Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions flang/lib/Parser/prescan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,12 +712,16 @@ bool Prescanner::NextToken(TokenSequence &tokens) {
// Subtlety: When an identifier is split across three or more continuation
// lines (or two continuation lines, immediately preceded or followed
// by '&' free form continuation line markers, its parts are kept as
// distinct pp-tokens so that macro operates on them independently.
// This trick accommodates the historic practice of using line
// continuation for token pasting after replacement.
// distinct pp-tokens so that macro replacement operates on them
// independently. This trick accommodates the historic practice of
// using line continuation for token pasting after replacement.
} else if (parts == 2) {
if (afterLast && afterLast < limit_) {
afterLast = SkipWhiteSpace(afterLast);
}
if ((start > start_ && start[-1] == '&') ||
(afterLast < limit_ && (*afterLast == '&' || *afterLast == '\n'))) {
(afterLast && afterLast < limit_ &&
(*afterLast == '&' || *afterLast == '\n'))) {
// call & call foo& call foo&
// &MACRO& OR &MACRO& OR &MACRO
// &foo(...) &(...)
Expand Down
12 changes: 8 additions & 4 deletions flang/test/Preprocessing/pp134.F90
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
! RUN: %flang -E %s 2>&1 | FileCheck %s
! CHECK: print *, ADC, 1
! CHECK: print *, AD, 1
! CHECK: print *, DC, 1
! CHECK: print *, AD, 2
! CHECK: print *, DC, 3
! CHECK: print *, AD(1), 4
! CHECK: print *, AD
! CHECK: print *, AB
#define B D
Expand All @@ -12,10 +13,13 @@
&C, 1
print *, A&
&B&
&, 1
&, 2
print *, &
&B&
&C, 1
&C, 3
print *, A&
&B &
&(1), 4
print *, A&
&B
print *, A&
Expand Down