[flang-commits] [flang] Recognition of the Fortran 2023 ENUMERATION TYPE. (PR #185497)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Wed Mar 18 05:49:59 PDT 2026
================
@@ -669,6 +669,34 @@ TYPE_PARSER(
TYPE_PARSER(recovery("END ENUM"_tok, constructEndStmtErrorRecovery) >>
construct<EndEnumStmt>())
+// R766 enumeration-type-def ->
+// enumeration-type-stmt
+// enumeration-enumerator-stmt [ enumeration-enumerator-stmt ]...
+// end-enumeration-type-stmt
+TYPE_CONTEXT_PARSER("enumeration type definition"_en_US,
+ construct<EnumerationTypeDef>(statement(Parser<EnumerationTypeStmt>{}),
+ some(unambiguousStatement(Parser<EnumerationEnumeratorStmt>{})),
----------------
klausler wrote:
`some` will fail if there are no enumerators, leading to a parse failure for the program. If you use `many` instead, you can diagnose the error in semantics and fail more gracefully.
https://github.com/llvm/llvm-project/pull/185497
More information about the flang-commits
mailing list