Skip to content

Commit 19c9348

Browse files
[FLANG][OPENMP] Fix handling of continuation lines in mixed OpenMP an… (#120714)
…d Fortran free-form OpenMP feature was not enabled in the flang-new for the continuation line, when we used the continuation line marker in combination of free-form and OpenMP directive, it was throwing an error. PR is the fix for that issue. Added a fix for the following issue #89559
1 parent bc51a2e commit 19c9348

File tree

2 files changed

+55
-7
lines changed

2 files changed

+55
-7
lines changed

flang/lib/Parser/prescan.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,14 +1289,18 @@ const char *Prescanner::FreeFormContinuationLine(bool ampersand) {
12891289
return nullptr;
12901290
}
12911291
p = SkipWhiteSpace(p);
1292-
if (InCompilerDirective()) {
1293-
if (*p++ != '!') {
1294-
return nullptr;
1295-
}
1296-
for (const char *s{directiveSentinel_}; *s != '\0'; ++p, ++s) {
1297-
if (*s != ToLowerCaseLetter(*p)) {
1298-
return nullptr;
1292+
if (*p == '!') {
1293+
++p;
1294+
if (InCompilerDirective()) {
1295+
for (const char *s{directiveSentinel_}; *s != '\0'; ++p, ++s) {
1296+
if (*s != ToLowerCaseLetter(*p)) {
1297+
return nullptr;
1298+
}
12991299
}
1300+
} else if (features_.IsEnabled(LanguageFeature::OpenMP) && *p == '$') {
1301+
++p;
1302+
} else {
1303+
return nullptr;
13001304
}
13011305
p = SkipWhiteSpace(p);
13021306
if (*p == '&') {
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
! RUN: %flang_fc1 -fopenmp -E %s 2>&1 | FileCheck %s --check-prefix=CHECK-OMP
2+
! RUN: %flang_fc1 -E %s 2>&1 | FileCheck %s
3+
4+
5+
! Test in mixed way, i.e., combination of Fortran free source form
6+
! and free source form with conditional compilation sentinel.
7+
! CHECK-LABEL: subroutine mixed_form1()
8+
! CHECK-OMP: i = 1 +100+ 1000+ 10 + 1 +1000000000 + 1000000
9+
! CHECK: i = 1 + 10 + 10000 + 1000000
10+
subroutine mixed_form1()
11+
i = 1 &
12+
!$+100&
13+
!$&+ 1000&
14+
&+ 10 + 1&
15+
!$& +100000&
16+
&0000 + 1000000
17+
end subroutine
18+
19+
20+
! Testing continuation lines in only Fortran Free form Source
21+
! CHECK-LABEL: subroutine mixed_form2()
22+
! CHECK-OMP: i = 1 +10 +100 + 1000 + 10000
23+
! CHECK: i = 1 +10 +100 + 1000 + 10000
24+
subroutine mixed_form2()
25+
i = 1 &
26+
+10 &
27+
&+100
28+
& + 1000 &
29+
+ 10000
30+
end subroutine
31+
32+
33+
! Testing continuation line in only free source form conditional compilation sentinel.
34+
! CHECK-LABEL: subroutine mixed_form3()
35+
! CHECK-OMP: i=0
36+
! CHECK-OMP: i = 1 +10 +100+1000
37+
subroutine mixed_form3()
38+
!$ i=0
39+
!$ i = 1 &
40+
!$ & +10 &
41+
!$&+100&
42+
!$ +1000
43+
end subroutine
44+

0 commit comments

Comments
 (0)