@@ -3457,15 +3457,7 @@ WRAPPER_CLASS(PauseStmt, std::optional<StopCode>);
34573457// --- Common definitions
34583458
34593459struct OmpClause ;
3460- struct OmpClauseList ;
3461-
3462- struct OmpDirectiveSpecification {
3463- TUPLE_CLASS_BOILERPLATE (OmpDirectiveSpecification);
3464- std::tuple<llvm::omp::Directive,
3465- std::optional<common::Indirection<OmpClauseList>>>
3466- t;
3467- CharBlock source;
3468- };
3460+ struct OmpDirectiveSpecification ;
34693461
34703462// 2.1 Directives or clauses may accept a list or extended-list.
34713463// A list item is a variable, array section or common block name (enclosed
@@ -3478,15 +3470,76 @@ struct OmpObject {
34783470
34793471WRAPPER_CLASS (OmpObjectList, std::list<OmpObject>);
34803472
3481- #define MODIFIER_BOILERPLATE (...) \
3482- struct Modifier { \
3483- using Variant = std::variant<__VA_ARGS__>; \
3484- UNION_CLASS_BOILERPLATE (Modifier); \
3485- CharBlock source; \
3486- Variant u; \
3487- }
3473+ // Ref: [4.5:201-207], [5.0:293-299], [5.1:325-331], [5.2:124]
3474+ //
3475+ // reduction-identifier ->
3476+ // base-language-identifier | // since 4.5
3477+ // - | // since 4.5, until 5.2
3478+ // + | * | .AND. | .OR. | .EQV. | .NEQV. | // since 4.5
3479+ // MIN | MAX | IAND | IOR | IEOR // since 4.5
3480+ struct OmpReductionIdentifier {
3481+ UNION_CLASS_BOILERPLATE (OmpReductionIdentifier);
3482+ std::variant<DefinedOperator, ProcedureDesignator> u;
3483+ };
34883484
3489- #define MODIFIERS () std::optional<std::list<Modifier>>
3485+ // Ref: [4.5:222:6], [5.0:305:27], [5.1:337:19], [5.2:126:3-4], [6.0:240:27-28]
3486+ //
3487+ // combiner-expression -> // since 4.5
3488+ // assignment-statement |
3489+ // function-reference
3490+ struct OmpReductionCombiner {
3491+ UNION_CLASS_BOILERPLATE (OmpReductionCombiner);
3492+ std::variant<AssignmentStmt, FunctionReference> u;
3493+ };
3494+
3495+ inline namespace arguments {
3496+ struct OmpTypeSpecifier {
3497+ UNION_CLASS_BOILERPLATE (OmpTypeSpecifier);
3498+ std::variant<TypeSpec, DeclarationTypeSpec> u;
3499+ };
3500+
3501+ WRAPPER_CLASS (OmpTypeNameList, std::list<OmpTypeSpecifier>);
3502+
3503+ struct OmpLocator {
3504+ UNION_CLASS_BOILERPLATE (OmpLocator);
3505+ std::variant<OmpObject, FunctionReference> u;
3506+ };
3507+
3508+ WRAPPER_CLASS (OmpLocatorList, std::list<OmpLocator>);
3509+
3510+ // Ref: [5.0:326:10-16], [5.1:359:5-11], [5.2:163:2-7], [6.0:293:16-21]
3511+ //
3512+ // mapper-specifier ->
3513+ // [mapper-identifier :] type :: var | // since 5.0
3514+ // DEFAULT type :: var
3515+ struct OmpMapperSpecifier {
3516+ // Absent mapper-identifier is equivalent to DEFAULT.
3517+ TUPLE_CLASS_BOILERPLATE (OmpMapperSpecifier);
3518+ std::tuple<std::optional<Name>, TypeSpec, Name> t;
3519+ };
3520+
3521+ // Ref: [4.5:222:1-5], [5.0:305:20-27], [5.1:337:11-19], [5.2:139:18-23],
3522+ // [6.0:260:16-20]
3523+ //
3524+ // reduction-specifier ->
3525+ // reduction-identifier : typename-list
3526+ // : combiner-expression // since 4.5, until 5.2
3527+ // reduction-identifier : typename-list // since 6.0
3528+ struct OmpReductionSpecifier {
3529+ TUPLE_CLASS_BOILERPLATE (OmpReductionSpecifier);
3530+ std::tuple<OmpReductionIdentifier, OmpTypeNameList,
3531+ std::optional<OmpReductionCombiner>>
3532+ t;
3533+ };
3534+
3535+ struct OmpArgument {
3536+ CharBlock source;
3537+ UNION_CLASS_BOILERPLATE (OmpArgument);
3538+ std::variant<OmpLocator, // {variable, extended, locator}-list-item
3539+ OmpMapperSpecifier, OmpReductionSpecifier>
3540+ u;
3541+ };
3542+ } // namespace arguments
34903543
34913544inline namespace traits {
34923545// trait-property-name ->
@@ -3620,6 +3673,16 @@ struct OmpContextSelectorSpecification { // Modifier
36203673};
36213674} // namespace traits
36223675
3676+ #define MODIFIER_BOILERPLATE (...) \
3677+ struct Modifier { \
3678+ using Variant = std::variant<__VA_ARGS__>; \
3679+ UNION_CLASS_BOILERPLATE (Modifier); \
3680+ CharBlock source; \
3681+ Variant u; \
3682+ }
3683+
3684+ #define MODIFIERS () std::optional<std::list<Modifier>>
3685+
36233686inline namespace modifier {
36243687// For uniformity, in all keyword modifiers the name of the type defined
36253688// by ENUM_CLASS is "Value", e.g.
@@ -3832,18 +3895,6 @@ struct OmpPrescriptiveness {
38323895 WRAPPER_CLASS_BOILERPLATE (OmpPrescriptiveness, Value);
38333896};
38343897
3835- // Ref: [4.5:201-207], [5.0:293-299], [5.1:325-331], [5.2:124]
3836- //
3837- // reduction-identifier ->
3838- // base-language-identifier | // since 4.5
3839- // - | // since 4.5, until 5.2
3840- // + | * | .AND. | .OR. | .EQV. | .NEQV. | // since 4.5
3841- // MIN | MAX | IAND | IOR | IEOR // since 4.5
3842- struct OmpReductionIdentifier {
3843- UNION_CLASS_BOILERPLATE (OmpReductionIdentifier);
3844- std::variant<DefinedOperator, ProcedureDesignator> u;
3845- };
3846-
38473898// Ref: [5.0:300-302], [5.1:332-334], [5.2:134-137]
38483899//
38493900// reduction-modifier ->
@@ -3986,7 +4037,9 @@ struct OmpBindClause {
39864037struct OmpDefaultClause {
39874038 ENUM_CLASS (DataSharingAttribute, Private, Firstprivate, Shared, None)
39884039 UNION_CLASS_BOILERPLATE (OmpDefaultClause);
3989- std::variant<DataSharingAttribute, OmpDirectiveSpecification> u;
4040+ std::variant<DataSharingAttribute,
4041+ common::Indirection<OmpDirectiveSpecification>>
4042+ u;
39904043};
39914044
39924045// Ref: [4.5:103-107], [5.0:324-325], [5.1:357-358], [5.2:161-162]
@@ -4251,8 +4304,8 @@ struct OmpOrderClause {
42514304// otherwise-clause ->
42524305// OTHERWISE ([directive-specification])] // since 5.2
42534306struct OmpOtherwiseClause {
4254- WRAPPER_CLASS_BOILERPLATE (
4255- OmpOtherwiseClause, std::optional<OmpDirectiveSpecification>);
4307+ WRAPPER_CLASS_BOILERPLATE (OmpOtherwiseClause,
4308+ std::optional<common::Indirection< OmpDirectiveSpecification> >);
42564309};
42574310
42584311// Ref: [4.5:46-50], [5.0:74-78], [5.1:92-96], [5.2:229-230]
@@ -4348,7 +4401,9 @@ struct OmpUpdateClause {
43484401struct OmpWhenClause {
43494402 TUPLE_CLASS_BOILERPLATE (OmpWhenClause);
43504403 MODIFIER_BOILERPLATE (OmpContextSelector);
4351- std::tuple<MODIFIERS(), std::optional<OmpDirectiveSpecification>> t;
4404+ std::tuple<MODIFIERS(),
4405+ std::optional<common::Indirection<OmpDirectiveSpecification>>>
4406+ t;
43524407};
43534408
43544409// OpenMP Clauses
@@ -4375,6 +4430,14 @@ struct OmpClauseList {
43754430
43764431// --- Directives and constructs
43774432
4433+ struct OmpDirectiveSpecification {
4434+ CharBlock source;
4435+ TUPLE_CLASS_BOILERPLATE (OmpDirectiveSpecification);
4436+ std::tuple<llvm::omp::Directive, std::optional<std::list<OmpArgument>>,
4437+ std::optional<OmpClauseList>>
4438+ t;
4439+ };
4440+
43784441struct OmpMetadirectiveDirective {
43794442 TUPLE_CLASS_BOILERPLATE (OmpMetadirectiveDirective);
43804443 std::tuple<OmpClauseList> t;
@@ -4475,27 +4538,16 @@ struct OpenMPDeclareTargetConstruct {
44754538 std::tuple<Verbatim, OmpDeclareTargetSpecifier> t;
44764539};
44774540
4478- struct OmpDeclareMapperSpecifier {
4479- TUPLE_CLASS_BOILERPLATE (OmpDeclareMapperSpecifier);
4480- std::tuple<std::optional<Name>, TypeSpec, Name> t;
4481- };
4482-
44834541// OMP v5.2: 5.8.8
44844542// declare-mapper -> DECLARE MAPPER ([mapper-name :] type :: var) map-clauses
44854543struct OpenMPDeclareMapperConstruct {
44864544 TUPLE_CLASS_BOILERPLATE (OpenMPDeclareMapperConstruct);
44874545 CharBlock source;
4488- std::tuple<Verbatim, OmpDeclareMapperSpecifier , OmpClauseList> t;
4546+ std::tuple<Verbatim, OmpMapperSpecifier , OmpClauseList> t;
44894547};
44904548
44914549// 2.16 declare-reduction -> DECLARE REDUCTION (reduction-identifier : type-list
44924550// : combiner) [initializer-clause]
4493- struct OmpReductionCombiner {
4494- UNION_CLASS_BOILERPLATE (OmpReductionCombiner);
4495- WRAPPER_CLASS (FunctionCombiner, Call);
4496- std::variant<AssignmentStmt, FunctionCombiner> u;
4497- };
4498-
44994551WRAPPER_CLASS (OmpReductionInitializerClause, Expr);
45004552
45014553struct OpenMPDeclareReductionConstruct {
0 commit comments