-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang][OpenMP] Fix regression in !$ continuation #134756
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
Conversation
@llvm/pr-subscribers-flang-openmp @llvm/pr-subscribers-flang-parser Author: Peter Klausler (klausler) ChangesA recent patch that obviated the need to use -fopenmp when using the compiler to preprocess in -E mode broke a case of Fortran line continuation when using OpenMP conditional compilation lines (!$) when not in -E mode. Fix. Full diff: https://github.com/llvm/llvm-project/pull/134756.diff 1 Files Affected:
diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index 31fdadeddef53..a55a610a1f4f2 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -1351,26 +1351,37 @@ const char *Prescanner::FreeFormContinuationLine(bool ampersand) {
}
p = SkipWhiteSpaceIncludingEmptyMacros(p);
if (InCompilerDirective()) {
- if (preprocessingOnly_ && directiveSentinel_[0] == '$' &&
- directiveSentinel_[1] == '\0') {
- // in -E mode, don't treat !$ as a continuation
+ if (directiveSentinel_[0] == '$' && directiveSentinel_[1] == '\0') {
+ if (preprocessingOnly_) {
+ // in -E mode, don't treat !$ as a continuation
+ return nullptr;
+ } else if (p[0] == '!' && p[1] == '$') {
+ // accept but do not require a matching sentinel
+ if (IsLetter(p[2])) {
+ return nullptr; // not !$
+ }
+ p += 2;
+ }
} else if (*p++ == '!') {
for (const char *s{directiveSentinel_}; *s != '\0'; ++p, ++s) {
if (*s != ToLowerCaseLetter(*p)) {
return nullptr; // not the same directive class
}
}
- p = SkipWhiteSpace(p);
- if (*p == '&') {
- if (!ampersand) {
- insertASpace_ = true;
- }
- return p + 1;
- } else if (ampersand) {
- return p;
+ } else {
+ return nullptr;
+ }
+ p = SkipWhiteSpace(p);
+ if (*p == '&') {
+ if (!ampersand) {
+ insertASpace_ = true;
}
+ return p + 1;
+ } else if (ampersand) {
+ return p;
+ } else {
+ return nullptr;
}
- return nullptr;
}
if (p[0] == '!' && p[1] == '$' && !preprocessingOnly_ &&
features_.IsEnabled(LanguageFeature::OpenMP)) {
|
Maybe some tests should be added for the failure fixed by this PR? (I don't remember seeing regression in check-flang, so perhaps there are no tests there that cover this condition...) |
A recent patch that obviated the need to use -fopenmp when using the compiler to preprocess in -E mode broke a case of Fortran line continuation when using OpenMP conditional compilation lines (!$) when *not* in -E mode. Fix.
Added tests, and verified changes against test suite failures. |
A recent patch that obviated the need to use -fopenmp when using the compiler to preprocess in -E mode broke a case of Fortran line continuation when using OpenMP conditional compilation lines (!$) when *not* in -E mode. Fix.
This commit (0ae9bb9) breaks building a SPEC openmp benchmark (https://www.spec.org/auto/omp2012/Docs/357.bt331.html). A reduced test case: program BT
!$ integer omp_get_max_threads
!$ external omp_get_max_threads
c---------------------------------------------------------------------
write(*, '(A1)') ' '
end This leads to the following compile error:
|
Fix is ready, will merge today.
From: Robert Imschweiler ***@***.***>
Date: Monday, April 14, 2025 at 08:45
To: llvm/llvm-project ***@***.***>
Cc: Peter Klausler ***@***.***>, State change ***@***.***>
Subject: Re: [llvm/llvm-project] [flang][OpenMP] Fix regression in !$ continuation (PR #134756)
This commit (0ae9bb9<0ae9bb9>) breaks building a SPEC openmp benchmark (https://www.spec.org/auto/omp2012/Docs/357.bt331.html). A reduced test case:
program BT
!$ integer omp_get_max_threads
!$ external omp_get_max_threads
c---------------------------------------------------------------------
write(*, '(A1)') ' '
end
This leads to the following compile error:
$ flang -fopenmp -c bt.condcomp.f
error: Could not parse bt.condcomp.f
./bt.condcomp.f:1:1: warning: Character in fixed-form label field must be a digit
program BT
^
./bt.condcomp.f:5:6: error: expected end of statement
c---------------------------------------------------------------------
^
./bt.condcomp.f:3:8: in the context: specification construct
!$ external omp_get_max_threads
^
./bt.condcomp.f:2:8: in the context: specification part
!$ integer omp_get_max_threads
^
—
Reply to this email directly, view it on GitHub<#134756 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AIRI5XPBYKGM6DDMNCF3Q4D2ZPJZRAVCNFSM6AAAAAB2U2RVDGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMBSGE2DINBSGY>.
You are receiving this because you modified the open/close state.Message ID: ***@***.***>
[Image removed by sender.]ro-i left a comment (llvm/llvm-project#134756)<#134756 (comment)>
This commit (0ae9bb9<0ae9bb9>) breaks building a SPEC openmp benchmark (https://www.spec.org/auto/omp2012/Docs/357.bt331.html). A reduced test case:
program BT
!$ integer omp_get_max_threads
!$ external omp_get_max_threads
c---------------------------------------------------------------------
write(*, '(A1)') ' '
end
This leads to the following compile error:
$ flang -fopenmp -c bt.condcomp.f
error: Could not parse bt.condcomp.f
./bt.condcomp.f:1:1: warning: Character in fixed-form label field must be a digit
program BT
^
./bt.condcomp.f:5:6: error: expected end of statement
c---------------------------------------------------------------------
^
./bt.condcomp.f:3:8: in the context: specification construct
!$ external omp_get_max_threads
^
./bt.condcomp.f:2:8: in the context: specification part
!$ integer omp_get_max_threads
^
—
Reply to this email directly, view it on GitHub<#134756 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AIRI5XPBYKGM6DDMNCF3Q4D2ZPJZRAVCNFSM6AAAAAB2U2RVDGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMBSGE2DINBSGY>.
You are receiving this because you modified the open/close state.Message ID: ***@***.***>
|
A recent patch that obviated the need to use -fopenmp when using the compiler to preprocess in -E mode broke a case of Fortran line continuation when using OpenMP conditional compilation lines (!$) when *not* in -E mode. Fix.
A recent patch that obviated the need to use -fopenmp when using the compiler to preprocess in -E mode broke a case of Fortran line continuation when using OpenMP conditional compilation lines (!$) when not in -E mode. Fix.