[flang-commits] [flang] [flang][openacc] Make OpenACC block construct parse errors less verbose. (PR #131042)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Mon Mar 17 14:16:08 PDT 2025
================
@@ -221,11 +228,19 @@ TYPE_PARSER(sourced(construct<AccBeginBlockDirective>(
sourced(Parser<AccBlockDirective>{}), Parser<AccClauseList>{})))
TYPE_PARSER(startAccLine >> sourced(construct<AccEndBlockDirective>("END"_tok >>
- sourced(Parser<AccBlockDirective>{}))))
+ sourced(recovery(Parser<AccBlockDirective>{},
+ construct<AccBlockDirective>(pure(
+ llvm::acc::Directive::ACCD_data)))))))
TYPE_PARSER(construct<OpenACCBlockConstruct>(
Parser<AccBeginBlockDirective>{} / endAccLine, block,
- Parser<AccEndBlockDirective>{} / endAccLine))
+ // TODO: This still allows mismatched directives.
+ recovery(withMessage("expected OpenACC end block directive"_err_en_US,
+ attempt(Parser<AccEndBlockDirective>{} / endAccLine)),
+ // TODO: Is there a simpler way to build this?
+ sourced(construct<AccEndBlockDirective>(
----------------
klausler wrote:
Are you sure that you want `sourced` here? It's going to create `AccEndBlockDirective` and `AccBlockDirective` class instances whose `source` data members will point to something that isn't such a thing, and that might cause semantic error messages on those parse tree nodes to point to arbitrary locations in the source file.
https://github.com/llvm/llvm-project/pull/131042
More information about the flang-commits
mailing list