Skip to content

Commit 507ce46

Browse files
authored
[flang][preprocessor] Directive continuation must skip empty macros (#134149)
When a compiler directive continuation line starts with keyword macro names that have empty expansions, skip them.
1 parent efd7caa commit 507ce46

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

flang/lib/Parser/prescan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ const char *Prescanner::FreeFormContinuationLine(bool ampersand) {
13251325
if (p >= limit_) {
13261326
return nullptr;
13271327
}
1328-
p = SkipWhiteSpace(p);
1328+
p = SkipWhiteSpaceIncludingEmptyMacros(p);
13291329
if (*p == '!') {
13301330
++p;
13311331
if (InCompilerDirective()) {

flang/test/Preprocessing/directive-contin-with-pp.F90

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define COMMENT !
99
#define OMP_START !$omp
1010
#define OMP_CONT !$omp&
11+
#define EMPTY
1112

1213
module m
1314
contains
@@ -50,6 +51,11 @@ subroutine s1(x1, x2, x3, x4, x5, x6, x7)
5051
OMP_CONT reduction(+:x)
5152
do j3 = 1, n
5253
end do
54+
55+
EMPTY !$omp parallel &
56+
EMPTY !$omp do
57+
do j4 = 1, n
58+
end do
5359
end
5460

5561
COMMENT &
@@ -79,6 +85,9 @@ subroutine s3
7985
!CHECK: !$OMP PARALLEL DO REDUCTION(+: x)
8086
!CHECK: DO j3=1_4,n
8187
!CHECK: END DO
88+
!CHECK: !$OMP PARALLEL DO
89+
!CHECK: DO j4=1_4,n
90+
!CHECK: END DO
8291
!CHECK: END SUBROUTINE
8392
!CHECK: SUBROUTINE s2
8493
!CHECK: END SUBROUTINE

0 commit comments

Comments
 (0)