diff options
author | Peter Klausler <35819229+klausler@users.noreply.github.com> | 2024-06-13 11:22:27 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-13 11:22:27 -0700 |
commit | 86bee819120b5ba4b7262c7800a88fbf904d4932 (patch) | |
tree | 0bc663b453c94068cc502bc5bda032db90f82111 /flang/lib/Parser/token-sequence.cpp | |
parent | f8fc883da951064a310e365680b4b567fad58ebc (diff) | |
download | llvm-86bee819120b5ba4b7262c7800a88fbf904d4932.zip llvm-86bee819120b5ba4b7262c7800a88fbf904d4932.tar.gz llvm-86bee819120b5ba4b7262c7800a88fbf904d4932.tar.bz2 |
[flang][preprocessor] Fixed-form continuation across preprocessing di… (#95332)
…rective
Implement fixed-form line continuation when the continuation line is the
result of text produced by an #include or other preprocessing directive.
This accommodates the somewhat common practice of putting dummy or
actual arguments into a header file and #including it into several code
sites.
Fixes https://github.com/llvm/llvm-project/issues/78928.
Diffstat (limited to 'flang/lib/Parser/token-sequence.cpp')
-rw-r--r-- | flang/lib/Parser/token-sequence.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/flang/lib/Parser/token-sequence.cpp b/flang/lib/Parser/token-sequence.cpp index 40560bb..133e60b 100644 --- a/flang/lib/Parser/token-sequence.cpp +++ b/flang/lib/Parser/token-sequence.cpp @@ -378,9 +378,7 @@ const TokenSequence &TokenSequence::CheckBadFortranCharacters( return *this; } -const TokenSequence &TokenSequence::CheckBadParentheses( - Messages &messages) const { - // First, a quick pass with no allocation for the common case +bool TokenSequence::BadlyNestedParentheses() const { int nesting{0}; std::size_t tokens{SizeInTokens()}; for (std::size_t j{0}; j < tokens; ++j) { @@ -394,8 +392,14 @@ const TokenSequence &TokenSequence::CheckBadParentheses( } } } - if (nesting != 0) { + return nesting != 0; +} + +const TokenSequence &TokenSequence::CheckBadParentheses( + Messages &messages) const { + if (BadlyNestedParentheses()) { // There's an error; diagnose it + std::size_t tokens{SizeInTokens()}; std::vector<std::size_t> stack; for (std::size_t j{0}; j < tokens; ++j) { CharBlock token{TokenAt(j)}; |