Skip to content

Commit 1ada235

Browse files
authored
[flang][preprocessor] Fix handling of #line before free-form continua… (#100178)
…tion See new test. A #line (or #) directive after a line ending with & and before its continuation shouldn't elicit an error about mismatched parentheses. Fixes #100073.
1 parent 539a6b5 commit 1ada235

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

flang/lib/Parser/prescan.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,13 @@ void Prescanner::Statement() {
111111
skipLeadingAmpersand_ |= !inFixedForm_;
112112
return;
113113
case LineClassification::Kind::PreprocessorDirective:
114+
preprocessor_.Directive(TokenizePreprocessorDirective(), *this);
115+
afterPreprocessingDirective_ = true;
116+
// Don't set skipLeadingAmpersand_
117+
return;
114118
case LineClassification::Kind::DefinitionDirective:
115119
preprocessor_.Directive(TokenizePreprocessorDirective(), *this);
116-
// Don't set afterPreprocessingDirective_
120+
// Don't set afterPreprocessingDirective_ or skipLeadingAmpersand_
117121
return;
118122
case LineClassification::Kind::CompilerDirective: {
119123
directiveSentinel_ = line.sentinel;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
! RUN: %flang_fc1 -E %s 2>&1 | FileCheck %s
2+
! CHECK: call foo( 0.)
3+
! CHECK: call foo( 1.)
4+
! CHECK: call foo( 2.)
5+
! CHECK: call foo( 3.)
6+
call foo( &
7+
# 100 "bar.h"
8+
& 0.)
9+
call foo( &
10+
# 101 "bar.h"
11+
1.)
12+
call foo( &
13+
# 102 "bar.h"
14+
& 2. &
15+
& )
16+
call foo( &
17+
# 103 "bar.h"
18+
& 3. &
19+
)
20+
end

0 commit comments

Comments
 (0)