File tree Expand file tree Collapse file tree 2 files changed +96
-15
lines changed Expand file tree Collapse file tree 2 files changed +96
-15
lines changed Original file line number Diff line number Diff line change @@ -1289,29 +1289,49 @@ 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)) {
1292+ if (*p == ' !' ) {
1293+ if (InCompilerDirective ()) {
1294+ if (*p++ != ' !' ) {
12981295 return nullptr ;
12991296 }
1300- }
1301- p = SkipWhiteSpace (p);
1302- if (*p == ' &' ) {
1303- if (!ampersand) {
1304- insertASpace_ = true ;
1297+ for (const char *s{directiveSentinel_}; *s != ' \0 ' ; ++p, ++s) {
1298+ if (*s != ToLowerCaseLetter (*p)) {
1299+ return nullptr ;
1300+ }
1301+ }
1302+ p = SkipWhiteSpace (p);
1303+ if (*p == ' &' ) {
1304+ if (!ampersand) {
1305+ insertASpace_ = true ;
1306+ }
1307+ return p + 1 ;
1308+ } else if (ampersand) {
1309+ return p;
1310+ } else {
1311+ return nullptr ;
1312+ }
1313+ } else if (features_.IsEnabled (LanguageFeature::OpenMP)) {
1314+ if (*p + 1 == ' $' )
1315+ return nullptr ;
1316+ p += 2 ;
1317+ p = SkipWhiteSpace (p);
1318+ if (*p == ' &' ) {
1319+ if (!ampersand) {
1320+ insertASpace_ = true ;
1321+ }
1322+ return p + 1 ;
1323+ } else if (ampersand) {
1324+ return p;
1325+ } else {
1326+ return nullptr ;
13051327 }
1306- return p + 1 ;
1307- } else if (ampersand) {
1308- return p;
13091328 } else {
13101329 return nullptr ;
13111330 }
13121331 } else {
13131332 if (*p == ' &' ) {
1314- return p + 1 ;
1333+ p = SkipWhiteSpace (p + 1 );
1334+ return p;
13151335 } else if (*p == ' !' || *p == ' \n ' || *p == ' #' ) {
13161336 return nullptr ;
13171337 } else if (ampersand || IsImplicitContinuation ()) {
Original file line number Diff line number Diff line change 1+ ! RUN: flang-new -fopenmp -E %s 2>&1 | FileCheck %s --check-prefix=CHECK-OMP
2+ ! RUN: flang-new -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+
21+ ! CHECK-LABEL: subroutine mixed_form2()
22+ ! CHECK-OMP: i = 0
23+ ! CHECK-OMP: i = 1 +100+ 1000+ 10 + 1 +1000000000 + 1000000
24+ ! CHECK: i = 1 + 10 + 10000 + 1000000
25+ subroutine mixed_form2 ()
26+ ! $ i = 0
27+ i = 1 &
28+ ! $+100&
29+ ! $&+ 1000&
30+ &+ 10 + 1 &
31+ ! $& +100000&
32+ & 0000 + 1000000
33+
34+ end subroutine
35+
36+
37+ ! Testing continuation lines in only Fortran Free form Source
38+ ! CHECK-LABEL: subroutine mixed_form3()
39+ ! CHECK-OMP: i = 1 +10 +100+ 1000 + 10000
40+ ! CHECK: i = 1 +10 +100+ 1000 + 10000
41+ subroutine mixed_form3 ()
42+ i = 1 &
43+ + 10 &
44+ &+ 100
45+ & + 1000 &
46+ + 10000
47+ end subroutine
48+
49+
50+ ! Testing continuation line in only free source form conditional compilation sentinel.
51+ ! CHECK-LABEL: subroutine mixed_form4()
52+ ! CHECK-OMP: i=0
53+ ! CHECK-OMP: i = 1 +10 +100+1000
54+ subroutine mixed_form4 ()
55+ ! $ i=0
56+ ! $ i = 1 &
57+ ! $ & +10 &
58+ ! $&+100&
59+ ! $ +1000
60+ end subroutine
61+
You can’t perform that action at this time.
0 commit comments