Skip to content

Commit 7de70e0

Browse files
authored
[Flang][OpenMP] Fix comments that should not be Sentinels on fixed format. (#68911)
Fixes #68653
1 parent f95b2f1 commit 7de70e0

File tree

2 files changed

+49
-9
lines changed

2 files changed

+49
-9
lines changed

flang/lib/Parser/prescan.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,16 +1177,14 @@ Prescanner::IsFixedFormCompilerDirectiveLine(const char *start) const {
11771177
char sentinel[5], *sp{sentinel};
11781178
int column{2};
11791179
for (; column < 6; ++column, ++p) {
1180-
if (*p != ' ') {
1181-
if (*p == '\n' || *p == '\t') {
1182-
break;
1183-
}
1184-
if (sp == sentinel + 1 && sentinel[0] == '$' && IsDecimalDigit(*p)) {
1185-
// OpenMP conditional compilation line: leave the label alone
1186-
break;
1187-
}
1188-
*sp++ = ToLowerCaseLetter(*p);
1180+
if (*p == ' ' || *p == '\n' || *p == '\t') {
1181+
break;
1182+
}
1183+
if (sp == sentinel + 1 && sentinel[0] == '$' && IsDecimalDigit(*p)) {
1184+
// OpenMP conditional compilation line: leave the label alone
1185+
break;
11891186
}
1187+
*sp++ = ToLowerCaseLetter(*p);
11901188
}
11911189
if (column == 6) {
11921190
if (*p == ' ' || *p == '\t' || *p == '0') {

flang/test/Parser/OpenMP/sentinels.f

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
! RUN: %flang_fc1 -fopenmp -E %s | FileCheck %s
2+
! CHECK: program main
3+
! CHECK: interface
4+
! CHECK: subroutine sub(a, b)
5+
! CHECK:!dir$ ignore_tkr a
6+
! CHECK:!dir$ ignore_tkr b
7+
! CHECK: real(4):: a, b
8+
! CHECK: end subroutine
9+
! CHECK: end interface
10+
! CHECK: PRINT *, "Is ' '"
11+
! CHECK: 123 PRINT *, "Is '123 '"
12+
13+
!@cuf subroutine atcuf;
14+
program main
15+
interface
16+
subroutine sub(a, b)
17+
!dir$ ignore_tkr a
18+
!dir$ ignore_tkr
19+
!dir$+ b
20+
real(4):: a, b
21+
end subroutine
22+
end interface
23+
!
24+
! comment line
25+
!@fp PRINT *, "This is a comment line"
26+
!@f p PRINT *, "This is a comment line"
27+
!$ PRINT *, "Is ' '"
28+
!$123 PRINT *, "Is '123 '"
29+
!$ABC PRINT *, "Is 'ABC '"
30+
! $ PRINT *, "This is a comment line 6"
31+
c $This is a comment line
32+
!0$110This is a comment line
33+
34+
! $ This is a comment line
35+
! $ 0This is a comment line
36+
! &This is a comment line
37+
! $ This is a comment line
38+
! $ This is a comment line
39+
C $ This is a comment line
40+
c $ his is a comment line
41+
* $ This is a comment line
42+
end

0 commit comments

Comments
 (0)