Skip to content

[flang][preprocessor] Fix handling of #line before free-form continua… #100178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2024
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
6 changes: 5 additions & 1 deletion flang/lib/Parser/prescan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ void Prescanner::Statement() {
skipLeadingAmpersand_ |= !inFixedForm_;
return;
case LineClassification::Kind::PreprocessorDirective:
preprocessor_.Directive(TokenizePreprocessorDirective(), *this);
afterPreprocessingDirective_ = true;
// Don't set skipLeadingAmpersand_
return;
case LineClassification::Kind::DefinitionDirective:
preprocessor_.Directive(TokenizePreprocessorDirective(), *this);
// Don't set afterPreprocessingDirective_
// Don't set afterPreprocessingDirective_ or skipLeadingAmpersand_
return;
case LineClassification::Kind::CompilerDirective: {
directiveSentinel_ = line.sentinel;
Expand Down
20 changes: 20 additions & 0 deletions flang/test/Preprocessing/line-in-contin.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
! RUN: %flang_fc1 -E %s 2>&1 | FileCheck %s
! CHECK: call foo( 0.)
! CHECK: call foo( 1.)
! CHECK: call foo( 2.)
! CHECK: call foo( 3.)
call foo( &
# 100 "bar.h"
& 0.)
call foo( &
# 101 "bar.h"
1.)
call foo( &
# 102 "bar.h"
& 2. &
& )
call foo( &
# 103 "bar.h"
& 3. &
)
end
Loading