Skip to content

Commit 766c480

Browse files
committed
[Flang][OpenMP] Fix compilation error when a line with Fixed Source Form Conditional Compilation Sentinels is a continuation line
1 parent 18775a4 commit 766c480

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

flang/lib/Parser/prescan.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -997,20 +997,27 @@ const char *Prescanner::FixedFormContinuationLine(bool mightNeedSpace) {
997997
}
998998
tabInCurrentLine_ = false;
999999
char col1{*nextLine_};
1000-
if (InCompilerDirective()) {
1001-
// Must be a continued compiler directive.
1002-
if (!IsFixedFormCommentChar(col1)) {
1003-
return nullptr;
1004-
}
1000+
if (InCompilerDirective() ||
1001+
(features_.IsEnabled(LanguageFeature::OpenMP) &&
1002+
IsFixedFormCommentChar(col1) && nextLine_[1] == '$')) {
10051003
int j{1};
1006-
for (; j < 5; ++j) {
1007-
char ch{directiveSentinel_[j - 1]};
1008-
if (ch == '\0') {
1009-
break;
1010-
}
1011-
if (ch != ToLowerCaseLetter(nextLine_[j])) {
1004+
if (InCompilerDirective()) {
1005+
// Must be a continued compiler directive.
1006+
if (!IsFixedFormCommentChar(col1)) {
10121007
return nullptr;
10131008
}
1009+
for (; j < 5; ++j) {
1010+
char ch{directiveSentinel_[j - 1]};
1011+
if (ch == '\0') {
1012+
break;
1013+
}
1014+
if (ch != ToLowerCaseLetter(nextLine_[j])) {
1015+
return nullptr;
1016+
}
1017+
}
1018+
} else {
1019+
// Fixed Source Form Conditional Compilation Sentinels.
1020+
j = 2;
10141021
}
10151022
for (; j < 5; ++j) {
10161023
if (nextLine_[j] != ' ') {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
! RUN: %flang_fc1 -fopenmp -fopenacc -E %s 2>&1 | FileCheck %s
2+
program main
3+
! CHECK: k01=1+1
4+
k01=1+
5+
!$ & 1
6+
7+
! CHECK: !$omp parallel
8+
!$omp para
9+
!$omp+llel
10+
!$omp end parallel
11+
12+
! CHECK-NOT: comment
13+
!$omp parallel
14+
!$acc+comment
15+
!$omp end parallel
16+
end

0 commit comments

Comments
 (0)