[flang-commits] [flang] [FLANG][OPENMP] Fix handling of continuation lines in mixed OpenMP an… (PR #120714)
Leandro Lupori via flang-commits
flang-commits at lists.llvm.org
Fri Dec 20 10:54:06 PST 2024
================
@@ -1289,29 +1289,49 @@ const char *Prescanner::FreeFormContinuationLine(bool ampersand) {
return nullptr;
}
p = SkipWhiteSpace(p);
- if (InCompilerDirective()) {
- if (*p++ != '!') {
- return nullptr;
- }
- for (const char *s{directiveSentinel_}; *s != '\0'; ++p, ++s) {
- if (*s != ToLowerCaseLetter(*p)) {
+ if (*p == '!') {
+ if (InCompilerDirective()) {
+ if (*p++ != '!') {
return nullptr;
}
- }
- p = SkipWhiteSpace(p);
- if (*p == '&') {
- if (!ampersand) {
- insertASpace_ = true;
+ for (const char *s{directiveSentinel_}; *s != '\0'; ++p, ++s) {
+ if (*s != ToLowerCaseLetter(*p)) {
+ return nullptr;
+ }
+ }
+ p = SkipWhiteSpace(p);
+ if (*p == '&') {
+ if (!ampersand) {
+ insertASpace_ = true;
+ }
+ return p + 1;
+ } else if (ampersand) {
+ return p;
+ } else {
+ return nullptr;
+ }
+ } else if (features_.IsEnabled(LanguageFeature::OpenMP)) {
+ if (*p + 1 == '$')
+ return nullptr;
+ p += 2;
+ p = SkipWhiteSpace(p);
+ if (*p == '&') {
+ if (!ampersand) {
+ insertASpace_ = true;
+ }
+ return p + 1;
+ } else if (ampersand) {
+ return p;
+ } else {
+ return nullptr;
}
----------------
luporl wrote:
```suggestion
for (const char *s{directiveSentinel_}; *s != '\0'; ++p, ++s) {
if (*s != ToLowerCaseLetter(*p)) {
return nullptr;
}
}
} else if (features_.IsEnabled(LanguageFeature::OpenMP) && *p == '$') {
++p;
} else {
return nullptr;
}
p = SkipWhiteSpace(p);
if (*p == '&') {
if (!ampersand) {
insertASpace_ = true;
}
return p + 1;
} else if (ampersand) {
return p;
```
You can reorganize this block of code in a different way, to avoid repeating the logic that deals with ampersand.
https://github.com/llvm/llvm-project/pull/120714
More information about the flang-commits
mailing list