@@ -3454,15 +3454,7 @@ WRAPPER_CLASS(PauseStmt, std::optional<StopCode>);
34543454// --- Common definitions
34553455
34563456struct OmpClause ;
3457- struct OmpClauseList ;
3458-
3459- struct OmpDirectiveSpecification {
3460- TUPLE_CLASS_BOILERPLATE (OmpDirectiveSpecification);
3461- std::tuple<llvm::omp::Directive,
3462- std::optional<common::Indirection<OmpClauseList>>>
3463- t;
3464- CharBlock source;
3465- };
3457+ struct OmpDirectiveSpecification ;
34663458
34673459// 2.1 Directives or clauses may accept a list or extended-list.
34683460// A list item is a variable, array section or common block name (enclosed
@@ -3475,15 +3467,76 @@ struct OmpObject {
34753467
34763468WRAPPER_CLASS (OmpObjectList, std::list<OmpObject>);
34773469
3478- #define MODIFIER_BOILERPLATE (...) \
3479- struct Modifier { \
3480- using Variant = std::variant<__VA_ARGS__>; \
3481- UNION_CLASS_BOILERPLATE (Modifier); \
3482- CharBlock source; \
3483- Variant u; \
3484- }
3470+ // Ref: [4.5:201-207], [5.0:293-299], [5.1:325-331], [5.2:124]
3471+ //
3472+ // reduction-identifier ->
3473+ // base-language-identifier | // since 4.5
3474+ // - | // since 4.5, until 5.2
3475+ // + | * | .AND. | .OR. | .EQV. | .NEQV. | // since 4.5
3476+ // MIN | MAX | IAND | IOR | IEOR // since 4.5
3477+ struct OmpReductionIdentifier {
3478+ UNION_CLASS_BOILERPLATE (OmpReductionIdentifier);
3479+ std::variant<DefinedOperator, ProcedureDesignator> u;
3480+ };
34853481
3486- #define MODIFIERS () std::optional<std::list<Modifier>>
3482+ // Ref: [4.5:222:6], [5.0:305:27], [5.1:337:19], [5.2:126:3-4], [6.0:240:27-28]
3483+ //
3484+ // combiner-expression -> // since 4.5
3485+ // assignment-statement |
3486+ // function-reference
3487+ struct OmpReductionCombiner {
3488+ UNION_CLASS_BOILERPLATE (OmpReductionCombiner);
3489+ std::variant<AssignmentStmt, FunctionReference> u;
3490+ };
3491+
3492+ inline namespace arguments {
3493+ struct OmpTypeSpecifier {
3494+ UNION_CLASS_BOILERPLATE (OmpTypeSpecifier);
3495+ std::variant<TypeSpec, DeclarationTypeSpec> u;
3496+ };
3497+
3498+ WRAPPER_CLASS (OmpTypeNameList, std::list<OmpTypeSpecifier>);
3499+
3500+ struct OmpLocator {
3501+ UNION_CLASS_BOILERPLATE (OmpLocator);
3502+ std::variant<OmpObject, FunctionReference> u;
3503+ };
3504+
3505+ WRAPPER_CLASS (OmpLocatorList, std::list<OmpLocator>);
3506+
3507+ // Ref: [5.0:326:10-16], [5.1:359:5-11], [5.2:163:2-7], [6.0:293:16-21]
3508+ //
3509+ // mapper-specifier ->
3510+ // [mapper-identifier :] type :: var | // since 5.0
3511+ // DEFAULT type :: var
3512+ struct OmpMapperSpecifier {
3513+ // Absent mapper-identifier is equivalent to DEFAULT.
3514+ TUPLE_CLASS_BOILERPLATE (OmpMapperSpecifier);
3515+ std::tuple<std::optional<Name>, TypeSpec, Name> t;
3516+ };
3517+
3518+ // Ref: [4.5:222:1-5], [5.0:305:20-27], [5.1:337:11-19], [5.2:139:18-23],
3519+ // [6.0:260:16-20]
3520+ //
3521+ // reduction-specifier ->
3522+ // reduction-identifier : typename-list
3523+ // : combiner-expression // since 4.5, until 5.2
3524+ // reduction-identifier : typename-list // since 6.0
3525+ struct OmpReductionSpecifier {
3526+ TUPLE_CLASS_BOILERPLATE (OmpReductionSpecifier);
3527+ std::tuple<OmpReductionIdentifier, OmpTypeNameList,
3528+ std::optional<OmpReductionCombiner>>
3529+ t;
3530+ };
3531+
3532+ struct OmpArgument {
3533+ CharBlock source;
3534+ UNION_CLASS_BOILERPLATE (OmpArgument);
3535+ std::variant<OmpLocator, // {variable, extended, locator}-list-item
3536+ OmpMapperSpecifier, OmpReductionSpecifier>
3537+ u;
3538+ };
3539+ } // namespace arguments
34873540
34883541inline namespace traits {
34893542// trait-property-name ->
@@ -3617,6 +3670,16 @@ struct OmpContextSelectorSpecification { // Modifier
36173670};
36183671} // namespace traits
36193672
3673+ #define MODIFIER_BOILERPLATE (...) \
3674+ struct Modifier { \
3675+ using Variant = std::variant<__VA_ARGS__>; \
3676+ UNION_CLASS_BOILERPLATE (Modifier); \
3677+ CharBlock source; \
3678+ Variant u; \
3679+ }
3680+
3681+ #define MODIFIERS () std::optional<std::list<Modifier>>
3682+
36203683inline namespace modifier {
36213684// For uniformity, in all keyword modifiers the name of the type defined
36223685// by ENUM_CLASS is "Value", e.g.
@@ -3829,18 +3892,6 @@ struct OmpPrescriptiveness {
38293892 WRAPPER_CLASS_BOILERPLATE (OmpPrescriptiveness, Value);
38303893};
38313894
3832- // Ref: [4.5:201-207], [5.0:293-299], [5.1:325-331], [5.2:124]
3833- //
3834- // reduction-identifier ->
3835- // base-language-identifier | // since 4.5
3836- // - | // since 4.5, until 5.2
3837- // + | * | .AND. | .OR. | .EQV. | .NEQV. | // since 4.5
3838- // MIN | MAX | IAND | IOR | IEOR // since 4.5
3839- struct OmpReductionIdentifier {
3840- UNION_CLASS_BOILERPLATE (OmpReductionIdentifier);
3841- std::variant<DefinedOperator, ProcedureDesignator> u;
3842- };
3843-
38443895// Ref: [5.0:300-302], [5.1:332-334], [5.2:134-137]
38453896//
38463897// reduction-modifier ->
@@ -3983,7 +4034,9 @@ struct OmpBindClause {
39834034struct OmpDefaultClause {
39844035 ENUM_CLASS (DataSharingAttribute, Private, Firstprivate, Shared, None)
39854036 UNION_CLASS_BOILERPLATE (OmpDefaultClause);
3986- std::variant<DataSharingAttribute, OmpDirectiveSpecification> u;
4037+ std::variant<DataSharingAttribute,
4038+ common::Indirection<OmpDirectiveSpecification>>
4039+ u;
39874040};
39884041
39894042// Ref: [4.5:103-107], [5.0:324-325], [5.1:357-358], [5.2:161-162]
@@ -4248,8 +4301,8 @@ struct OmpOrderClause {
42484301// otherwise-clause ->
42494302// OTHERWISE ([directive-specification])] // since 5.2
42504303struct OmpOtherwiseClause {
4251- WRAPPER_CLASS_BOILERPLATE (
4252- OmpOtherwiseClause, std::optional<OmpDirectiveSpecification>);
4304+ WRAPPER_CLASS_BOILERPLATE (OmpOtherwiseClause,
4305+ std::optional<common::Indirection< OmpDirectiveSpecification> >);
42534306};
42544307
42554308// Ref: [4.5:46-50], [5.0:74-78], [5.1:92-96], [5.2:229-230]
@@ -4345,7 +4398,9 @@ struct OmpUpdateClause {
43454398struct OmpWhenClause {
43464399 TUPLE_CLASS_BOILERPLATE (OmpWhenClause);
43474400 MODIFIER_BOILERPLATE (OmpContextSelector);
4348- std::tuple<MODIFIERS(), std::optional<OmpDirectiveSpecification>> t;
4401+ std::tuple<MODIFIERS(),
4402+ std::optional<common::Indirection<OmpDirectiveSpecification>>>
4403+ t;
43494404};
43504405
43514406// OpenMP Clauses
@@ -4372,6 +4427,14 @@ struct OmpClauseList {
43724427
43734428// --- Directives and constructs
43744429
4430+ struct OmpDirectiveSpecification {
4431+ CharBlock source;
4432+ TUPLE_CLASS_BOILERPLATE (OmpDirectiveSpecification);
4433+ std::tuple<llvm::omp::Directive, std::optional<std::list<OmpArgument>>,
4434+ std::optional<OmpClauseList>>
4435+ t;
4436+ };
4437+
43754438struct OmpMetadirectiveDirective {
43764439 TUPLE_CLASS_BOILERPLATE (OmpMetadirectiveDirective);
43774440 std::tuple<OmpClauseList> t;
@@ -4472,27 +4535,16 @@ struct OpenMPDeclareTargetConstruct {
44724535 std::tuple<Verbatim, OmpDeclareTargetSpecifier> t;
44734536};
44744537
4475- struct OmpDeclareMapperSpecifier {
4476- TUPLE_CLASS_BOILERPLATE (OmpDeclareMapperSpecifier);
4477- std::tuple<std::optional<Name>, TypeSpec, Name> t;
4478- };
4479-
44804538// OMP v5.2: 5.8.8
44814539// declare-mapper -> DECLARE MAPPER ([mapper-name :] type :: var) map-clauses
44824540struct OpenMPDeclareMapperConstruct {
44834541 TUPLE_CLASS_BOILERPLATE (OpenMPDeclareMapperConstruct);
44844542 CharBlock source;
4485- std::tuple<Verbatim, OmpDeclareMapperSpecifier , OmpClauseList> t;
4543+ std::tuple<Verbatim, OmpMapperSpecifier , OmpClauseList> t;
44864544};
44874545
44884546// 2.16 declare-reduction -> DECLARE REDUCTION (reduction-identifier : type-list
44894547// : combiner) [initializer-clause]
4490- struct OmpReductionCombiner {
4491- UNION_CLASS_BOILERPLATE (OmpReductionCombiner);
4492- WRAPPER_CLASS (FunctionCombiner, Call);
4493- std::variant<AssignmentStmt, FunctionCombiner> u;
4494- };
4495-
44964548WRAPPER_CLASS (OmpReductionInitializerClause, Expr);
44974549
44984550struct OpenMPDeclareReductionConstruct {
0 commit comments