diff options
author | Peter Klausler <35819229+klausler@users.noreply.github.com> | 2024-06-28 12:16:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-28 12:16:41 -0700 |
commit | 259ce1199906554fba5c8d3b07b6ce14ee42d301 (patch) | |
tree | 93d0c2fdcdf1f015651dcbb48c64f681842f65c6 /flang/lib/Parser/token-sequence.cpp | |
parent | cddbcd15a0e6ef59e1cae0a68d000b0c5942ff43 (diff) | |
download | llvm-259ce1199906554fba5c8d3b07b6ce14ee42d301.zip llvm-259ce1199906554fba5c8d3b07b6ce14ee42d301.tar.gz llvm-259ce1199906554fba5c8d3b07b6ce14ee42d301.tar.bz2 |
[flang] Accept a compiler directive sentinel after a semicolon (#96966)
Don't treat !DIR$ or an active !$ACC, !$OMP, &c. as a comment when they
appear after a semicolon, but instead treat them as a compiler directive
sentinel.
Diffstat (limited to 'flang/lib/Parser/token-sequence.cpp')
-rw-r--r-- | flang/lib/Parser/token-sequence.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/flang/lib/Parser/token-sequence.cpp b/flang/lib/Parser/token-sequence.cpp index 133e60b..c73bca1 100644 --- a/flang/lib/Parser/token-sequence.cpp +++ b/flang/lib/Parser/token-sequence.cpp @@ -266,7 +266,7 @@ TokenSequence &TokenSequence::ClipComment( if (std::size_t blanks{tok.CountLeadingBlanks()}; blanks < tok.size() && tok[blanks] == '!') { // Retain active compiler directive sentinels (e.g. "!dir$") - for (std::size_t k{j + 1}; k < tokens && tok.size() < blanks + 5; ++k) { + for (std::size_t k{j + 1}; k < tokens && tok.size() <= blanks + 5; ++k) { if (tok.begin() + tok.size() == TokenAt(k).begin()) { tok.ExtendToCover(TokenAt(k)); } else { @@ -274,12 +274,9 @@ TokenSequence &TokenSequence::ClipComment( } } bool isSentinel{false}; - if (tok.size() == blanks + 5) { - char sentinel[4]; - for (int k{0}; k < 4; ++k) { - sentinel[k] = ToLowerCaseLetter(tok[blanks + k + 1]); - } - isSentinel = prescanner.IsCompilerDirectiveSentinel(sentinel, 4); + if (tok.size() > blanks + 5) { + isSentinel = prescanner.IsCompilerDirectiveSentinel(&tok[blanks + 1]) + .has_value(); } if (isSentinel) { } else if (skipFirst) { |