[flang-commits] [flang] 7c55dd8 - [flang] Accept multiple spaces after compiler directive sentinel (#76541)
via flang-commits
flang-commits at lists.llvm.org
Tue Jan 2 09:15:08 PST 2024
Author: Peter Klausler
Date: 2024-01-02T09:15:04-08:00
New Revision: 7c55dd8de64823deb71bbeff8543e31ab6264cd9
URL: https://github.com/llvm/llvm-project/commit/7c55dd8de64823deb71bbeff8543e31ab6264cd9
DIFF: https://github.com/llvm/llvm-project/commit/7c55dd8de64823deb71bbeff8543e31ab6264cd9.diff
LOG: [flang] Accept multiple spaces after compiler directive sentinel (#76541)
The prescanner allows multiple spaces within a compiler directive, but
not between the directive's sentinel (e.g., !DIR$) and the directive's
first token.
Fixes https://github.com/llvm/llvm-project/issues/76537.
Added:
Modified:
flang/lib/Parser/prescan.cpp
flang/test/Parser/compiler-directives.f90
Removed:
################################################################################
diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index 79cdaccf1fbfec..68d7d9f0c53c47 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -139,16 +139,18 @@ void Prescanner::Statement() {
SkipSpaces();
}
} else {
- // Compiler directive. Emit normalized sentinel.
+ // Compiler directive. Emit normalized sentinel, squash following spaces.
EmitChar(tokens, '!');
++at_, ++column_;
for (const char *sp{directiveSentinel_}; *sp != '\0';
++sp, ++at_, ++column_) {
EmitChar(tokens, *sp);
}
- if (*at_ == ' ') {
+ if (*at_ == ' ' || *at_ == '\t') {
EmitChar(tokens, ' ');
- ++at_, ++column_;
+ while (*at_ == ' ' || *at_ == '\t') {
+ ++at_, ++column_;
+ }
}
tokens.CloseToken();
}
diff --git a/flang/test/Parser/compiler-directives.f90 b/flang/test/Parser/compiler-directives.f90
index 88cfd0944faf0a..67e8d5b292aa07 100644
--- a/flang/test/Parser/compiler-directives.f90
+++ b/flang/test/Parser/compiler-directives.f90
@@ -17,6 +17,7 @@ module m
!dir$ integer
!dir$ integer=64
!dir$ integer = 64
+ !dir$ integer = 64
PROC(4)
!dir$ optimize:1
!dir$ optimize : 1
More information about the flang-commits
mailing list