Skip to content

Commit e5199e8

Browse files
klauslergithub-actions[bot]
authored andcommitted
Automerge: [flang] Fix prescanner bug w/ empty macros in line continuation (#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.
2 parents c917419 + f48f844 commit e5199e8

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;
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)