@@ -1778,6 +1778,31 @@ struct OmpBlockConstructParser {
17781778 llvm::omp::Directive dir_;
17791779};
17801780
1781+ struct OmpDeclarativeAllocateParser {
1782+ using resultType = OmpAllocateDirective;
1783+
1784+ std::optional<resultType> Parse(ParseState &state) const {
1785+ constexpr llvm::omp::Directive dir{llvm::omp::Directive::OMPD_allocate};
1786+ if (auto &&begin{attempt(OmpBeginDirectiveParser(dir)).Parse(state)}) {
1787+ Block empty;
1788+ auto end{maybe(OmpEndDirectiveParser{dir}).Parse(state)};
1789+ return OmpAllocateDirective{std::move(*begin), std::move(empty),
1790+ llvm::transformOptional(std::move(*end),
1791+ [](auto &&s) { return OmpEndDirective(std::move(s)); })};
1792+ }
1793+ return std::nullopt;
1794+ }
1795+ };
1796+
1797+ struct OmpExecutableAllocateParser {
1798+ using resultType = OmpAllocateDirective;
1799+
1800+ std::optional<resultType> Parse(ParseState &state) const {
1801+ OmpStatementConstructParser p{llvm::omp::Directive::OMPD_allocate};
1802+ return construct<OmpAllocateDirective>(p).Parse(state);
1803+ }
1804+ };
1805+
17811806TYPE_PARSER(sourced(construct<OpenMPAllocatorsConstruct>(
17821807 OmpStatementConstructParser{llvm::omp::Directive::OMPD_allocators})))
17831808
@@ -2044,14 +2069,6 @@ TYPE_PARSER(construct<OmpInitializerExpression>(OmpStylizedExpressionParser{}))
20442069TYPE_PARSER(sourced(construct<OpenMPCriticalConstruct>(
20452070 OmpBlockConstructParser{llvm::omp::Directive::OMPD_critical})))
20462071
2047- // 2.11.3 Executable Allocate directive
2048- TYPE_PARSER(sourced(construct<OpenMPExecutableAllocate>(
2049- verbatim("ALLOCATE"_tok), maybe(parenthesized(Parser<OmpObjectList>{})),
2050- Parser<OmpClauseList>{},
2051- maybe(nonemptyList(startOmpLine >> Parser<OpenMPDeclarativeAllocate>{})) /
2052- endOmpLine,
2053- statement(allocateStmt))))
2054-
20552072// 2.8.2 Declare Simd construct
20562073TYPE_PARSER(sourced(construct<OpenMPDeclareSimdConstruct>(
20572074 predicated(Parser<OmpDirectiveName>{},
@@ -2077,13 +2094,6 @@ TYPE_PARSER(sourced( //
20772094 IsDirective(llvm::omp::Directive::OMPD_threadprivate)) >=
20782095 Parser<OmpDirectiveSpecification>{})))
20792096
2080- // 2.11.3 Declarative Allocate directive
2081- TYPE_PARSER(
2082- sourced(construct<OpenMPDeclarativeAllocate>(verbatim("ALLOCATE"_tok),
2083- maybe(parenthesized(Parser<OmpObjectList>{})),
2084- Parser<OmpClauseList>{})) /
2085- lookAhead(endOmpLine / !statement(allocateStmt)))
2086-
20872097// Assumes Construct
20882098TYPE_PARSER(sourced(construct<OpenMPDeclarativeAssumes>(
20892099 predicated(OmpDirectiveNameParser{},
@@ -2106,7 +2116,7 @@ TYPE_PARSER(
21062116 construct<OpenMPDeclarativeConstruct>(
21072117 Parser<OmpDeclareVariantDirective>{}) ||
21082118 construct<OpenMPDeclarativeConstruct>(
2109- Parser<OpenMPDeclarativeAllocate>{} ) ||
2119+ sourced(OmpDeclarativeAllocateParser{}) ) ||
21102120 construct<OpenMPDeclarativeConstruct>(
21112121 Parser<OpenMPGroupprivate>{}) ||
21122122 construct<OpenMPDeclarativeConstruct>(
@@ -2194,16 +2204,16 @@ TYPE_CONTEXT_PARSER("OpenMP construct"_en_US,
21942204 withMessage("expected OpenMP construct"_err_en_US,
21952205 first(construct<OpenMPConstruct>(Parser<OpenMPSectionsConstruct>{}),
21962206 construct<OpenMPConstruct>(Parser<OpenMPLoopConstruct>{}),
2207+ construct<OpenMPConstruct>(
2208+ sourced(OmpExecutableAllocateParser{})),
21972209 construct<OpenMPConstruct>(Parser<OmpBlockConstruct>{}),
21982210 // OmpBlockConstruct is attempted before
21992211 // OpenMPStandaloneConstruct to resolve !$OMP ORDERED
22002212 construct<OpenMPConstruct>(Parser<OpenMPStandaloneConstruct>{}),
22012213 construct<OpenMPConstruct>(Parser<OpenMPAtomicConstruct>{}),
22022214 construct<OpenMPConstruct>(Parser<OpenMPUtilityConstruct>{}),
22032215 construct<OpenMPConstruct>(Parser<OpenMPDispatchConstruct>{}),
2204- construct<OpenMPConstruct>(Parser<OpenMPExecutableAllocate>{}),
22052216 construct<OpenMPConstruct>(Parser<OpenMPAllocatorsConstruct>{}),
2206- construct<OpenMPConstruct>(Parser<OpenMPDeclarativeAllocate>{}),
22072217 construct<OpenMPConstruct>(Parser<OpenMPAssumeConstruct>{}),
22082218 construct<OpenMPConstruct>(Parser<OpenMPCriticalConstruct>{}))))
22092219
0 commit comments