Skip to content

[flang] Dodge bogus GCC 13.2.0 error message in new code #86708

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

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

klausler
Copy link
Contributor

Rearrange some new code a little bit to avoid a bogus error message coming out from GCC 13.2.0 about an uninitialized data member in a parser.

Rearrange some new code a little bit to avoid a bogus error message
coming out from GCC 13.2.0 about an uninitialized data member in a
parser.
@klausler klausler requested a review from kazutakahirata March 26, 2024 18:24
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:parser labels Mar 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 26, 2024

@llvm/pr-subscribers-flang-parser

Author: Peter Klausler (klausler)

Changes

Rearrange some new code a little bit to avoid a bogus error message coming out from GCC 13.2.0 about an uninitialized data member in a parser.


Full diff: https://github.com/llvm/llvm-project/pull/86708.diff

2 Files Affected:

  • (modified) flang/include/flang/Parser/parse-tree.h (+1-1)
  • (modified) flang/lib/Parser/Fortran-parsers.cpp (+2-3)
diff --git a/flang/include/flang/Parser/parse-tree.h b/flang/include/flang/Parser/parse-tree.h
index 85e8121dd1250c..26b2e5f4e34b06 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -3317,7 +3317,7 @@ struct CompilerDirective {
     TUPLE_CLASS_BOILERPLATE(NameValue);
     std::tuple<Name, std::optional<std::uint64_t>> t;
   };
-  struct Unrecognized {};
+  EMPTY_CLASS(Unrecognized);
   CharBlock source;
   std::variant<std::list<IgnoreTKR>, LoopCount, std::list<AssumeAligned>,
       std::list<NameValue>, Unrecognized>
diff --git a/flang/lib/Parser/Fortran-parsers.cpp b/flang/lib/Parser/Fortran-parsers.cpp
index fd28eea0f947d2..21185694227d98 100644
--- a/flang/lib/Parser/Fortran-parsers.cpp
+++ b/flang/lib/Parser/Fortran-parsers.cpp
@@ -1280,9 +1280,8 @@ TYPE_PARSER(beginDirective >> "DIR$ "_tok >>
                     many(construct<CompilerDirective::NameValue>(
                         name, maybe(("="_tok || ":"_tok) >> digitString64))))) /
             endOfStmt ||
-        construct<CompilerDirective>(
-            SkipTo<'\n'>{} >> pure<CompilerDirective::Unrecognized>()) /
-            endOfStmt))
+        construct<CompilerDirective>(pure<CompilerDirective::Unrecognized>()) /
+            SkipTo<'\n'>{}))
 
 TYPE_PARSER(extension<LanguageFeature::CrayPointer>(
     "nonstandard usage: based POINTER"_port_en_US,

Copy link
Contributor

@kazutakahirata kazutakahirata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've verified that flang builds with gcc-13.2.0 and clang-16.0.6. I'll merge the patch shortly. Thanks a lot!

@kazutakahirata kazutakahirata merged commit 8a84596 into llvm:main Mar 26, 2024
@klausler klausler deleted the fix branch April 22, 2024 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:parser flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants