Skip to content

[Flang][OpenMP] Correctly handling continuation lines with Fixed Source Form Conditional Compilation Sentinels #70309

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 3 commits into from
Nov 1, 2023
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
27 changes: 17 additions & 10 deletions flang/lib/Parser/prescan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -997,20 +997,27 @@ const char *Prescanner::FixedFormContinuationLine(bool mightNeedSpace) {
}
tabInCurrentLine_ = false;
char col1{*nextLine_};
if (InCompilerDirective()) {
// Must be a continued compiler directive.
if (!IsFixedFormCommentChar(col1)) {
return nullptr;
}
if (IsFixedFormCommentChar(col1)) {
int j{1};
for (; j < 5; ++j) {
char ch{directiveSentinel_[j - 1]};
if (ch == '\0') {
break;
if (InCompilerDirective()) {
// Must be a continued compiler directive.
for (; j < 5; ++j) {
char ch{directiveSentinel_[j - 1]};
if (ch == '\0') {
break;
}
if (ch != ToLowerCaseLetter(nextLine_[j])) {
return nullptr;
}
}
if (ch != ToLowerCaseLetter(nextLine_[j])) {
} else if (features_.IsEnabled(LanguageFeature::OpenMP)) {
// Fixed Source Form Conditional Compilation Sentinels.
if (nextLine_[1] != '$') {
return nullptr;
}
j++;
} else {
return nullptr;
}
for (; j < 5; ++j) {
if (nextLine_[j] != ' ') {
Expand Down
16 changes: 16 additions & 0 deletions flang/test/Parser/continuation-in-conditional-compilation.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
! RUN: %flang_fc1 -fopenmp -fopenacc -E %s 2>&1 | FileCheck %s
program main
! CHECK: k01=1+1
k01=1+
!$ & 1

! CHECK: !$omp parallel private(k01)
!$omp parallel
!$omp+ private(k01)
!$omp end parallel

! CHECK-NOT: comment
!$omp parallel
!$acc+comment
!$omp end parallel
end