Skip to content

Commit b0fe8a9

Browse files
klauslergoogle-yfyang
authored andcommitted
[flang] Fix prescanner bug w/ empty macros in line continuation (llvm#141274)
When processing free form source line continuation, the prescanner treats empty keyword macros as if they were spaces or tabs. After skipping over them, however, there's code that only works if the skipped characters ended with an actual space or tab. If the last skipped item was an empty keyword macro's name, the last character of that name would end up being the first character of the continuation line. Fix.
1 parent e2de050 commit b0fe8a9

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

flang/lib/Parser/prescan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ const char *Prescanner::FreeFormContinuationLine(bool ampersand) {
14731473
GetProvenanceRange(p, p + 1),
14741474
"Character literal continuation line should have been preceded by '&'"_port_en_US);
14751475
}
1476-
} else if (p > lineStart) {
1476+
} else if (p > lineStart && IsSpaceOrTab(p - 1)) {
14771477
--p;
14781478
} else {
14791479
insertASpace_ = true;

flang/test/Preprocessing/bug890.F90

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
! RUN: %flang -E %s 2>&1 | FileCheck %s
2+
!CHECK: subroutine sub()
3+
#define empty
4+
subroutine sub ( &
5+
empty)
6+
end

0 commit comments

Comments
 (0)