FLANG
parse-tree.h
1//===-- include/flang/Parser/parse-tree.h -----------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef FORTRAN_PARSER_PARSE_TREE_H_
10#define FORTRAN_PARSER_PARSE_TREE_H_
11
12// Defines the classes used to represent successful reductions of productions
13// in the Fortran grammar. The names and content of these definitions
14// adhere closely to the syntax specifications in the language standard (q.v.)
15// that are transcribed here and referenced via their requirement numbers.
16// The representations of some productions that may also be of use in the
17// run-time I/O support library have been isolated into a distinct header file
18// (viz., format-specification.h).
19
20#include "char-block.h"
21#include "characters.h"
22#include "format-specification.h"
23#include "message.h"
24#include "provenance.h"
25#include "flang/Common/enum-set.h"
26#include "flang/Common/idioms.h"
27#include "flang/Common/indirection.h"
28#include "flang/Common/reference.h"
29#include "flang/Support/Fortran.h"
30#include "llvm/ADT/ArrayRef.h"
31#include "llvm/Frontend/OpenACC/ACC.h.inc"
32#include "llvm/Frontend/OpenMP/OMP.h"
33#include "llvm/Frontend/OpenMP/OMPConstants.h"
34#include <cinttypes>
35#include <list>
36#include <memory>
37#include <optional>
38#include <string>
39#include <tuple>
40#include <type_traits>
41#include <utility>
42#include <variant>
43
44// Parse tree node class types do not have default constructors. They
45// explicitly declare "T() {} = delete;" to make this clear. This restriction
46// prevents the introduction of what would be a viral requirement to include
47// std::monostate among most std::variant<> discriminated union members.
48
49// Parse tree node class types do not have copy constructors or copy assignment
50// operators. They are explicitly declared "= delete;" to make this clear,
51// although a C++ compiler wouldn't default them anyway due to the presence
52// of explicitly defaulted move constructors and move assignments.
53
54CLASS_TRAIT(EmptyTrait)
55CLASS_TRAIT(WrapperTrait)
56CLASS_TRAIT(UnionTrait)
57CLASS_TRAIT(TupleTrait)
58CLASS_TRAIT(ConstraintTrait)
59
60// Some parse tree nodes have fields in them to cache the results of a
61// successful semantic analysis later. Their types are forward declared
62// here.
63namespace Fortran::semantics {
64class Symbol;
65class DeclTypeSpec;
66class DerivedTypeSpec;
67} // namespace Fortran::semantics
68
69// Expressions in the parse tree have owning pointers that can be set to
70// type-checked generic expression representations by semantic analysis.
71namespace Fortran::evaluate {
72struct GenericExprWrapper; // forward definition, wraps Expr<SomeType>
73struct GenericAssignmentWrapper; // forward definition, represent assignment
74class ProcedureRef; // forward definition, represents a CALL or function ref
75} // namespace Fortran::evaluate
76
77// Most non-template classes in this file use these default definitions
78// for their move constructor and move assignment operator=, and disable
79// their copy constructor and copy assignment operator=.
80#define COPY_AND_ASSIGN_BOILERPLATE(classname) \
81 classname(classname &&) = default; \
82 classname &operator=(classname &&) = default; \
83 classname(const classname &) = delete; \
84 classname &operator=(const classname &) = delete
85
86// Almost all classes in this file have no default constructor.
87#define BOILERPLATE(classname) \
88 COPY_AND_ASSIGN_BOILERPLATE(classname); \
89 classname() = delete
90
91// Empty classes are often used below as alternatives in std::variant<>
92// discriminated unions.
93#define EMPTY_CLASS(classname) \
94 struct classname { \
95 classname() {} \
96 classname(const classname &) {} \
97 classname(classname &&) {} \
98 classname &operator=(const classname &) { return *this; }; \
99 classname &operator=(classname &&) { return *this; }; \
100 using EmptyTrait = std::true_type; \
101 }
102
103// Many classes below simply wrap a std::variant<> discriminated union,
104// which is conventionally named "u".
105#define UNION_CLASS_BOILERPLATE(classname) \
106 template <typename A, typename = common::NoLvalue<A>> \
107 classname(A &&x) : u(std::move(x)) {} \
108 using UnionTrait = std::true_type; \
109 BOILERPLATE(classname)
110
111// Many other classes below simply wrap a std::tuple<> structure, which
112// is conventionally named "t".
113#define TUPLE_CLASS_BOILERPLATE(classname) \
114 template <typename... Ts, typename = common::NoLvalue<Ts...>> \
115 classname(Ts &&...args) : t(std::move(args)...) {} \
116 using TupleTrait = std::true_type; \
117 BOILERPLATE(classname)
118
119// Many other classes below simply wrap a single data member, which is
120// conventionally named "v".
121#define WRAPPER_CLASS_BOILERPLATE(classname, type) \
122 BOILERPLATE(classname); \
123 classname(type &&x) : v(std::move(x)) {} \
124 using WrapperTrait = std::true_type; \
125 type v
126
127#define WRAPPER_CLASS(classname, type) \
128 struct classname { \
129 WRAPPER_CLASS_BOILERPLATE(classname, type); \
130 }
131
132namespace Fortran::parser {
133
134// These are the unavoidable recursively-defined productions of Fortran.
135// Some references to the representations of their parses require
136// indirection. The Indirect<> pointer wrapper class is used to
137// enforce ownership semantics and non-nullability.
138struct SpecificationPart; // R504
139struct ExecutableConstruct; // R514
140struct ActionStmt; // R515
141struct AcImpliedDo; // R774
142struct DataImpliedDo; // R840
143struct Designator; // R901
144struct Variable; // R902
145struct Expr; // R1001
146struct WhereConstruct; // R1042
147struct ForallConstruct; // R1050
148struct InputImpliedDo; // R1218
149struct OutputImpliedDo; // R1218
150struct FunctionReference; // R1520
151struct FunctionSubprogram; // R1529
152struct SubroutineSubprogram; // R1534
153
154// These additional forward references are declared so that the order of
155// class definitions in this header file can remain reasonably consistent
156// with order of the the requirement productions in the grammar.
157struct DerivedTypeDef; // R726
158struct EnumDef; // R759
159struct TypeDeclarationStmt; // R801
160struct AccessStmt; // R827
161struct AllocatableStmt; // R829
162struct AsynchronousStmt; // R831
163struct BindStmt; // R832
164struct CodimensionStmt; // R834
165struct ContiguousStmt; // R836
166struct DataStmt; // R837
167struct DataStmtValue; // R843
168struct DimensionStmt; // R848
169struct IntentStmt; // R849
170struct OptionalStmt; // R850
171struct ParameterStmt; // R851
172struct OldParameterStmt;
173struct PointerStmt; // R853
174struct ProtectedStmt; // R855
175struct SaveStmt; // R856
176struct TargetStmt; // R859
177struct ValueStmt; // R861
178struct VolatileStmt; // R862
179struct ImplicitStmt; // R863
180struct ImportStmt; // R867
181struct NamelistStmt; // R868
182struct EquivalenceStmt; // R870
183struct CommonStmt; // R873
184struct Substring; // R908
186struct SubstringInquiry;
187struct DataRef; // R911
188struct StructureComponent; // R913
189struct CoindexedNamedObject; // R914
190struct ArrayElement; // R917
191struct AllocateStmt; // R927
192struct NullifyStmt; // R939
193struct DeallocateStmt; // R941
194struct AssignmentStmt; // R1032
195struct PointerAssignmentStmt; // R1033
196struct WhereStmt; // R1041, R1045, R1046
197struct ForallStmt; // R1055
198struct AssociateConstruct; // R1102
199struct BlockConstruct; // R1107
200struct ChangeTeamConstruct; // R1111
201struct CriticalConstruct; // R1116
202struct DoConstruct; // R1119
203struct LabelDoStmt; // R1121
204struct ConcurrentHeader; // R1125
205struct EndDoStmt; // R1132
206struct CycleStmt; // R1133
207struct IfConstruct; // R1134
208struct IfStmt; // R1139
209struct CaseConstruct; // R1140
210struct SelectRankConstruct; // R1148
211struct SelectTypeConstruct; // R1152
212struct ExitStmt; // R1156
213struct GotoStmt; // R1157
214struct ComputedGotoStmt; // R1158
215struct StopStmt; // R1160, R1161
216struct NotifyWaitStmt; // F2023: R1166
217struct SyncAllStmt; // R1164
218struct SyncImagesStmt; // R1166
219struct SyncMemoryStmt; // R1168
220struct SyncTeamStmt; // R1169
221struct EventPostStmt; // R1170, R1171
222struct EventWaitSpec; // F2023: R1177
223struct EventWaitStmt; // R1172, R1173, R1174
224struct FormTeamStmt; // R1175, R1176, R1177
225struct LockStmt; // R1178
226struct UnlockStmt; // R1180
227struct OpenStmt; // R1204
228struct CloseStmt; // R1208
229struct ReadStmt; // R1210
230struct WriteStmt; // R1211
231struct PrintStmt; // R1212
232struct WaitStmt; // R1222
233struct BackspaceStmt; // R1224
234struct EndfileStmt; // R1225
235struct RewindStmt; // R1226
236struct FlushStmt; // R1228
237struct InquireStmt; // R1230
238struct FormatStmt; // R1301
239struct MainProgram; // R1401
240struct Module; // R1404
241struct UseStmt; // R1409
242struct Submodule; // R1416
243struct BlockData; // R1420
244struct InterfaceBlock; // R1501
245struct GenericSpec; // R1508
246struct GenericStmt; // R1510
247struct ExternalStmt; // R1511
248struct ProcedureDeclarationStmt; // R1512
249struct IntrinsicStmt; // R1519
250struct Call; // R1520 & R1521
251struct CallStmt; // R1521
252struct ProcedureDesignator; // R1522
253struct ActualArg; // R1524
254struct SeparateModuleSubprogram; // R1538
255struct EntryStmt; // R1541
256struct ReturnStmt; // R1542
257struct StmtFunctionStmt; // R1544
258
259// Directives, extensions, and deprecated statements
260struct CompilerDirective;
261struct BasedPointerStmt;
262struct CUDAAttributesStmt;
263struct StructureDef;
264struct ArithmeticIfStmt;
265struct AssignStmt;
266struct AssignedGotoStmt;
267struct PauseStmt;
268struct OpenACCConstruct;
272struct OpenMPConstruct;
277
278// Cooked character stream locations
279using Location = const char *;
280
281// A parse tree node with provenance only
282struct Verbatim {
283 // Allow a no-arg constructor for Verbatim so parsers can return `RESULT{}`.
284 constexpr Verbatim() {}
285 COPY_AND_ASSIGN_BOILERPLATE(Verbatim);
286 using EmptyTrait = std::true_type;
287 CharBlock source;
288};
289
290// Implicit definitions of the Standard
291
292// R403 scalar-xyz -> xyz
293// These template class wrappers correspond to the Standard's modifiers
294// scalar-xyz, constant-xzy, int-xzy, default-char-xyz, & logical-xyz.
295template <typename A> struct Scalar {
296 using ConstraintTrait = std::true_type;
297 Scalar(Scalar &&that) = default;
298 Scalar(A &&that) : thing(std::move(that)) {}
299 Scalar &operator=(Scalar &&) = default;
300 A thing;
301};
302
303template <typename A> struct Constant {
304 using ConstraintTrait = std::true_type;
305 Constant(Constant &&that) = default;
306 Constant(A &&that) : thing(std::move(that)) {}
307 Constant &operator=(Constant &&) = default;
308 A thing;
309};
310
311template <typename A> struct Integer {
312 using ConstraintTrait = std::true_type;
313 Integer(Integer &&that) = default;
314 Integer(A &&that) : thing(std::move(that)) {}
315 Integer &operator=(Integer &&) = default;
316 A thing;
317};
318
319template <typename A> struct Logical {
320 using ConstraintTrait = std::true_type;
321 Logical(Logical &&that) = default;
322 Logical(A &&that) : thing(std::move(that)) {}
323 Logical &operator=(Logical &&) = default;
324 A thing;
325};
326
327template <typename A> struct DefaultChar {
328 using ConstraintTrait = std::true_type;
329 DefaultChar(DefaultChar &&that) = default;
330 DefaultChar(A &&that) : thing(std::move(that)) {}
331 DefaultChar &operator=(DefaultChar &&) = default;
332 A thing;
333};
334
335using LogicalExpr = Logical<common::Indirection<Expr>>; // R1024
336using DefaultCharExpr = DefaultChar<common::Indirection<Expr>>; // R1025
337using IntExpr = Integer<common::Indirection<Expr>>; // R1026
338using ConstantExpr = Constant<common::Indirection<Expr>>; // R1029
339using IntConstantExpr = Integer<ConstantExpr>; // R1031
340using ScalarLogicalExpr = Scalar<LogicalExpr>;
341using ScalarIntExpr = Scalar<IntExpr>;
342using ScalarIntConstantExpr = Scalar<IntConstantExpr>;
343using ScalarLogicalConstantExpr = Scalar<Logical<ConstantExpr>>;
344using ScalarDefaultCharExpr = Scalar<DefaultCharExpr>;
345// R1030 default-char-constant-expr is used in the Standard only as part of
346// scalar-default-char-constant-expr.
347using ScalarDefaultCharConstantExpr = Scalar<DefaultChar<ConstantExpr>>;
348
349// R611 label -> digit [digit]...
350using Label = common::Label; // validated later, must be in [1..99999]
351
352// A wrapper for xzy-stmt productions that are statements, so that
353// source provenances and labels have a uniform representation.
354template <typename A> struct UnlabeledStatement {
355 explicit UnlabeledStatement(A &&s) : statement(std::move(s)) {}
356 CharBlock source;
357 A statement;
358};
359template <typename A> struct Statement : public UnlabeledStatement<A> {
360 Statement(std::optional<long> &&lab, A &&s)
361 : UnlabeledStatement<A>{std::move(s)}, label(std::move(lab)) {}
362 std::optional<Label> label;
363};
364
365// Error recovery marker
366EMPTY_CLASS(ErrorRecovery);
367
368// R513 other-specification-stmt ->
369// access-stmt | allocatable-stmt | asynchronous-stmt | bind-stmt |
370// codimension-stmt | contiguous-stmt | dimension-stmt | external-stmt |
371// intent-stmt | intrinsic-stmt | namelist-stmt | optional-stmt |
372// pointer-stmt | protected-stmt | save-stmt | target-stmt |
373// volatile-stmt | value-stmt | common-stmt | equivalence-stmt
374// Extension: (Cray) based POINTER statement
375// Extension: CUDA data attribute statement
393
394// R508 specification-construct ->
395// derived-type-def | enum-def | generic-stmt | interface-block |
396// parameter-stmt | procedure-declaration-stmt |
397// other-specification-stmt | type-declaration-stmt
416
417// R506 implicit-part-stmt ->
418// implicit-stmt | parameter-stmt | format-stmt | entry-stmt
430
431// R505 implicit-part -> [implicit-part-stmt]... implicit-stmt
432WRAPPER_CLASS(ImplicitPart, std::list<ImplicitPartStmt>);
433
434// R507 declaration-construct ->
435// specification-construct | data-stmt | format-stmt |
436// entry-stmt | stmt-function-stmt
438 UNION_CLASS_BOILERPLATE(DeclarationConstruct);
439 std::variant<SpecificationConstruct, Statement<common::Indirection<DataStmt>>,
443 u;
444};
445
446// R504 specification-part -> [use-stmt]... [import-stmt]... [implicit-part]
447// [declaration-construct]...
448// PARAMETER, FORMAT, and ENTRY statements that appear before any other
449// kind of declaration-construct will be parsed into the implicit-part,
450// even if there are no IMPLICIT statements.
452 TUPLE_CLASS_BOILERPLATE(SpecificationPart);
453 std::tuple<std::list<OpenACCDeclarativeConstruct>,
454 std::list<OpenMPDeclarativeConstruct>,
455 std::list<common::Indirection<CompilerDirective>>,
456 std::list<Statement<common::Indirection<UseStmt>>>,
457 std::list<Statement<common::Indirection<ImportStmt>>>, ImplicitPart,
458 std::list<DeclarationConstruct>>
459 t;
460};
461
462// R512 internal-subprogram -> function-subprogram | subroutine-subprogram
464 UNION_CLASS_BOILERPLATE(InternalSubprogram);
465 std::variant<common::Indirection<FunctionSubprogram>,
468 u;
469};
470
471// R1543 contains-stmt -> CONTAINS
472EMPTY_CLASS(ContainsStmt);
473
474// R511 internal-subprogram-part -> contains-stmt [internal-subprogram]...
476 TUPLE_CLASS_BOILERPLATE(InternalSubprogramPart);
477 std::tuple<Statement<ContainsStmt>, std::list<InternalSubprogram>> t;
478};
479
480// R1159 continue-stmt -> CONTINUE
481EMPTY_CLASS(ContinueStmt);
482
483// R1163 fail-image-stmt -> FAIL IMAGE
484EMPTY_CLASS(FailImageStmt);
485
486// R515 action-stmt ->
487// allocate-stmt | assignment-stmt | backspace-stmt | call-stmt |
488// close-stmt | continue-stmt | cycle-stmt | deallocate-stmt |
489// endfile-stmt | error-stop-stmt | event-post-stmt | event-wait-stmt |
490// exit-stmt | fail-image-stmt | flush-stmt | form-team-stmt |
491// goto-stmt | if-stmt | inquire-stmt | lock-stmt | notify-wait-stmt |
492// nullify-stmt | open-stmt | pointer-assignment-stmt | print-stmt |
493// read-stmt | return-stmt | rewind-stmt | stop-stmt | sync-all-stmt |
494// sync-images-stmt | sync-memory-stmt | sync-team-stmt | unlock-stmt |
495// wait-stmt | where-stmt | write-stmt | computed-goto-stmt | forall-stmt
497 UNION_CLASS_BOILERPLATE(ActionStmt);
498 std::variant<common::Indirection<AllocateStmt>,
501 ContinueStmt, common::Indirection<CycleStmt>,
504 common::Indirection<ExitStmt>, FailImageStmt,
520 u;
521};
522
523// R514 executable-construct ->
524// action-stmt | associate-construct | block-construct |
525// case-construct | change-team-construct | critical-construct |
526// do-construct | if-construct | select-rank-construct |
527// select-type-construct | where-construct | forall-construct |
528// (CUDA) CUF-kernel-do-construct
550
551// R510 execution-part-construct ->
552// executable-construct | format-stmt | entry-stmt | data-stmt
553// Extension (PGI/Intel): also accept NAMELIST in execution part
555 UNION_CLASS_BOILERPLATE(ExecutionPartConstruct);
556 std::variant<ExecutableConstruct, Statement<common::Indirection<FormatStmt>>,
560 u;
561};
562
563// R509 execution-part -> executable-construct [execution-part-construct]...
564// R1101 block -> [execution-part-construct]...
565using Block = std::list<ExecutionPartConstruct>;
566WRAPPER_CLASS(ExecutionPart, Block);
567
568// R502 program-unit ->
569// main-program | external-subprogram | module | submodule | block-data
570// R503 external-subprogram -> function-subprogram | subroutine-subprogram
581
582// R501 program -> program-unit [program-unit]...
583// This is the top-level production.
584WRAPPER_CLASS(Program, std::list<ProgramUnit>);
585
586// R603 name -> letter [alphanumeric-character]...
587struct Name {
588 std::string ToString() const { return source.ToString(); }
589 CharBlock source;
590 mutable semantics::Symbol *symbol{nullptr}; // filled in during semantics
591};
592
593// R516 keyword -> name
594WRAPPER_CLASS(Keyword, Name);
595
596// R606 named-constant -> name
597WRAPPER_CLASS(NamedConstant, Name);
598
599// R1003 defined-unary-op -> . letter [letter]... .
600// R1023 defined-binary-op -> . letter [letter]... .
601// R1414 local-defined-operator -> defined-unary-op | defined-binary-op
602// R1415 use-defined-operator -> defined-unary-op | defined-binary-op
603// The Name here is stored with the dots; e.g., .FOO.
604WRAPPER_CLASS(DefinedOpName, Name);
605
606// R608 intrinsic-operator ->
607// ** | * | / | + | - | // | .LT. | .LE. | .EQ. | .NE. | .GE. | .GT. |
608// .NOT. | .AND. | .OR. | .EQV. | .NEQV.
609// R609 defined-operator ->
610// defined-unary-op | defined-binary-op | extended-intrinsic-op
611// R610 extended-intrinsic-op -> intrinsic-operator
613 UNION_CLASS_BOILERPLATE(DefinedOperator);
614 ENUM_CLASS(IntrinsicOperator, Power, Multiply, Divide, Add, Subtract, Concat,
615 LT, LE, EQ, NE, GE, GT, NOT, AND, OR, EQV, NEQV)
616 std::variant<DefinedOpName, IntrinsicOperator> u;
617};
618
619// R804 object-name -> name
620using ObjectName = Name;
621
622// R867 import-stmt ->
623// IMPORT [[::] import-name-list] |
624// IMPORT , ONLY : import-name-list | IMPORT , NONE | IMPORT , ALL
625struct ImportStmt {
626 TUPLE_CLASS_BOILERPLATE(ImportStmt);
627 ImportStmt(common::ImportKind &&k) : t(k, std::list<Name>{}) {}
628 ImportStmt(std::list<Name> &&n)
629 : t(common::ImportKind::Default, std::move(n)) {}
630 ImportStmt(common::ImportKind &&, std::list<Name> &&);
631 std::tuple<common::ImportKind, std::list<Name>> t;
632};
633
634// R868 namelist-stmt ->
635// NAMELIST / namelist-group-name / namelist-group-object-list
636// [[,] / namelist-group-name / namelist-group-object-list]...
637// R869 namelist-group-object -> variable-name
639 struct Group {
640 TUPLE_CLASS_BOILERPLATE(Group);
641 std::tuple<Name, std::list<Name>> t;
642 };
643 WRAPPER_CLASS_BOILERPLATE(NamelistStmt, std::list<Group>);
644};
645
646// R701 type-param-value -> scalar-int-expr | * | :
647EMPTY_CLASS(Star);
648
650 UNION_CLASS_BOILERPLATE(TypeParamValue);
651 EMPTY_CLASS(Deferred); // :
652 std::variant<ScalarIntExpr, Star, Deferred> u;
653};
654
655// R706 kind-selector -> ( [KIND =] scalar-int-constant-expr )
656// Legacy extension: kind-selector -> * digit-string
657// N.B. These are not semantically identical in the case of COMPLEX.
659 UNION_CLASS_BOILERPLATE(KindSelector);
660 WRAPPER_CLASS(StarSize, std::uint64_t);
661 std::variant<ScalarIntConstantExpr, StarSize> u;
662};
663
664// R705 integer-type-spec -> INTEGER [kind-selector]
665WRAPPER_CLASS(IntegerTypeSpec, std::optional<KindSelector>);
666
667WRAPPER_CLASS(UnsignedTypeSpec, std::optional<KindSelector>);
668
669// R723 char-length -> ( type-param-value ) | digit-string
671 UNION_CLASS_BOILERPLATE(CharLength);
672 std::variant<TypeParamValue, std::uint64_t> u;
673};
674
675// R722 length-selector -> ( [LEN =] type-param-value ) | * char-length [,]
677 UNION_CLASS_BOILERPLATE(LengthSelector);
678 std::variant<TypeParamValue, CharLength> u;
679};
680
681// R721 char-selector ->
682// length-selector |
683// ( LEN = type-param-value , KIND = scalar-int-constant-expr ) |
684// ( type-param-value , [KIND =] scalar-int-constant-expr ) |
685// ( KIND = scalar-int-constant-expr [, LEN = type-param-value] )
686struct CharSelector {
687 UNION_CLASS_BOILERPLATE(CharSelector);
689 TUPLE_CLASS_BOILERPLATE(LengthAndKind);
690 std::tuple<std::optional<TypeParamValue>, ScalarIntConstantExpr> t;
691 };
692 CharSelector(TypeParamValue &&l, ScalarIntConstantExpr &&k)
693 : u{LengthAndKind{std::make_optional(std::move(l)), std::move(k)}} {}
694 CharSelector(ScalarIntConstantExpr &&k, std::optional<TypeParamValue> &&l)
695 : u{LengthAndKind{std::move(l), std::move(k)}} {}
696 std::variant<LengthSelector, LengthAndKind> u;
697};
698
699// R704 intrinsic-type-spec ->
700// integer-type-spec | REAL [kind-selector] | DOUBLE PRECISION |
701// COMPLEX [kind-selector] | CHARACTER [char-selector] |
702// LOGICAL [kind-selector]
703// Extensions: DOUBLE COMPLEX & UNSIGNED [kind-selector]
705 UNION_CLASS_BOILERPLATE(IntrinsicTypeSpec);
706 struct Real {
707 WRAPPER_CLASS_BOILERPLATE(Real, std::optional<KindSelector>);
708 };
709 EMPTY_CLASS(DoublePrecision);
710 struct Complex {
711 WRAPPER_CLASS_BOILERPLATE(Complex, std::optional<KindSelector>);
712 };
713 struct Character {
714 WRAPPER_CLASS_BOILERPLATE(Character, std::optional<CharSelector>);
715 };
716 struct Logical {
717 WRAPPER_CLASS_BOILERPLATE(Logical, std::optional<KindSelector>);
718 };
719 EMPTY_CLASS(DoubleComplex);
720 std::variant<IntegerTypeSpec, UnsignedTypeSpec, Real, DoublePrecision,
721 Complex, Character, Logical, DoubleComplex>
722 u;
723};
724
725// Extension: Vector type
727 UNION_CLASS_BOILERPLATE(VectorElementType);
728 std::variant<IntegerTypeSpec, IntrinsicTypeSpec::Real, UnsignedTypeSpec> u;
729};
730WRAPPER_CLASS(IntrinsicVectorTypeSpec, VectorElementType);
732 UNION_CLASS_BOILERPLATE(VectorTypeSpec);
733 EMPTY_CLASS(PairVectorTypeSpec);
734 EMPTY_CLASS(QuadVectorTypeSpec);
735 std::variant<IntrinsicVectorTypeSpec, PairVectorTypeSpec, QuadVectorTypeSpec>
736 u;
737};
738
739// R755 type-param-spec -> [keyword =] type-param-value
741 TUPLE_CLASS_BOILERPLATE(TypeParamSpec);
742 std::tuple<std::optional<Keyword>, TypeParamValue> t;
743};
744
745// R754 derived-type-spec -> type-name [(type-param-spec-list)]
747 TUPLE_CLASS_BOILERPLATE(DerivedTypeSpec);
748 mutable const semantics::DerivedTypeSpec *derivedTypeSpec{nullptr};
749 std::tuple<Name, std::list<TypeParamSpec>> t;
750};
751
752// R702 type-spec -> intrinsic-type-spec | derived-type-spec
753struct TypeSpec {
754 UNION_CLASS_BOILERPLATE(TypeSpec);
755 mutable const semantics::DeclTypeSpec *declTypeSpec{nullptr};
756 std::variant<IntrinsicTypeSpec, DerivedTypeSpec> u;
757};
758
759// R703 declaration-type-spec ->
760// intrinsic-type-spec | TYPE ( intrinsic-type-spec ) |
761// TYPE ( derived-type-spec ) | CLASS ( derived-type-spec ) |
762// CLASS ( * ) | TYPE ( * )
763// Legacy extension: RECORD /struct/
765 UNION_CLASS_BOILERPLATE(DeclarationTypeSpec);
766 WRAPPER_CLASS(Type, DerivedTypeSpec);
767 WRAPPER_CLASS(Class, DerivedTypeSpec);
768 EMPTY_CLASS(ClassStar);
769 EMPTY_CLASS(TypeStar);
770 WRAPPER_CLASS(Record, Name);
771 std::variant<IntrinsicTypeSpec, Type, Class, ClassStar, TypeStar, Record,
773 u;
774};
775
776// R709 kind-param -> digit-string | scalar-int-constant-name
777struct KindParam {
778 UNION_CLASS_BOILERPLATE(KindParam);
779 std::variant<std::uint64_t, Scalar<Integer<Constant<Name>>>> u;
780};
781
782// R707 signed-int-literal-constant -> [sign] int-literal-constant
784 TUPLE_CLASS_BOILERPLATE(SignedIntLiteralConstant);
785 CharBlock source;
786 std::tuple<CharBlock, std::optional<KindParam>> t;
787};
788
789// R708 int-literal-constant -> digit-string [_ kind-param]
791 TUPLE_CLASS_BOILERPLATE(IntLiteralConstant);
792 std::tuple<CharBlock, std::optional<KindParam>> t;
793};
794
795// extension: unsigned-literal-constant -> digit-string U [_ kind-param]
797 TUPLE_CLASS_BOILERPLATE(UnsignedLiteralConstant);
798 std::tuple<CharBlock, std::optional<KindParam>> t;
799};
800
801// R712 sign -> + | -
802enum class Sign { Positive, Negative };
803
804// R714 real-literal-constant ->
805// significand [exponent-letter exponent] [_ kind-param] |
806// digit-string exponent-letter exponent [_ kind-param]
807// R715 significand -> digit-string . [digit-string] | . digit-string
808// R717 exponent -> signed-digit-string
810 TUPLE_CLASS_BOILERPLATE(RealLiteralConstant);
811 struct Real {
812 using EmptyTrait = std::true_type;
813 COPY_AND_ASSIGN_BOILERPLATE(Real);
814 Real() {}
815 CharBlock source;
816 };
817 std::tuple<Real, std::optional<KindParam>> t;
818};
819
820// R713 signed-real-literal-constant -> [sign] real-literal-constant
822 TUPLE_CLASS_BOILERPLATE(SignedRealLiteralConstant);
823 std::tuple<std::optional<Sign>, RealLiteralConstant> t;
824};
825
826// R719 real-part ->
827// signed-int-literal-constant | signed-real-literal-constant |
828// named-constant
829// R720 imag-part ->
830// signed-int-literal-constant | signed-real-literal-constant |
831// named-constant
833 UNION_CLASS_BOILERPLATE(ComplexPart);
835 NamedConstant>
836 u;
837};
838
839// R718 complex-literal-constant -> ( real-part , imag-part )
841 TUPLE_CLASS_BOILERPLATE(ComplexLiteralConstant);
842 std::tuple<ComplexPart, ComplexPart> t; // real, imaginary
843};
844
845// Extension: signed COMPLEX constant
847 TUPLE_CLASS_BOILERPLATE(SignedComplexLiteralConstant);
848 std::tuple<Sign, ComplexLiteralConstant> t;
849};
850
851// R724 char-literal-constant ->
852// [kind-param _] ' [rep-char]... ' |
853// [kind-param _] " [rep-char]... "
855 TUPLE_CLASS_BOILERPLATE(CharLiteralConstant);
856 std::tuple<std::optional<KindParam>, std::string> t;
857 std::string GetString() const { return std::get<std::string>(t); }
858};
859
860// legacy extension
862 WRAPPER_CLASS_BOILERPLATE(HollerithLiteralConstant, std::string);
863 std::string GetString() const { return v; }
864};
865
866// R725 logical-literal-constant ->
867// .TRUE. [_ kind-param] | .FALSE. [_ kind-param]
869 TUPLE_CLASS_BOILERPLATE(LogicalLiteralConstant);
870 std::tuple<bool, std::optional<KindParam>> t;
871};
872
873// R764 boz-literal-constant -> binary-constant | octal-constant | hex-constant
874// R765 binary-constant -> B ' digit [digit]... ' | B " digit [digit]... "
875// R766 octal-constant -> O ' digit [digit]... ' | O " digit [digit]... "
876// R767 hex-constant ->
877// Z ' hex-digit [hex-digit]... ' | Z " hex-digit [hex-digit]... "
878// The constant must be large enough to hold any real or integer scalar
879// of any supported kind (F'2018 7.7).
880WRAPPER_CLASS(BOZLiteralConstant, std::string);
881
882// R605 literal-constant ->
883// int-literal-constant | real-literal-constant |
884// complex-literal-constant | logical-literal-constant |
885// char-literal-constant | boz-literal-constant
893
894// R807 access-spec -> PUBLIC | PRIVATE
896 ENUM_CLASS(Kind, Public, Private)
897 WRAPPER_CLASS_BOILERPLATE(AccessSpec, Kind);
898};
899
900// R728 type-attr-spec ->
901// ABSTRACT | access-spec | BIND(C) | EXTENDS ( parent-type-name )
902EMPTY_CLASS(Abstract);
904 UNION_CLASS_BOILERPLATE(TypeAttrSpec);
905 EMPTY_CLASS(BindC);
906 WRAPPER_CLASS(Extends, Name);
907 std::variant<Abstract, AccessSpec, BindC, Extends> u;
908};
909
910// R727 derived-type-stmt ->
911// TYPE [[, type-attr-spec-list] ::] type-name [( type-param-name-list )]
913 TUPLE_CLASS_BOILERPLATE(DerivedTypeStmt);
914 std::tuple<std::list<TypeAttrSpec>, Name, std::list<Name>> t;
915};
916
917// R731 sequence-stmt -> SEQUENCE
918EMPTY_CLASS(SequenceStmt);
919
920// R745 private-components-stmt -> PRIVATE
921// R747 binding-private-stmt -> PRIVATE
922EMPTY_CLASS(PrivateStmt);
923
924// R729 private-or-sequence -> private-components-stmt | sequence-stmt
926 UNION_CLASS_BOILERPLATE(PrivateOrSequence);
927 std::variant<PrivateStmt, SequenceStmt> u;
928};
929
930// R733 type-param-decl -> type-param-name [= scalar-int-constant-expr]
932 TUPLE_CLASS_BOILERPLATE(TypeParamDecl);
933 std::tuple<Name, std::optional<ScalarIntConstantExpr>> t;
934};
935
936// R732 type-param-def-stmt ->
937// integer-type-spec , type-param-attr-spec :: type-param-decl-list
938// R734 type-param-attr-spec -> KIND | LEN
940 TUPLE_CLASS_BOILERPLATE(TypeParamDefStmt);
941 std::tuple<IntegerTypeSpec, common::TypeParamAttr, std::list<TypeParamDecl>>
942 t;
943};
944
945// R1028 specification-expr -> scalar-int-expr
946WRAPPER_CLASS(SpecificationExpr, ScalarIntExpr);
947
948// R816 explicit-shape-spec -> [lower-bound :] upper-bound
949// R817 lower-bound -> specification-expr
950// R818 upper-bound -> specification-expr
952 TUPLE_CLASS_BOILERPLATE(ExplicitShapeSpec);
953 std::tuple<std::optional<SpecificationExpr>, SpecificationExpr> t;
954};
955
956// R810 deferred-coshape-spec -> :
957// deferred-coshape-spec-list is just a count of the colons (i.e., the rank).
958WRAPPER_CLASS(DeferredCoshapeSpecList, int);
959
960// R811 explicit-coshape-spec ->
961// [[lower-cobound :] upper-cobound ,]... [lower-cobound :] *
962// R812 lower-cobound -> specification-expr
963// R813 upper-cobound -> specification-expr
965 TUPLE_CLASS_BOILERPLATE(ExplicitCoshapeSpec);
966 std::tuple<std::list<ExplicitShapeSpec>, std::optional<SpecificationExpr>> t;
967};
968
969// R809 coarray-spec -> deferred-coshape-spec-list | explicit-coshape-spec
971 UNION_CLASS_BOILERPLATE(CoarraySpec);
972 std::variant<DeferredCoshapeSpecList, ExplicitCoshapeSpec> u;
973};
974
975// R820 deferred-shape-spec -> :
976// deferred-shape-spec-list is just a count of the colons (i.e., the rank).
977WRAPPER_CLASS(DeferredShapeSpecList, int);
978
979// R740 component-array-spec ->
980// explicit-shape-spec-list | deferred-shape-spec-list
982 UNION_CLASS_BOILERPLATE(ComponentArraySpec);
983 std::variant<std::list<ExplicitShapeSpec>, DeferredShapeSpecList> u;
984};
985
986// R738 component-attr-spec ->
987// access-spec | ALLOCATABLE |
988// CODIMENSION lbracket coarray-spec rbracket |
989// CONTIGUOUS | DIMENSION ( component-array-spec ) | POINTER |
990// (CUDA) CONSTANT | DEVICE | MANAGED | PINNED | SHARED | TEXTURE | UNIFIED
991EMPTY_CLASS(Allocatable);
992EMPTY_CLASS(Pointer);
993EMPTY_CLASS(Contiguous);
995 UNION_CLASS_BOILERPLATE(ComponentAttrSpec);
996 std::variant<AccessSpec, Allocatable, CoarraySpec, Contiguous,
997 ComponentArraySpec, Pointer, common::CUDADataAttr, ErrorRecovery>
998 u;
999};
1000
1001// R806 null-init -> function-reference ... which must be NULL()
1002WRAPPER_CLASS(NullInit, common::Indirection<Expr>);
1003
1004// R744 initial-data-target -> designator
1005using InitialDataTarget = common::Indirection<Designator>;
1006
1007// R743 component-initialization ->
1008// = constant-expr | => null-init | => initial-data-target
1009// R805 initialization ->
1010// = constant-expr | => null-init | => initial-data-target
1011// Universal extension: initialization -> / data-stmt-value-list /
1013 UNION_CLASS_BOILERPLATE(Initialization);
1014 std::variant<ConstantExpr, NullInit, InitialDataTarget,
1015 std::list<common::Indirection<DataStmtValue>>>
1016 u;
1017};
1018
1019// R739 component-decl ->
1020// component-name [( component-array-spec )]
1021// [lbracket coarray-spec rbracket] [* char-length]
1022// [component-initialization] |
1023// component-name *char-length [( component-array-spec )]
1024// [lbracket coarray-spec rbracket] [component-initialization]
1025struct ComponentDecl {
1026 TUPLE_CLASS_BOILERPLATE(ComponentDecl);
1027 ComponentDecl(Name &&name, CharLength &&length,
1028 std::optional<ComponentArraySpec> &&aSpec,
1029 std::optional<CoarraySpec> &&coaSpec,
1030 std::optional<Initialization> &&init)
1031 : t{std::move(name), std::move(aSpec), std::move(coaSpec),
1032 std::move(length), std::move(init)} {}
1033 std::tuple<Name, std::optional<ComponentArraySpec>,
1034 std::optional<CoarraySpec>, std::optional<CharLength>,
1035 std::optional<Initialization>>
1036 t;
1037};
1038
1039// A %FILL component for a DEC STRUCTURE. The name will be replaced
1040// with a distinct compiler-generated name.
1041struct FillDecl {
1042 TUPLE_CLASS_BOILERPLATE(FillDecl);
1043 std::tuple<Name, std::optional<ComponentArraySpec>, std::optional<CharLength>>
1044 t;
1045};
1046
1048 UNION_CLASS_BOILERPLATE(ComponentOrFill);
1049 std::variant<ComponentDecl, FillDecl> u;
1050};
1051
1052// R737 data-component-def-stmt ->
1053// declaration-type-spec [[, component-attr-spec-list] ::]
1054// component-decl-list
1056 TUPLE_CLASS_BOILERPLATE(DataComponentDefStmt);
1057 std::tuple<DeclarationTypeSpec, std::list<ComponentAttrSpec>,
1058 std::list<ComponentOrFill>>
1059 t;
1060};
1061
1062// R742 proc-component-attr-spec ->
1063// access-spec | NOPASS | PASS [(arg-name)] | POINTER
1064EMPTY_CLASS(NoPass);
1065WRAPPER_CLASS(Pass, std::optional<Name>);
1067 UNION_CLASS_BOILERPLATE(ProcComponentAttrSpec);
1068 std::variant<AccessSpec, NoPass, Pass, Pointer> u;
1069};
1070
1071// R1517 proc-pointer-init -> null-init | initial-proc-target
1072// R1518 initial-proc-target -> procedure-name
1074 UNION_CLASS_BOILERPLATE(ProcPointerInit);
1075 std::variant<NullInit, Name> u;
1076};
1077
1078// R1513 proc-interface -> interface-name | declaration-type-spec
1079// R1516 interface-name -> name
1081 UNION_CLASS_BOILERPLATE(ProcInterface);
1082 std::variant<Name, DeclarationTypeSpec> u;
1083};
1084
1085// R1515 proc-decl -> procedure-entity-name [=> proc-pointer-init]
1086struct ProcDecl {
1087 TUPLE_CLASS_BOILERPLATE(ProcDecl);
1088 std::tuple<Name, std::optional<ProcPointerInit>> t;
1089};
1090
1091// R741 proc-component-def-stmt ->
1092// PROCEDURE ( [proc-interface] ) , proc-component-attr-spec-list
1093// :: proc-decl-list
1095 TUPLE_CLASS_BOILERPLATE(ProcComponentDefStmt);
1096 std::tuple<std::optional<ProcInterface>, std::list<ProcComponentAttrSpec>,
1097 std::list<ProcDecl>>
1098 t;
1099};
1100
1101// R736 component-def-stmt -> data-component-def-stmt | proc-component-def-stmt
1103 UNION_CLASS_BOILERPLATE(ComponentDefStmt);
1106 // , TypeParamDefStmt -- PGI accidental extension, not enabled
1107 >
1108 u;
1109};
1110
1111// R752 bind-attr ->
1112// access-spec | DEFERRED | NON_OVERRIDABLE | NOPASS | PASS [(arg-name)]
1113struct BindAttr {
1114 UNION_CLASS_BOILERPLATE(BindAttr);
1115 EMPTY_CLASS(Deferred);
1116 EMPTY_CLASS(Non_Overridable);
1117 std::variant<AccessSpec, Deferred, Non_Overridable, NoPass, Pass> u;
1118};
1119
1120// R750 type-bound-proc-decl -> binding-name [=> procedure-name]
1122 TUPLE_CLASS_BOILERPLATE(TypeBoundProcDecl);
1123 std::tuple<Name, std::optional<Name>> t;
1124};
1125
1126// R749 type-bound-procedure-stmt ->
1127// PROCEDURE [[, bind-attr-list] ::] type-bound-proc-decl-list |
1128// PROCEDURE ( interface-name ) , bind-attr-list :: binding-name-list
1129// The second form, with interface-name, requires DEFERRED in bind-attr-list,
1130// and thus can appear only in an abstract type.
1132 UNION_CLASS_BOILERPLATE(TypeBoundProcedureStmt);
1134 TUPLE_CLASS_BOILERPLATE(WithoutInterface);
1135 std::tuple<std::list<BindAttr>, std::list<TypeBoundProcDecl>> t;
1136 };
1138 TUPLE_CLASS_BOILERPLATE(WithInterface);
1139 std::tuple<Name, std::list<BindAttr>, std::list<Name>> t;
1140 };
1141 std::variant<WithoutInterface, WithInterface> u;
1142};
1143
1144// R751 type-bound-generic-stmt ->
1145// GENERIC [, access-spec] :: generic-spec => binding-name-list
1147 TUPLE_CLASS_BOILERPLATE(TypeBoundGenericStmt);
1148 std::tuple<std::optional<AccessSpec>, common::Indirection<GenericSpec>,
1149 std::list<Name>>
1150 t;
1151};
1152
1153// R753 final-procedure-stmt -> FINAL [::] final-subroutine-name-list
1154WRAPPER_CLASS(FinalProcedureStmt, std::list<Name>);
1155
1156// R748 type-bound-proc-binding ->
1157// type-bound-procedure-stmt | type-bound-generic-stmt |
1158// final-procedure-stmt
1160 UNION_CLASS_BOILERPLATE(TypeBoundProcBinding);
1161 std::variant<TypeBoundProcedureStmt, TypeBoundGenericStmt, FinalProcedureStmt,
1162 ErrorRecovery>
1163 u;
1164};
1165
1166// R746 type-bound-procedure-part ->
1167// contains-stmt [binding-private-stmt] [type-bound-proc-binding]...
1169 TUPLE_CLASS_BOILERPLATE(TypeBoundProcedurePart);
1170 std::tuple<Statement<ContainsStmt>, std::optional<Statement<PrivateStmt>>,
1171 std::list<Statement<TypeBoundProcBinding>>>
1172 t;
1173};
1174
1175// R730 end-type-stmt -> END TYPE [type-name]
1176WRAPPER_CLASS(EndTypeStmt, std::optional<Name>);
1177
1178// R726 derived-type-def ->
1179// derived-type-stmt [type-param-def-stmt]... [private-or-sequence]...
1180// [component-part] [type-bound-procedure-part] end-type-stmt
1181// R735 component-part -> [component-def-stmt]...
1183 TUPLE_CLASS_BOILERPLATE(DerivedTypeDef);
1184 std::tuple<Statement<DerivedTypeStmt>, std::list<Statement<TypeParamDefStmt>>,
1185 std::list<Statement<PrivateOrSequence>>,
1186 std::list<Statement<ComponentDefStmt>>,
1187 std::optional<TypeBoundProcedurePart>, Statement<EndTypeStmt>>
1188 t;
1189};
1190
1191// R758 component-data-source -> expr | data-target | proc-target
1192// R1037 data-target -> expr
1193// R1040 proc-target -> expr | procedure-name | proc-component-ref
1194WRAPPER_CLASS(ComponentDataSource, common::Indirection<Expr>);
1195
1196// R757 component-spec -> [keyword =] component-data-source
1198 TUPLE_CLASS_BOILERPLATE(ComponentSpec);
1199 std::tuple<std::optional<Keyword>, ComponentDataSource> t;
1200};
1201
1202// R756 structure-constructor -> derived-type-spec ( [component-spec-list] )
1204 TUPLE_CLASS_BOILERPLATE(StructureConstructor);
1205 std::tuple<DerivedTypeSpec, std::list<ComponentSpec>> t;
1206};
1207
1208// R760 enum-def-stmt -> ENUM, BIND(C)
1209EMPTY_CLASS(EnumDefStmt);
1210
1211// R762 enumerator -> named-constant [= scalar-int-constant-expr]
1213 TUPLE_CLASS_BOILERPLATE(Enumerator);
1214 std::tuple<NamedConstant, std::optional<ScalarIntConstantExpr>> t;
1215};
1216
1217// R761 enumerator-def-stmt -> ENUMERATOR [::] enumerator-list
1218WRAPPER_CLASS(EnumeratorDefStmt, std::list<Enumerator>);
1219
1220// R763 end-enum-stmt -> END ENUM
1221EMPTY_CLASS(EndEnumStmt);
1222
1223// R759 enum-def ->
1224// enum-def-stmt enumerator-def-stmt [enumerator-def-stmt]...
1225// end-enum-stmt
1226struct EnumDef {
1227 TUPLE_CLASS_BOILERPLATE(EnumDef);
1228 std::tuple<Statement<EnumDefStmt>, std::list<Statement<EnumeratorDefStmt>>,
1230 t;
1231};
1232
1233// R773 ac-value -> expr | ac-implied-do
1234struct AcValue {
1235 struct Triplet { // PGI/Intel extension
1236 TUPLE_CLASS_BOILERPLATE(Triplet);
1237 std::tuple<ScalarIntExpr, ScalarIntExpr, std::optional<ScalarIntExpr>> t;
1238 };
1239 UNION_CLASS_BOILERPLATE(AcValue);
1240 std::variant<Triplet, common::Indirection<Expr>,
1242 u;
1243};
1244
1245// R770 ac-spec -> type-spec :: | [type-spec ::] ac-value-list
1246struct AcSpec {
1247 TUPLE_CLASS_BOILERPLATE(AcSpec);
1248 explicit AcSpec(TypeSpec &&ts) : t(std::move(ts), std::list<AcValue>()) {}
1249 std::tuple<std::optional<TypeSpec>, std::list<AcValue>> t;
1250};
1251
1252// R769 array-constructor -> (/ ac-spec /) | lbracket ac-spec rbracket
1253WRAPPER_CLASS(ArrayConstructor, AcSpec);
1254
1255// R1124 do-variable -> scalar-int-variable-name
1256using DoVariable = Scalar<Integer<Name>>;
1257
1258template <typename VAR, typename BOUND> struct LoopBounds {
1259 TUPLE_CLASS_BOILERPLATE(LoopBounds);
1260 std::tuple<VAR, BOUND, BOUND, std::optional<BOUND>> t;
1261
1262 const VAR &Name() const { return std::get<0>(t); }
1263 const BOUND &Lower() const { return std::get<1>(t); }
1264 const BOUND &Upper() const { return std::get<2>(t); }
1265 const std::optional<BOUND> &Step() const { return std::get<3>(t); }
1266};
1267
1268using ScalarName = Scalar<Name>;
1269using ScalarExpr = Scalar<common::Indirection<Expr>>;
1270
1271// R775 ac-implied-do-control ->
1272// [integer-type-spec ::] ac-do-variable = scalar-int-expr ,
1273// scalar-int-expr [, scalar-int-expr]
1274// R776 ac-do-variable -> do-variable
1276 TUPLE_CLASS_BOILERPLATE(AcImpliedDoControl);
1278 std::tuple<std::optional<IntegerTypeSpec>, Bounds> t;
1279};
1280
1281// R774 ac-implied-do -> ( ac-value-list , ac-implied-do-control )
1283 TUPLE_CLASS_BOILERPLATE(AcImpliedDo);
1284 std::tuple<std::list<AcValue>, AcImpliedDoControl> t;
1285};
1286
1287// R808 language-binding-spec ->
1288// BIND ( C [, NAME = scalar-default-char-constant-expr ]
1289// [, CDEFINED ] )
1290// R1528 proc-language-binding-spec -> language-binding-spec
1292 TUPLE_CLASS_BOILERPLATE(LanguageBindingSpec);
1293 std::tuple<std::optional<ScalarDefaultCharConstantExpr>, bool> t;
1294};
1295
1296// R852 named-constant-def -> named-constant = constant-expr
1298 TUPLE_CLASS_BOILERPLATE(NamedConstantDef);
1299 std::tuple<NamedConstant, ConstantExpr> t;
1300};
1301
1302// R851 parameter-stmt -> PARAMETER ( named-constant-def-list )
1303WRAPPER_CLASS(ParameterStmt, std::list<NamedConstantDef>);
1304
1305// R819 assumed-shape-spec -> [lower-bound] :
1306WRAPPER_CLASS(AssumedShapeSpec, std::optional<SpecificationExpr>);
1307
1308// R821 assumed-implied-spec -> [lower-bound :] *
1309WRAPPER_CLASS(AssumedImpliedSpec, std::optional<SpecificationExpr>);
1310
1311// R822 assumed-size-spec -> explicit-shape-spec-list , assumed-implied-spec
1313 TUPLE_CLASS_BOILERPLATE(AssumedSizeSpec);
1314 std::tuple<std::list<ExplicitShapeSpec>, AssumedImpliedSpec> t;
1315};
1316
1317// R823 implied-shape-or-assumed-size-spec -> assumed-implied-spec
1318// R824 implied-shape-spec -> assumed-implied-spec , assumed-implied-spec-list
1319// I.e., when the assumed-implied-spec-list has a single item, it constitutes an
1320// implied-shape-or-assumed-size-spec; otherwise, an implied-shape-spec.
1321WRAPPER_CLASS(ImpliedShapeSpec, std::list<AssumedImpliedSpec>);
1322
1323// R825 assumed-rank-spec -> ..
1324EMPTY_CLASS(AssumedRankSpec);
1325
1326// R815 array-spec ->
1327// explicit-shape-spec-list | assumed-shape-spec-list |
1328// deferred-shape-spec-list | assumed-size-spec | implied-shape-spec |
1329// implied-shape-or-assumed-size-spec | assumed-rank-spec
1331 UNION_CLASS_BOILERPLATE(ArraySpec);
1332 std::variant<std::list<ExplicitShapeSpec>, std::list<AssumedShapeSpec>,
1333 DeferredShapeSpecList, AssumedSizeSpec, ImpliedShapeSpec, AssumedRankSpec>
1334 u;
1335};
1336
1337// R826 intent-spec -> IN | OUT | INOUT
1339 ENUM_CLASS(Intent, In, Out, InOut)
1340 WRAPPER_CLASS_BOILERPLATE(IntentSpec, Intent);
1341};
1342
1343// R802 attr-spec ->
1344// access-spec | ALLOCATABLE | ASYNCHRONOUS |
1345// CODIMENSION lbracket coarray-spec rbracket | CONTIGUOUS |
1346// DIMENSION ( array-spec ) | EXTERNAL | INTENT ( intent-spec ) |
1347// INTRINSIC | language-binding-spec | OPTIONAL | PARAMETER | POINTER |
1348// PROTECTED | SAVE | TARGET | VALUE | VOLATILE |
1349// (CUDA) CONSTANT | DEVICE | MANAGED | PINNED | SHARED | TEXTURE
1350EMPTY_CLASS(Asynchronous);
1351EMPTY_CLASS(External);
1352EMPTY_CLASS(Intrinsic);
1353EMPTY_CLASS(Optional);
1354EMPTY_CLASS(Parameter);
1355EMPTY_CLASS(Protected);
1356EMPTY_CLASS(Save);
1357EMPTY_CLASS(Target);
1358EMPTY_CLASS(Value);
1359EMPTY_CLASS(Volatile);
1360struct AttrSpec {
1361 UNION_CLASS_BOILERPLATE(AttrSpec);
1362 std::variant<AccessSpec, Allocatable, Asynchronous, CoarraySpec, Contiguous,
1363 ArraySpec, External, IntentSpec, Intrinsic, LanguageBindingSpec, Optional,
1364 Parameter, Pointer, Protected, Save, Target, Value, Volatile,
1365 common::CUDADataAttr>
1366 u;
1367};
1368
1369// R803 entity-decl ->
1370// object-name [( array-spec )] [lbracket coarray-spec rbracket]
1371// [* char-length] [initialization] |
1372// function-name [* char-length] |
1373// (ext.) object-name *char-length [( array-spec )]
1374// [lbracket coarray-spec rbracket] [initialization]
1375struct EntityDecl {
1376 TUPLE_CLASS_BOILERPLATE(EntityDecl);
1377 EntityDecl(ObjectName &&name, CharLength &&length,
1378 std::optional<ArraySpec> &&aSpec, std::optional<CoarraySpec> &&coaSpec,
1379 std::optional<Initialization> &&init)
1380 : t{std::move(name), std::move(aSpec), std::move(coaSpec),
1381 std::move(length), std::move(init)} {}
1382 std::tuple<ObjectName, std::optional<ArraySpec>, std::optional<CoarraySpec>,
1383 std::optional<CharLength>, std::optional<Initialization>>
1384 t;
1385};
1386
1387// R801 type-declaration-stmt ->
1388// declaration-type-spec [[, attr-spec]... ::] entity-decl-list
1390 TUPLE_CLASS_BOILERPLATE(TypeDeclarationStmt);
1391 std::tuple<DeclarationTypeSpec, std::list<AttrSpec>, std::list<EntityDecl>> t;
1392};
1393
1394// R828 access-id -> access-name | generic-spec
1395// "access-name" is ambiguous with "generic-spec", so that's what's parsed
1396WRAPPER_CLASS(AccessId, common::Indirection<GenericSpec>);
1397
1398// R827 access-stmt -> access-spec [[::] access-id-list]
1400 TUPLE_CLASS_BOILERPLATE(AccessStmt);
1401 std::tuple<AccessSpec, std::list<AccessId>> t;
1402};
1403
1404// R830 allocatable-decl ->
1405// object-name [( array-spec )] [lbracket coarray-spec rbracket]
1406// R860 target-decl ->
1407// object-name [( array-spec )] [lbracket coarray-spec rbracket]
1409 TUPLE_CLASS_BOILERPLATE(ObjectDecl);
1410 std::tuple<ObjectName, std::optional<ArraySpec>, std::optional<CoarraySpec>>
1411 t;
1412};
1413
1414// R829 allocatable-stmt -> ALLOCATABLE [::] allocatable-decl-list
1415WRAPPER_CLASS(AllocatableStmt, std::list<ObjectDecl>);
1416
1417// R831 asynchronous-stmt -> ASYNCHRONOUS [::] object-name-list
1418WRAPPER_CLASS(AsynchronousStmt, std::list<ObjectName>);
1419
1420// R833 bind-entity -> entity-name | / common-block-name /
1422 TUPLE_CLASS_BOILERPLATE(BindEntity);
1423 ENUM_CLASS(Kind, Object, Common)
1424 std::tuple<Kind, Name> t;
1425};
1426
1427// R832 bind-stmt -> language-binding-spec [::] bind-entity-list
1428struct BindStmt {
1429 TUPLE_CLASS_BOILERPLATE(BindStmt);
1430 std::tuple<LanguageBindingSpec, std::list<BindEntity>> t;
1431};
1432
1433// R835 codimension-decl -> coarray-name lbracket coarray-spec rbracket
1435 TUPLE_CLASS_BOILERPLATE(CodimensionDecl);
1436 std::tuple<Name, CoarraySpec> t;
1437};
1438
1439// R834 codimension-stmt -> CODIMENSION [::] codimension-decl-list
1440WRAPPER_CLASS(CodimensionStmt, std::list<CodimensionDecl>);
1441
1442// R836 contiguous-stmt -> CONTIGUOUS [::] object-name-list
1443WRAPPER_CLASS(ContiguousStmt, std::list<ObjectName>);
1444
1445// R847 constant-subobject -> designator
1446// R846 int-constant-subobject -> constant-subobject
1447using ConstantSubobject = Constant<common::Indirection<Designator>>;
1448
1449// Represent an analyzed expression
1452using TypedAssignment =
1454
1455// R845 data-stmt-constant ->
1456// scalar-constant | scalar-constant-subobject |
1457// signed-int-literal-constant | signed-real-literal-constant |
1458// null-init | initial-data-target |
1459// structure-constructor
1460// N.B. Parsing ambiguities abound here without recourse to symbols
1461// (see comments on R845's parser).
1463 UNION_CLASS_BOILERPLATE(DataStmtConstant);
1464 CharBlock source;
1465 mutable TypedExpr typedExpr;
1466 std::variant<common::Indirection<CharLiteralConstantSubstring>,
1470 u;
1471};
1472
1473// R844 data-stmt-repeat -> scalar-int-constant | scalar-int-constant-subobject
1474// R607 int-constant -> constant
1475// R604 constant -> literal-constant | named-constant
1476// (only literal-constant -> int-literal-constant applies)
1478 UNION_CLASS_BOILERPLATE(DataStmtRepeat);
1479 std::variant<IntLiteralConstant, Scalar<Integer<ConstantSubobject>>> u;
1480};
1481
1482// R843 data-stmt-value -> [data-stmt-repeat *] data-stmt-constant
1484 TUPLE_CLASS_BOILERPLATE(DataStmtValue);
1485 mutable std::int64_t repetitions{1}; // replaced during semantics
1486 std::tuple<std::optional<DataStmtRepeat>, DataStmtConstant> t;
1487};
1488
1489// R841 data-i-do-object ->
1490// array-element | scalar-structure-component | data-implied-do
1492 UNION_CLASS_BOILERPLATE(DataIDoObject);
1493 std::variant<Scalar<common::Indirection<Designator>>,
1495 u;
1496};
1497
1498// R840 data-implied-do ->
1499// ( data-i-do-object-list , [integer-type-spec ::] data-i-do-variable
1500// = scalar-int-constant-expr , scalar-int-constant-expr
1501// [, scalar-int-constant-expr] )
1502// R842 data-i-do-variable -> do-variable
1504 TUPLE_CLASS_BOILERPLATE(DataImpliedDo);
1506 std::tuple<std::list<DataIDoObject>, std::optional<IntegerTypeSpec>, Bounds>
1507 t;
1508};
1509
1510// R839 data-stmt-object -> variable | data-implied-do
1512 UNION_CLASS_BOILERPLATE(DataStmtObject);
1513 std::variant<common::Indirection<Variable>, DataImpliedDo> u;
1514};
1515
1516// R838 data-stmt-set -> data-stmt-object-list / data-stmt-value-list /
1518 TUPLE_CLASS_BOILERPLATE(DataStmtSet);
1519 std::tuple<std::list<DataStmtObject>, std::list<DataStmtValue>> t;
1520};
1521
1522// R837 data-stmt -> DATA data-stmt-set [[,] data-stmt-set]...
1523WRAPPER_CLASS(DataStmt, std::list<DataStmtSet>);
1524
1525// R848 dimension-stmt ->
1526// DIMENSION [::] array-name ( array-spec )
1527// [, array-name ( array-spec )]...
1530 TUPLE_CLASS_BOILERPLATE(Declaration);
1531 std::tuple<Name, ArraySpec> t;
1532 };
1533 WRAPPER_CLASS_BOILERPLATE(DimensionStmt, std::list<Declaration>);
1534};
1535
1536// R849 intent-stmt -> INTENT ( intent-spec ) [::] dummy-arg-name-list
1538 TUPLE_CLASS_BOILERPLATE(IntentStmt);
1539 std::tuple<IntentSpec, std::list<Name>> t;
1540};
1541
1542// R850 optional-stmt -> OPTIONAL [::] dummy-arg-name-list
1543WRAPPER_CLASS(OptionalStmt, std::list<Name>);
1544
1545// R854 pointer-decl ->
1546// object-name [( deferred-shape-spec-list )] | proc-entity-name
1548 TUPLE_CLASS_BOILERPLATE(PointerDecl);
1549 std::tuple<Name, std::optional<DeferredShapeSpecList>> t;
1550};
1551
1552// R853 pointer-stmt -> POINTER [::] pointer-decl-list
1553WRAPPER_CLASS(PointerStmt, std::list<PointerDecl>);
1554
1555// R855 protected-stmt -> PROTECTED [::] entity-name-list
1556WRAPPER_CLASS(ProtectedStmt, std::list<Name>);
1557
1558// R857 saved-entity -> object-name | proc-pointer-name | / common-block-name /
1559// R858 proc-pointer-name -> name
1561 TUPLE_CLASS_BOILERPLATE(SavedEntity);
1562 ENUM_CLASS(Kind, Entity, Common)
1563 std::tuple<Kind, Name> t;
1564};
1565
1566// R856 save-stmt -> SAVE [[::] saved-entity-list]
1567WRAPPER_CLASS(SaveStmt, std::list<SavedEntity>);
1568
1569// R859 target-stmt -> TARGET [::] target-decl-list
1570WRAPPER_CLASS(TargetStmt, std::list<ObjectDecl>);
1571
1572// R861 value-stmt -> VALUE [::] dummy-arg-name-list
1573WRAPPER_CLASS(ValueStmt, std::list<Name>);
1574
1575// R862 volatile-stmt -> VOLATILE [::] object-name-list
1576WRAPPER_CLASS(VolatileStmt, std::list<ObjectName>);
1577
1578// R865 letter-spec -> letter [- letter]
1580 TUPLE_CLASS_BOILERPLATE(LetterSpec);
1581 std::tuple<Location, std::optional<Location>> t;
1582};
1583
1584// R864 implicit-spec -> declaration-type-spec ( letter-spec-list )
1586 TUPLE_CLASS_BOILERPLATE(ImplicitSpec);
1587 std::tuple<DeclarationTypeSpec, std::list<LetterSpec>> t;
1588};
1589
1590// R863 implicit-stmt ->
1591// IMPLICIT implicit-spec-list |
1592// IMPLICIT NONE [( [implicit-name-spec-list] )]
1593// R866 implicit-name-spec -> EXTERNAL | TYPE
1595 UNION_CLASS_BOILERPLATE(ImplicitStmt);
1596 ENUM_CLASS(ImplicitNoneNameSpec, External, Type) // R866
1597 std::variant<std::list<ImplicitSpec>, std::list<ImplicitNoneNameSpec>> u;
1598};
1599
1600// R874 common-block-object -> variable-name [( array-spec )]
1602 TUPLE_CLASS_BOILERPLATE(CommonBlockObject);
1603 std::tuple<Name, std::optional<ArraySpec>> t;
1604};
1605
1606// R873 common-stmt ->
1607// COMMON [/ [common-block-name] /] common-block-object-list
1608// [[,] / [common-block-name] / common-block-object-list]...
1609struct CommonStmt {
1610 struct Block {
1611 TUPLE_CLASS_BOILERPLATE(Block);
1612 std::tuple<std::optional<Name>, std::list<CommonBlockObject>> t;
1613 };
1614 WRAPPER_CLASS_BOILERPLATE(CommonStmt, std::list<Block>);
1615 CommonStmt(std::optional<Name> &&, std::list<CommonBlockObject> &&,
1616 std::list<Block> &&);
1617 CharBlock source;
1618};
1619
1620// R872 equivalence-object -> variable-name | array-element | substring
1621WRAPPER_CLASS(EquivalenceObject, common::Indirection<Designator>);
1622
1623// R870 equivalence-stmt -> EQUIVALENCE equivalence-set-list
1624// R871 equivalence-set -> ( equivalence-object , equivalence-object-list )
1625WRAPPER_CLASS(EquivalenceStmt, std::list<std::list<EquivalenceObject>>);
1626
1627// R910 substring-range -> [scalar-int-expr] : [scalar-int-expr]
1629 TUPLE_CLASS_BOILERPLATE(SubstringRange);
1630 std::tuple<std::optional<ScalarIntExpr>, std::optional<ScalarIntExpr>> t;
1631};
1632
1633// R919 subscript -> scalar-int-expr
1634using Subscript = ScalarIntExpr;
1635
1636// R921 subscript-triplet -> [subscript] : [subscript] [: stride]
1638 TUPLE_CLASS_BOILERPLATE(SubscriptTriplet);
1639 std::tuple<std::optional<Subscript>, std::optional<Subscript>,
1640 std::optional<Subscript>>
1641 t;
1642};
1643
1644// R920 section-subscript -> subscript | subscript-triplet | vector-subscript
1645// R923 vector-subscript -> int-expr
1647 UNION_CLASS_BOILERPLATE(SectionSubscript);
1648 std::variant<IntExpr, SubscriptTriplet> u;
1649};
1650
1651// R925 cosubscript -> scalar-int-expr
1652using Cosubscript = ScalarIntExpr;
1653
1654// R1115 team-value -> scalar-expr
1655WRAPPER_CLASS(TeamValue, Scalar<common::Indirection<Expr>>);
1656
1657// R926 image-selector-spec ->
1658// NOTIFY = notify-variable |
1659// STAT = stat-variable | TEAM = team-value |
1660// TEAM_NUMBER = scalar-int-expr
1662 WRAPPER_CLASS(Stat, Scalar<Integer<common::Indirection<Variable>>>);
1663 WRAPPER_CLASS(Team_Number, ScalarIntExpr);
1664 WRAPPER_CLASS(Notify, Scalar<common::Indirection<Variable>>);
1665 UNION_CLASS_BOILERPLATE(ImageSelectorSpec);
1666 std::variant<Notify, Stat, TeamValue, Team_Number> u;
1667};
1668
1669// R924 image-selector ->
1670// lbracket cosubscript-list [, image-selector-spec-list] rbracket
1672 TUPLE_CLASS_BOILERPLATE(ImageSelector);
1673 std::tuple<std::list<Cosubscript>, std::list<ImageSelectorSpec>> t;
1674};
1675
1676// R1001 - R1022 expressions
1677struct Expr {
1678 UNION_CLASS_BOILERPLATE(Expr);
1679
1680 WRAPPER_CLASS(IntrinsicUnary, common::Indirection<Expr>);
1681 struct Parentheses : public IntrinsicUnary {
1682 using IntrinsicUnary::IntrinsicUnary;
1683 };
1684 struct UnaryPlus : public IntrinsicUnary {
1685 using IntrinsicUnary::IntrinsicUnary;
1686 };
1687 struct Negate : public IntrinsicUnary {
1688 using IntrinsicUnary::IntrinsicUnary;
1689 };
1690 struct NOT : public IntrinsicUnary {
1691 using IntrinsicUnary::IntrinsicUnary;
1692 };
1693
1694 WRAPPER_CLASS(PercentLoc, common::Indirection<Variable>); // %LOC(v) extension
1695
1697 TUPLE_CLASS_BOILERPLATE(DefinedUnary);
1698 std::tuple<DefinedOpName, common::Indirection<Expr>> t;
1699 };
1700
1702 TUPLE_CLASS_BOILERPLATE(IntrinsicBinary);
1703 std::tuple<common::Indirection<Expr>, common::Indirection<Expr>> t;
1704 };
1705 struct Power : public IntrinsicBinary {
1706 using IntrinsicBinary::IntrinsicBinary;
1707 };
1708 struct Multiply : public IntrinsicBinary {
1709 using IntrinsicBinary::IntrinsicBinary;
1710 };
1711 struct Divide : public IntrinsicBinary {
1712 using IntrinsicBinary::IntrinsicBinary;
1713 };
1714 struct Add : public IntrinsicBinary {
1715 using IntrinsicBinary::IntrinsicBinary;
1716 };
1717 struct Subtract : public IntrinsicBinary {
1718 using IntrinsicBinary::IntrinsicBinary;
1719 };
1720 struct Concat : public IntrinsicBinary {
1721 using IntrinsicBinary::IntrinsicBinary;
1722 };
1723 struct LT : public IntrinsicBinary {
1724 using IntrinsicBinary::IntrinsicBinary;
1725 };
1726 struct LE : public IntrinsicBinary {
1727 using IntrinsicBinary::IntrinsicBinary;
1728 };
1729 struct EQ : public IntrinsicBinary {
1730 using IntrinsicBinary::IntrinsicBinary;
1731 };
1732 struct NE : public IntrinsicBinary {
1733 using IntrinsicBinary::IntrinsicBinary;
1734 };
1735 struct GE : public IntrinsicBinary {
1736 using IntrinsicBinary::IntrinsicBinary;
1737 };
1738 struct GT : public IntrinsicBinary {
1739 using IntrinsicBinary::IntrinsicBinary;
1740 };
1741 struct AND : public IntrinsicBinary {
1742 using IntrinsicBinary::IntrinsicBinary;
1743 };
1744 struct OR : public IntrinsicBinary {
1745 using IntrinsicBinary::IntrinsicBinary;
1746 };
1747 struct EQV : public IntrinsicBinary {
1748 using IntrinsicBinary::IntrinsicBinary;
1749 };
1750 struct NEQV : public IntrinsicBinary {
1751 using IntrinsicBinary::IntrinsicBinary;
1752 };
1753
1754 // PGI/XLF extension: (x,y), not both constant
1756 using IntrinsicBinary::IntrinsicBinary;
1757 };
1758
1760 TUPLE_CLASS_BOILERPLATE(DefinedBinary);
1761 std::tuple<DefinedOpName, common::Indirection<Expr>,
1763 t;
1764 };
1765
1766 explicit Expr(Designator &&);
1767 explicit Expr(FunctionReference &&);
1768
1769 mutable TypedExpr typedExpr;
1770
1771 CharBlock source;
1772
1773 std::variant<common::Indirection<CharLiteralConstantSubstring>,
1777 Add, Subtract, Concat, LT, LE, EQ, NE, GE, GT, AND, OR, EQV, NEQV,
1779 u;
1780};
1781
1782// R912 part-ref -> part-name [( section-subscript-list )] [image-selector]
1783struct PartRef {
1784 TUPLE_CLASS_BOILERPLATE(PartRef);
1785 std::tuple<Name, std::list<SectionSubscript>, std::optional<ImageSelector>> t;
1786};
1787
1788// R911 data-ref -> part-ref [% part-ref]...
1789struct DataRef {
1790 UNION_CLASS_BOILERPLATE(DataRef);
1791 explicit DataRef(std::list<PartRef> &&);
1792 std::variant<Name, common::Indirection<StructureComponent>,
1795 u;
1796};
1797
1798// R908 substring -> parent-string ( substring-range )
1799// R909 parent-string ->
1800// scalar-variable-name | array-element | coindexed-named-object |
1801// scalar-structure-component | scalar-char-literal-constant |
1802// scalar-named-constant
1803// Substrings of character literals have been factored out into their
1804// own productions so that they can't appear as designators in any context
1805// other than a primary expression.
1807 TUPLE_CLASS_BOILERPLATE(Substring);
1808 std::tuple<DataRef, SubstringRange> t;
1809};
1810
1812 TUPLE_CLASS_BOILERPLATE(CharLiteralConstantSubstring);
1813 std::tuple<CharLiteralConstant, SubstringRange> t;
1814};
1815
1816// substring%KIND/LEN type parameter inquiry for cases that could not be
1817// parsed as part-refs and fixed up afterwards. N.B. we only have to
1818// handle inquiries into designator-based substrings, not those based on
1819// char-literal-constants.
1821 CharBlock source;
1822 WRAPPER_CLASS_BOILERPLATE(SubstringInquiry, Substring);
1823};
1824
1825// R901 designator -> object-name | array-element | array-section |
1826// coindexed-named-object | complex-part-designator |
1827// structure-component | substring
1829 UNION_CLASS_BOILERPLATE(Designator);
1830 bool EndsInBareName() const;
1831 CharBlock source;
1832 std::variant<DataRef, Substring> u;
1833};
1834
1835// R902 variable -> designator | function-reference
1836struct Variable {
1837 UNION_CLASS_BOILERPLATE(Variable);
1838 mutable TypedExpr typedExpr;
1839 CharBlock GetSource() const;
1840 std::variant<common::Indirection<Designator>,
1842 u;
1843};
1844
1845// R904 logical-variable -> variable
1846// Appears only as part of scalar-logical-variable.
1847using ScalarLogicalVariable = Scalar<Logical<Variable>>;
1848
1849// R906 default-char-variable -> variable
1850// Appears only as part of scalar-default-char-variable.
1851using ScalarDefaultCharVariable = Scalar<DefaultChar<Variable>>;
1852
1853// R907 int-variable -> variable
1854// Appears only as part of scalar-int-variable.
1855using ScalarIntVariable = Scalar<Integer<Variable>>;
1856
1857// R913 structure-component -> data-ref
1859 TUPLE_CLASS_BOILERPLATE(StructureComponent);
1860 std::tuple<DataRef, Name> t;
1861
1862 const DataRef &Base() const { return std::get<DataRef>(t); }
1863 const Name &Component() const { return std::get<Name>(t); }
1864};
1865
1866// R1039 proc-component-ref -> scalar-variable % procedure-component-name
1867// C1027 constrains the scalar-variable to be a data-ref without coindices.
1869 WRAPPER_CLASS_BOILERPLATE(ProcComponentRef, Scalar<StructureComponent>);
1870};
1871
1872// R914 coindexed-named-object -> data-ref
1874 TUPLE_CLASS_BOILERPLATE(CoindexedNamedObject);
1875 std::tuple<DataRef, ImageSelector> t;
1876};
1877
1878// R917 array-element -> data-ref
1880 TUPLE_CLASS_BOILERPLATE(ArrayElement);
1881 Substring ConvertToSubstring();
1882 StructureConstructor ConvertToStructureConstructor(
1884 std::tuple<DataRef, std::list<SectionSubscript>> t;
1885
1886 const DataRef &Base() const { return std::get<DataRef>(t); }
1887 const std::list<SectionSubscript> &Subscripts() const {
1888 return std::get<std::list<SectionSubscript>>(t);
1889 }
1890};
1891
1892// R933 allocate-object -> variable-name | structure-component
1894 UNION_CLASS_BOILERPLATE(AllocateObject);
1895 mutable TypedExpr typedExpr;
1896 std::variant<Name, StructureComponent> u;
1897};
1898
1899// R935 lower-bound-expr -> scalar-int-expr
1900// R936 upper-bound-expr -> scalar-int-expr
1901using BoundExpr = ScalarIntExpr;
1902
1903// R934 allocate-shape-spec -> [lower-bound-expr :] upper-bound-expr
1904// R938 allocate-coshape-spec -> [lower-bound-expr :] upper-bound-expr
1906 TUPLE_CLASS_BOILERPLATE(AllocateShapeSpec);
1907 std::tuple<std::optional<BoundExpr>, BoundExpr> t;
1908};
1909
1910using AllocateCoshapeSpec = AllocateShapeSpec;
1911
1912// R937 allocate-coarray-spec ->
1913// [allocate-coshape-spec-list ,] [lower-bound-expr :] *
1915 TUPLE_CLASS_BOILERPLATE(AllocateCoarraySpec);
1916 std::tuple<std::list<AllocateCoshapeSpec>, std::optional<BoundExpr>> t;
1917};
1918
1919// R932 allocation ->
1920// allocate-object [( allocate-shape-spec-list )]
1921// [lbracket allocate-coarray-spec rbracket]
1923 TUPLE_CLASS_BOILERPLATE(Allocation);
1924 std::tuple<AllocateObject, std::list<AllocateShapeSpec>,
1925 std::optional<AllocateCoarraySpec>>
1926 t;
1927};
1928
1929// R929 stat-variable -> scalar-int-variable
1930WRAPPER_CLASS(StatVariable, ScalarIntVariable);
1931
1932// R930 errmsg-variable -> scalar-default-char-variable
1933// R1207 iomsg-variable -> scalar-default-char-variable
1934WRAPPER_CLASS(MsgVariable, ScalarDefaultCharVariable);
1935
1936// R942 dealloc-opt -> STAT = stat-variable | ERRMSG = errmsg-variable
1937// R1165 sync-stat -> STAT = stat-variable | ERRMSG = errmsg-variable
1939 UNION_CLASS_BOILERPLATE(StatOrErrmsg);
1940 std::variant<StatVariable, MsgVariable> u;
1941};
1942
1943// R928 alloc-opt ->
1944// ERRMSG = errmsg-variable | MOLD = source-expr |
1945// SOURCE = source-expr | STAT = stat-variable |
1946// (CUDA) STREAM = scalar-int-expr
1947// PINNED = scalar-logical-variable
1948// R931 source-expr -> expr
1949struct AllocOpt {
1950 UNION_CLASS_BOILERPLATE(AllocOpt);
1951 WRAPPER_CLASS(Mold, common::Indirection<Expr>);
1952 WRAPPER_CLASS(Source, common::Indirection<Expr>);
1953 WRAPPER_CLASS(Stream, common::Indirection<ScalarIntExpr>);
1954 WRAPPER_CLASS(Pinned, common::Indirection<ScalarLogicalVariable>);
1955 std::variant<Mold, Source, StatOrErrmsg, Stream, Pinned> u;
1956};
1957
1958// R927 allocate-stmt ->
1959// ALLOCATE ( [type-spec ::] allocation-list [, alloc-opt-list] )
1961 TUPLE_CLASS_BOILERPLATE(AllocateStmt);
1962 std::tuple<std::optional<TypeSpec>, std::list<Allocation>,
1963 std::list<AllocOpt>>
1964 t;
1965};
1966
1967// R940 pointer-object ->
1968// variable-name | structure-component | proc-pointer-name
1970 UNION_CLASS_BOILERPLATE(PointerObject);
1971 mutable TypedExpr typedExpr;
1972 std::variant<Name, StructureComponent> u;
1973};
1974
1975// R939 nullify-stmt -> NULLIFY ( pointer-object-list )
1976WRAPPER_CLASS(NullifyStmt, std::list<PointerObject>);
1977
1978// R941 deallocate-stmt ->
1979// DEALLOCATE ( allocate-object-list [, dealloc-opt-list] )
1981 TUPLE_CLASS_BOILERPLATE(DeallocateStmt);
1982 std::tuple<std::list<AllocateObject>, std::list<StatOrErrmsg>> t;
1983};
1984
1985// R1032 assignment-stmt -> variable = expr
1987 TUPLE_CLASS_BOILERPLATE(AssignmentStmt);
1988 mutable TypedAssignment typedAssignment;
1989 std::tuple<Variable, Expr> t;
1990};
1991
1992// R1035 bounds-spec -> lower-bound-expr :
1993WRAPPER_CLASS(BoundsSpec, BoundExpr);
1994
1995// R1036 bounds-remapping -> lower-bound-expr : upper-bound-expr
1997 TUPLE_CLASS_BOILERPLATE(BoundsRemapping);
1998 std::tuple<BoundExpr, BoundExpr> t;
1999};
2000
2001// R1033 pointer-assignment-stmt ->
2002// data-pointer-object [( bounds-spec-list )] => data-target |
2003// data-pointer-object ( bounds-remapping-list ) => data-target |
2004// proc-pointer-object => proc-target
2005// R1034 data-pointer-object ->
2006// variable-name | scalar-variable % data-pointer-component-name
2007// R1038 proc-pointer-object -> proc-pointer-name | proc-component-ref
2009 struct Bounds {
2010 UNION_CLASS_BOILERPLATE(Bounds);
2011 std::variant<std::list<BoundsRemapping>, std::list<BoundsSpec>> u;
2012 };
2013 TUPLE_CLASS_BOILERPLATE(PointerAssignmentStmt);
2014 mutable TypedAssignment typedAssignment;
2015 std::tuple<DataRef, Bounds, Expr> t;
2016};
2017
2018// R1041 where-stmt -> WHERE ( mask-expr ) where-assignment-stmt
2019// R1045 where-assignment-stmt -> assignment-stmt
2020// R1046 mask-expr -> logical-expr
2022 TUPLE_CLASS_BOILERPLATE(WhereStmt);
2023 std::tuple<LogicalExpr, AssignmentStmt> t;
2024};
2025
2026// R1043 where-construct-stmt -> [where-construct-name :] WHERE ( mask-expr )
2028 TUPLE_CLASS_BOILERPLATE(WhereConstructStmt);
2029 std::tuple<std::optional<Name>, LogicalExpr> t;
2030};
2031
2032// R1044 where-body-construct ->
2033// where-assignment-stmt | where-stmt | where-construct
2035 UNION_CLASS_BOILERPLATE(WhereBodyConstruct);
2036 std::variant<Statement<AssignmentStmt>, Statement<WhereStmt>,
2038 u;
2039};
2040
2041// R1047 masked-elsewhere-stmt ->
2042// ELSEWHERE ( mask-expr ) [where-construct-name]
2044 TUPLE_CLASS_BOILERPLATE(MaskedElsewhereStmt);
2045 std::tuple<LogicalExpr, std::optional<Name>> t;
2046};
2047
2048// R1048 elsewhere-stmt -> ELSEWHERE [where-construct-name]
2049WRAPPER_CLASS(ElsewhereStmt, std::optional<Name>);
2050
2051// R1049 end-where-stmt -> END WHERE [where-construct-name]
2052WRAPPER_CLASS(EndWhereStmt, std::optional<Name>);
2053
2054// R1042 where-construct ->
2055// where-construct-stmt [where-body-construct]...
2056// [masked-elsewhere-stmt [where-body-construct]...]...
2057// [elsewhere-stmt [where-body-construct]...] end-where-stmt
2060 TUPLE_CLASS_BOILERPLATE(MaskedElsewhere);
2061 std::tuple<Statement<MaskedElsewhereStmt>, std::list<WhereBodyConstruct>> t;
2062 };
2063 struct Elsewhere {
2064 TUPLE_CLASS_BOILERPLATE(Elsewhere);
2065 std::tuple<Statement<ElsewhereStmt>, std::list<WhereBodyConstruct>> t;
2066 };
2067 TUPLE_CLASS_BOILERPLATE(WhereConstruct);
2068 std::tuple<Statement<WhereConstructStmt>, std::list<WhereBodyConstruct>,
2069 std::list<MaskedElsewhere>, std::optional<Elsewhere>,
2071 t;
2072};
2073
2074// R1051 forall-construct-stmt ->
2075// [forall-construct-name :] FORALL concurrent-header
2077 TUPLE_CLASS_BOILERPLATE(ForallConstructStmt);
2078 std::tuple<std::optional<Name>, common::Indirection<ConcurrentHeader>> t;
2079};
2080
2081// R1053 forall-assignment-stmt -> assignment-stmt | pointer-assignment-stmt
2083 UNION_CLASS_BOILERPLATE(ForallAssignmentStmt);
2084 std::variant<AssignmentStmt, PointerAssignmentStmt> u;
2085};
2086
2087// R1055 forall-stmt -> FORALL concurrent-header forall-assignment-stmt
2089 TUPLE_CLASS_BOILERPLATE(ForallStmt);
2090 std::tuple<common::Indirection<ConcurrentHeader>,
2092 t;
2093};
2094
2095// R1052 forall-body-construct ->
2096// forall-assignment-stmt | where-stmt | where-construct |
2097// forall-construct | forall-stmt
2099 UNION_CLASS_BOILERPLATE(ForallBodyConstruct);
2100 std::variant<Statement<ForallAssignmentStmt>, Statement<WhereStmt>,
2103 u;
2104};
2105
2106// R1054 end-forall-stmt -> END FORALL [forall-construct-name]
2107WRAPPER_CLASS(EndForallStmt, std::optional<Name>);
2108
2109// R1050 forall-construct ->
2110// forall-construct-stmt [forall-body-construct]... end-forall-stmt
2112 TUPLE_CLASS_BOILERPLATE(ForallConstruct);
2113 std::tuple<Statement<ForallConstructStmt>, std::list<ForallBodyConstruct>,
2115 t;
2116};
2117
2118// R1105 selector -> expr | variable
2119struct Selector {
2120 UNION_CLASS_BOILERPLATE(Selector);
2121 std::variant<Expr, Variable> u;
2122};
2123
2124// R1104 association -> associate-name => selector
2126 TUPLE_CLASS_BOILERPLATE(Association);
2127 std::tuple<Name, Selector> t;
2128};
2129
2130// R1103 associate-stmt ->
2131// [associate-construct-name :] ASSOCIATE ( association-list )
2133 TUPLE_CLASS_BOILERPLATE(AssociateStmt);
2134 std::tuple<std::optional<Name>, std::list<Association>> t;
2135};
2136
2137// R1106 end-associate-stmt -> END ASSOCIATE [associate-construct-name]
2138WRAPPER_CLASS(EndAssociateStmt, std::optional<Name>);
2139
2140// R1102 associate-construct -> associate-stmt block end-associate-stmt
2142 TUPLE_CLASS_BOILERPLATE(AssociateConstruct);
2143 std::tuple<Statement<AssociateStmt>, Block, Statement<EndAssociateStmt>> t;
2144};
2145
2146// R1108 block-stmt -> [block-construct-name :] BLOCK
2147WRAPPER_CLASS(BlockStmt, std::optional<Name>);
2148
2149// R1110 end-block-stmt -> END BLOCK [block-construct-name]
2150WRAPPER_CLASS(EndBlockStmt, std::optional<Name>);
2151
2152// R1109 block-specification-part ->
2153// [use-stmt]... [import-stmt]...
2154// [[declaration-construct]... specification-construct]
2155// N.B. Because BlockSpecificationPart just wraps the more general
2156// SpecificationPart, it can misrecognize an ImplicitPart as part of
2157// the BlockSpecificationPart during parsing, and we have to detect and
2158// flag such usage in semantics.
2159WRAPPER_CLASS(BlockSpecificationPart, SpecificationPart);
2160
2161// R1107 block-construct ->
2162// block-stmt [block-specification-part] block end-block-stmt
2164 TUPLE_CLASS_BOILERPLATE(BlockConstruct);
2165 std::tuple<Statement<BlockStmt>, BlockSpecificationPart, Block,
2167 t;
2168};
2169
2170// R1113 coarray-association -> codimension-decl => selector
2172 TUPLE_CLASS_BOILERPLATE(CoarrayAssociation);
2173 std::tuple<CodimensionDecl, Selector> t;
2174};
2175
2176// R1112 change-team-stmt ->
2177// [team-construct-name :] CHANGE TEAM
2178// ( team-value [, coarray-association-list] [, sync-stat-list] )
2180 TUPLE_CLASS_BOILERPLATE(ChangeTeamStmt);
2181 std::tuple<std::optional<Name>, TeamValue, std::list<CoarrayAssociation>,
2182 std::list<StatOrErrmsg>>
2183 t;
2184};
2185
2186// R1114 end-change-team-stmt ->
2187// END TEAM [( [sync-stat-list] )] [team-construct-name]
2189 TUPLE_CLASS_BOILERPLATE(EndChangeTeamStmt);
2190 std::tuple<std::list<StatOrErrmsg>, std::optional<Name>> t;
2191};
2192
2193// R1111 change-team-construct -> change-team-stmt block end-change-team-stmt
2195 TUPLE_CLASS_BOILERPLATE(ChangeTeamConstruct);
2196 std::tuple<Statement<ChangeTeamStmt>, Block, Statement<EndChangeTeamStmt>> t;
2197};
2198
2199// R1117 critical-stmt ->
2200// [critical-construct-name :] CRITICAL [( [sync-stat-list] )]
2202 TUPLE_CLASS_BOILERPLATE(CriticalStmt);
2203 std::tuple<std::optional<Name>, std::list<StatOrErrmsg>> t;
2204};
2205
2206// R1118 end-critical-stmt -> END CRITICAL [critical-construct-name]
2207WRAPPER_CLASS(EndCriticalStmt, std::optional<Name>);
2208
2209// R1116 critical-construct -> critical-stmt block end-critical-stmt
2211 TUPLE_CLASS_BOILERPLATE(CriticalConstruct);
2212 std::tuple<Statement<CriticalStmt>, Block, Statement<EndCriticalStmt>> t;
2213};
2214
2215// R1126 concurrent-control ->
2216// index-name = concurrent-limit : concurrent-limit [: concurrent-step]
2217// R1127 concurrent-limit -> scalar-int-expr
2218// R1128 concurrent-step -> scalar-int-expr
2220 TUPLE_CLASS_BOILERPLATE(ConcurrentControl);
2221 std::tuple<Name, ScalarIntExpr, ScalarIntExpr, std::optional<ScalarIntExpr>>
2222 t;
2223};
2224
2225// R1125 concurrent-header ->
2226// ( [integer-type-spec ::] concurrent-control-list
2227// [, scalar-mask-expr] )
2229 TUPLE_CLASS_BOILERPLATE(ConcurrentHeader);
2230 std::tuple<std::optional<IntegerTypeSpec>, std::list<ConcurrentControl>,
2231 std::optional<ScalarLogicalExpr>>
2232 t;
2233};
2234
2235// F'2023 R1131 reduce-operation -> reduction-operator
2236// CUF reduction-op -> reduction-operator
2237// OpenACC 3.3 2.5.15 reduction-operator ->
2238// + | * | .AND. | .OR. | .EQV. | .NEQV. |
2239// MAX | MIN | IAND | IOR | IEOR
2241 ENUM_CLASS(
2242 Operator, Plus, Multiply, Max, Min, Iand, Ior, Ieor, And, Or, Eqv, Neqv)
2243 WRAPPER_CLASS_BOILERPLATE(ReductionOperator, Operator);
2244 CharBlock source;
2245};
2246
2247// R1130 locality-spec ->
2248// LOCAL ( variable-name-list ) | LOCAL_INIT ( variable-name-list ) |
2249// REDUCE ( reduce-operation : variable-name-list ) |
2250// SHARED ( variable-name-list ) | DEFAULT ( NONE )
2252 UNION_CLASS_BOILERPLATE(LocalitySpec);
2253 WRAPPER_CLASS(Local, std::list<Name>);
2254 WRAPPER_CLASS(LocalInit, std::list<Name>);
2255 struct Reduce {
2256 TUPLE_CLASS_BOILERPLATE(Reduce);
2257 using Operator = ReductionOperator;
2258 std::tuple<Operator, std::list<Name>> t;
2259 };
2260 WRAPPER_CLASS(Shared, std::list<Name>);
2261 EMPTY_CLASS(DefaultNone);
2262 std::variant<Local, LocalInit, Reduce, Shared, DefaultNone> u;
2263};
2264
2265// R1123 loop-control ->
2266// [,] do-variable = scalar-int-expr , scalar-int-expr
2267// [, scalar-int-expr] |
2268// [,] WHILE ( scalar-logical-expr ) |
2269// [,] CONCURRENT concurrent-header concurrent-locality
2270// R1129 concurrent-locality -> [locality-spec]...
2272 UNION_CLASS_BOILERPLATE(LoopControl);
2273 struct Concurrent {
2274 TUPLE_CLASS_BOILERPLATE(Concurrent);
2275 std::tuple<ConcurrentHeader, std::list<LocalitySpec>> t;
2276 };
2278 std::variant<Bounds, ScalarLogicalExpr, Concurrent> u;
2279};
2280
2281// R1121 label-do-stmt -> [do-construct-name :] DO label [loop-control]
2282// A label-do-stmt with a do-construct-name is parsed as a non-label-do-stmt.
2284 TUPLE_CLASS_BOILERPLATE(LabelDoStmt);
2285 std::tuple<Label, std::optional<LoopControl>> t;
2286};
2287
2288// R1122 nonlabel-do-stmt -> [do-construct-name :] DO [loop-control]
2290 TUPLE_CLASS_BOILERPLATE(NonLabelDoStmt);
2291 std::tuple<std::optional<Name>, std::optional<Label>,
2292 std::optional<LoopControl>>
2293 t;
2294};
2295
2296// R1132 end-do-stmt -> END DO [do-construct-name]
2297WRAPPER_CLASS(EndDoStmt, std::optional<Name>);
2298
2299// R1131 end-do -> end-do-stmt | continue-stmt
2300
2301// R1119 do-construct -> do-stmt block end-do
2302// R1120 do-stmt -> nonlabel-do-stmt | label-do-stmt
2303// Deprecated, but supported: "label DO" loops ending on statements other
2304// than END DO and CONTINUE, and multiple "label DO" loops ending on the
2305// same label.
2307 TUPLE_CLASS_BOILERPLATE(DoConstruct);
2308 const std::optional<LoopControl> &GetLoopControl() const;
2309 bool IsDoNormal() const;
2310 bool IsDoWhile() const;
2311 bool IsDoConcurrent() const;
2312 std::tuple<Statement<NonLabelDoStmt>, Block, Statement<EndDoStmt>> t;
2313};
2314
2315// R1133 cycle-stmt -> CYCLE [do-construct-name]
2316WRAPPER_CLASS(CycleStmt, std::optional<Name>);
2317
2318// R1135 if-then-stmt -> [if-construct-name :] IF ( scalar-logical-expr ) THEN
2320 TUPLE_CLASS_BOILERPLATE(IfThenStmt);
2321 std::tuple<std::optional<Name>, ScalarLogicalExpr> t;
2322};
2323
2324// R1136 else-if-stmt ->
2325// ELSE IF ( scalar-logical-expr ) THEN [if-construct-name]
2327 TUPLE_CLASS_BOILERPLATE(ElseIfStmt);
2328 std::tuple<ScalarLogicalExpr, std::optional<Name>> t;
2329};
2330
2331// R1137 else-stmt -> ELSE [if-construct-name]
2332WRAPPER_CLASS(ElseStmt, std::optional<Name>);
2333
2334// R1138 end-if-stmt -> END IF [if-construct-name]
2335WRAPPER_CLASS(EndIfStmt, std::optional<Name>);
2336
2337// R1134 if-construct ->
2338// if-then-stmt block [else-if-stmt block]...
2339// [else-stmt block] end-if-stmt
2342 TUPLE_CLASS_BOILERPLATE(ElseIfBlock);
2343 std::tuple<Statement<ElseIfStmt>, Block> t;
2344 };
2345 struct ElseBlock {
2346 TUPLE_CLASS_BOILERPLATE(ElseBlock);
2347 std::tuple<Statement<ElseStmt>, Block> t;
2348 };
2349 TUPLE_CLASS_BOILERPLATE(IfConstruct);
2350 std::tuple<Statement<IfThenStmt>, Block, std::list<ElseIfBlock>,
2351 std::optional<ElseBlock>, Statement<EndIfStmt>>
2352 t;
2353};
2354
2355// R1139 if-stmt -> IF ( scalar-logical-expr ) action-stmt
2356struct IfStmt {
2357 TUPLE_CLASS_BOILERPLATE(IfStmt);
2358 std::tuple<ScalarLogicalExpr, UnlabeledStatement<ActionStmt>> t;
2359};
2360
2361// R1141 select-case-stmt -> [case-construct-name :] SELECT CASE ( case-expr )
2362// R1144 case-expr -> scalar-expr
2364 TUPLE_CLASS_BOILERPLATE(SelectCaseStmt);
2365 std::tuple<std::optional<Name>, Scalar<Expr>> t;
2366};
2367
2368// R1147 case-value -> scalar-constant-expr
2369using CaseValue = Scalar<ConstantExpr>;
2370
2371// R1146 case-value-range ->
2372// case-value | case-value : | : case-value | case-value : case-value
2374 UNION_CLASS_BOILERPLATE(CaseValueRange);
2375 struct Range {
2376 TUPLE_CLASS_BOILERPLATE(Range);
2377 std::tuple<std::optional<CaseValue>, std::optional<CaseValue>>
2378 t; // not both missing
2379 };
2380 std::variant<CaseValue, Range> u;
2381};
2382
2383// R1145 case-selector -> ( case-value-range-list ) | DEFAULT
2384EMPTY_CLASS(Default);
2385
2387 UNION_CLASS_BOILERPLATE(CaseSelector);
2388 std::variant<std::list<CaseValueRange>, Default> u;
2389};
2390
2391// R1142 case-stmt -> CASE case-selector [case-construct-name]
2392struct CaseStmt {
2393 TUPLE_CLASS_BOILERPLATE(CaseStmt);
2394 std::tuple<CaseSelector, std::optional<Name>> t;
2395};
2396
2397// R1143 end-select-stmt -> END SELECT [case-construct-name]
2398// R1151 end-select-rank-stmt -> END SELECT [select-construct-name]
2399// R1155 end-select-type-stmt -> END SELECT [select-construct-name]
2400WRAPPER_CLASS(EndSelectStmt, std::optional<Name>);
2401
2402// R1140 case-construct ->
2403// select-case-stmt [case-stmt block]... end-select-stmt
2405 struct Case {
2406 TUPLE_CLASS_BOILERPLATE(Case);
2407 std::tuple<Statement<CaseStmt>, Block> t;
2408 };
2409 TUPLE_CLASS_BOILERPLATE(CaseConstruct);
2410 std::tuple<Statement<SelectCaseStmt>, std::list<Case>,
2412 t;
2413};
2414
2415// R1149 select-rank-stmt ->
2416// [select-construct-name :] SELECT RANK
2417// ( [associate-name =>] selector )
2419 TUPLE_CLASS_BOILERPLATE(SelectRankStmt);
2420 std::tuple<std::optional<Name>, std::optional<Name>, Selector> t;
2421};
2422
2423// R1150 select-rank-case-stmt ->
2424// RANK ( scalar-int-constant-expr ) [select-construct-name] |
2425// RANK ( * ) [select-construct-name] |
2426// RANK DEFAULT [select-construct-name]
2428 struct Rank {
2429 UNION_CLASS_BOILERPLATE(Rank);
2430 std::variant<ScalarIntConstantExpr, Star, Default> u;
2431 };
2432 TUPLE_CLASS_BOILERPLATE(SelectRankCaseStmt);
2433 std::tuple<Rank, std::optional<Name>> t;
2434};
2435
2436// R1148 select-rank-construct ->
2437// select-rank-stmt [select-rank-case-stmt block]...
2438// end-select-rank-stmt
2440 TUPLE_CLASS_BOILERPLATE(SelectRankConstruct);
2441 struct RankCase {
2442 TUPLE_CLASS_BOILERPLATE(RankCase);
2443 std::tuple<Statement<SelectRankCaseStmt>, Block> t;
2444 };
2445 std::tuple<Statement<SelectRankStmt>, std::list<RankCase>,
2447 t;
2448};
2449
2450// R1153 select-type-stmt ->
2451// [select-construct-name :] SELECT TYPE
2452// ( [associate-name =>] selector )
2454 TUPLE_CLASS_BOILERPLATE(SelectTypeStmt);
2455 std::tuple<std::optional<Name>, std::optional<Name>, Selector> t;
2456};
2457
2458// R1154 type-guard-stmt ->
2459// TYPE IS ( type-spec ) [select-construct-name] |
2460// CLASS IS ( derived-type-spec ) [select-construct-name] |
2461// CLASS DEFAULT [select-construct-name]
2463 struct Guard {
2464 UNION_CLASS_BOILERPLATE(Guard);
2465 std::variant<TypeSpec, DerivedTypeSpec, Default> u;
2466 };
2467 TUPLE_CLASS_BOILERPLATE(TypeGuardStmt);
2468 std::tuple<Guard, std::optional<Name>> t;
2469};
2470
2471// R1152 select-type-construct ->
2472// select-type-stmt [type-guard-stmt block]... end-select-type-stmt
2474 TUPLE_CLASS_BOILERPLATE(SelectTypeConstruct);
2475 struct TypeCase {
2476 TUPLE_CLASS_BOILERPLATE(TypeCase);
2477 std::tuple<Statement<TypeGuardStmt>, Block> t;
2478 };
2479 std::tuple<Statement<SelectTypeStmt>, std::list<TypeCase>,
2481 t;
2482};
2483
2484// R1156 exit-stmt -> EXIT [construct-name]
2485WRAPPER_CLASS(ExitStmt, std::optional<Name>);
2486
2487// R1157 goto-stmt -> GO TO label
2488WRAPPER_CLASS(GotoStmt, Label);
2489
2490// R1158 computed-goto-stmt -> GO TO ( label-list ) [,] scalar-int-expr
2492 TUPLE_CLASS_BOILERPLATE(ComputedGotoStmt);
2493 std::tuple<std::list<Label>, ScalarIntExpr> t;
2494};
2495
2496// R1162 stop-code -> scalar-default-char-expr | scalar-int-expr
2497// We can't distinguish character expressions from integer
2498// expressions during parsing, so we just parse an expr and
2499// check its type later.
2500WRAPPER_CLASS(StopCode, Scalar<Expr>);
2501
2502// R1160 stop-stmt -> STOP [stop-code] [, QUIET = scalar-logical-expr]
2503// R1161 error-stop-stmt ->
2504// ERROR STOP [stop-code] [, QUIET = scalar-logical-expr]
2505struct StopStmt {
2506 ENUM_CLASS(Kind, Stop, ErrorStop)
2507 TUPLE_CLASS_BOILERPLATE(StopStmt);
2508 std::tuple<Kind, std::optional<StopCode>, std::optional<ScalarLogicalExpr>> t;
2509};
2510
2511// F2023: R1166 notify-wait-stmt -> NOTIFY WAIT ( notify-variable [,
2512// event-wait-spec-list] )
2514 TUPLE_CLASS_BOILERPLATE(NotifyWaitStmt);
2515 std::tuple<Scalar<Variable>, std::list<EventWaitSpec>> t;
2516};
2517
2518// R1164 sync-all-stmt -> SYNC ALL [( [sync-stat-list] )]
2519WRAPPER_CLASS(SyncAllStmt, std::list<StatOrErrmsg>);
2520
2521// R1166 sync-images-stmt -> SYNC IMAGES ( image-set [, sync-stat-list] )
2522// R1167 image-set -> int-expr | *
2524 struct ImageSet {
2525 UNION_CLASS_BOILERPLATE(ImageSet);
2526 std::variant<IntExpr, Star> u;
2527 };
2528 TUPLE_CLASS_BOILERPLATE(SyncImagesStmt);
2529 std::tuple<ImageSet, std::list<StatOrErrmsg>> t;
2530};
2531
2532// R1168 sync-memory-stmt -> SYNC MEMORY [( [sync-stat-list] )]
2533WRAPPER_CLASS(SyncMemoryStmt, std::list<StatOrErrmsg>);
2534
2535// R1169 sync-team-stmt -> SYNC TEAM ( team-value [, sync-stat-list] )
2537 TUPLE_CLASS_BOILERPLATE(SyncTeamStmt);
2538 std::tuple<TeamValue, std::list<StatOrErrmsg>> t;
2539};
2540
2541// R1171 event-variable -> scalar-variable
2542using EventVariable = Scalar<Variable>;
2543
2544// R1170 event-post-stmt -> EVENT POST ( event-variable [, sync-stat-list] )
2546 TUPLE_CLASS_BOILERPLATE(EventPostStmt);
2547 std::tuple<EventVariable, std::list<StatOrErrmsg>> t;
2548};
2549
2550// R1173 event-wait-spec -> until-spec | sync-stat
2552 UNION_CLASS_BOILERPLATE(EventWaitSpec);
2553 std::variant<ScalarIntExpr, StatOrErrmsg> u;
2554};
2555
2556// R1172 event-wait-stmt ->
2557// EVENT WAIT ( event-variable [, event-wait-spec-list] )
2558// R1174 until-spec -> UNTIL_COUNT = scalar-int-expr
2560 TUPLE_CLASS_BOILERPLATE(EventWaitStmt);
2561 std::tuple<EventVariable, std::list<EventWaitSpec>> t;
2562};
2563
2564// R1177 team-variable -> scalar-variable
2565using TeamVariable = Scalar<Variable>;
2566
2567// R1175 form-team-stmt ->
2568// FORM TEAM ( team-number , team-variable [, form-team-spec-list] )
2569// R1176 team-number -> scalar-int-expr
2570// R1178 form-team-spec -> NEW_INDEX = scalar-int-expr | sync-stat
2573 UNION_CLASS_BOILERPLATE(FormTeamSpec);
2574 std::variant<ScalarIntExpr, StatOrErrmsg> u;
2575 };
2576 TUPLE_CLASS_BOILERPLATE(FormTeamStmt);
2577 std::tuple<ScalarIntExpr, TeamVariable, std::list<FormTeamSpec>> t;
2578};
2579
2580// R1182 lock-variable -> scalar-variable
2581using LockVariable = Scalar<Variable>;
2582
2583// R1179 lock-stmt -> LOCK ( lock-variable [, lock-stat-list] )
2584// R1180 lock-stat -> ACQUIRED_LOCK = scalar-logical-variable | sync-stat
2585struct LockStmt {
2586 struct LockStat {
2587 UNION_CLASS_BOILERPLATE(LockStat);
2588 std::variant<Scalar<Logical<Variable>>, StatOrErrmsg> u;
2589 };
2590 TUPLE_CLASS_BOILERPLATE(LockStmt);
2591 std::tuple<LockVariable, std::list<LockStat>> t;
2592};
2593
2594// R1181 unlock-stmt -> UNLOCK ( lock-variable [, sync-stat-list] )
2596 TUPLE_CLASS_BOILERPLATE(UnlockStmt);
2597 std::tuple<LockVariable, std::list<StatOrErrmsg>> t;
2598};
2599
2600// R1202 file-unit-number -> scalar-int-expr
2601WRAPPER_CLASS(FileUnitNumber, ScalarIntExpr);
2602
2603// R1201 io-unit -> file-unit-number | * | internal-file-variable
2604// R1203 internal-file-variable -> char-variable
2605// R905 char-variable -> variable
2606// When Variable appears as an IoUnit, it must be character of a default,
2607// ASCII, or Unicode kind; this constraint is not automatically checked.
2608// The parse is ambiguous and is repaired if necessary once the types of
2609// symbols are known.
2610struct IoUnit {
2611 UNION_CLASS_BOILERPLATE(IoUnit);
2612 std::variant<Variable, common::Indirection<Expr>, Star> u;
2613};
2614
2615// R1206 file-name-expr -> scalar-default-char-expr
2616using FileNameExpr = ScalarDefaultCharExpr;
2617
2618// R1205 connect-spec ->
2619// [UNIT =] file-unit-number | ACCESS = scalar-default-char-expr |
2620// ACTION = scalar-default-char-expr |
2621// ASYNCHRONOUS = scalar-default-char-expr |
2622// BLANK = scalar-default-char-expr |
2623// DECIMAL = scalar-default-char-expr |
2624// DELIM = scalar-default-char-expr |
2625// ENCODING = scalar-default-char-expr | ERR = label |
2626// FILE = file-name-expr | FORM = scalar-default-char-expr |
2627// IOMSG = iomsg-variable | IOSTAT = scalar-int-variable |
2628// NEWUNIT = scalar-int-variable | PAD = scalar-default-char-expr |
2629// POSITION = scalar-default-char-expr | RECL = scalar-int-expr |
2630// ROUND = scalar-default-char-expr | SIGN = scalar-default-char-expr |
2631// STATUS = scalar-default-char-expr
2632// @ | CARRIAGECONTROL = scalar-default-char-variable
2633// | CONVERT = scalar-default-char-variable
2634// | DISPOSE = scalar-default-char-variable
2635WRAPPER_CLASS(StatusExpr, ScalarDefaultCharExpr);
2636WRAPPER_CLASS(ErrLabel, Label);
2637
2639 UNION_CLASS_BOILERPLATE(ConnectSpec);
2640 struct CharExpr {
2641 ENUM_CLASS(Kind, Access, Action, Asynchronous, Blank, Decimal, Delim,
2642 Encoding, Form, Pad, Position, Round, Sign,
2643 /* extensions: */ Carriagecontrol, Convert, Dispose)
2644 TUPLE_CLASS_BOILERPLATE(CharExpr);
2645 std::tuple<Kind, ScalarDefaultCharExpr> t;
2646 };
2647 WRAPPER_CLASS(Recl, ScalarIntExpr);
2648 WRAPPER_CLASS(Newunit, ScalarIntVariable);
2649 std::variant<FileUnitNumber, FileNameExpr, CharExpr, MsgVariable,
2650 StatVariable, Recl, Newunit, ErrLabel, StatusExpr>
2651 u;
2652};
2653
2654// R1204 open-stmt -> OPEN ( connect-spec-list )
2655WRAPPER_CLASS(OpenStmt, std::list<ConnectSpec>);
2656
2657// R1208 close-stmt -> CLOSE ( close-spec-list )
2658// R1209 close-spec ->
2659// [UNIT =] file-unit-number | IOSTAT = scalar-int-variable |
2660// IOMSG = iomsg-variable | ERR = label |
2661// STATUS = scalar-default-char-expr
2663 struct CloseSpec {
2664 UNION_CLASS_BOILERPLATE(CloseSpec);
2665 std::variant<FileUnitNumber, StatVariable, MsgVariable, ErrLabel,
2666 StatusExpr>
2667 u;
2668 };
2669 WRAPPER_CLASS_BOILERPLATE(CloseStmt, std::list<CloseSpec>);
2670};
2671
2672// R1215 format -> default-char-expr | label | *
2673// deprecated(ASSIGN): | scalar-int-name
2674struct Format {
2675 UNION_CLASS_BOILERPLATE(Format);
2676 std::variant<Expr, Label, Star> u;
2677};
2678
2679// R1214 id-variable -> scalar-int-variable
2680WRAPPER_CLASS(IdVariable, ScalarIntVariable);
2681
2682// R1213 io-control-spec ->
2683// [UNIT =] io-unit | [FMT =] format | [NML =] namelist-group-name |
2684// ADVANCE = scalar-default-char-expr |
2685// ASYNCHRONOUS = scalar-default-char-constant-expr |
2686// BLANK = scalar-default-char-expr |
2687// DECIMAL = scalar-default-char-expr |
2688// DELIM = scalar-default-char-expr | END = label | EOR = label |
2689// ERR = label | ID = id-variable | IOMSG = iomsg-variable |
2690// IOSTAT = scalar-int-variable | PAD = scalar-default-char-expr |
2691// POS = scalar-int-expr | REC = scalar-int-expr |
2692// ROUND = scalar-default-char-expr | SIGN = scalar-default-char-expr |
2693// SIZE = scalar-int-variable
2694WRAPPER_CLASS(EndLabel, Label);
2695WRAPPER_CLASS(EorLabel, Label);
2697 UNION_CLASS_BOILERPLATE(IoControlSpec);
2698 struct CharExpr {
2699 ENUM_CLASS(Kind, Advance, Blank, Decimal, Delim, Pad, Round, Sign)
2700 TUPLE_CLASS_BOILERPLATE(CharExpr);
2701 std::tuple<Kind, ScalarDefaultCharExpr> t;
2702 };
2703 WRAPPER_CLASS(Asynchronous, ScalarDefaultCharConstantExpr);
2704 WRAPPER_CLASS(Pos, ScalarIntExpr);
2705 WRAPPER_CLASS(Rec, ScalarIntExpr);
2706 WRAPPER_CLASS(Size, ScalarIntVariable);
2707 std::variant<IoUnit, Format, Name, CharExpr, Asynchronous, EndLabel, EorLabel,
2708 ErrLabel, IdVariable, MsgVariable, StatVariable, Pos, Rec, Size,
2709 ErrorRecovery>
2710 u;
2711};
2712
2713// R1216 input-item -> variable | io-implied-do
2715 UNION_CLASS_BOILERPLATE(InputItem);
2716 std::variant<Variable, common::Indirection<InputImpliedDo>> u;
2717};
2718
2719// R1210 read-stmt ->
2720// READ ( io-control-spec-list ) [input-item-list] |
2721// READ format [, input-item-list]
2722struct ReadStmt {
2723 BOILERPLATE(ReadStmt);
2724 ReadStmt(std::optional<IoUnit> &&i, std::optional<Format> &&f,
2725 std::list<IoControlSpec> &&cs, std::list<InputItem> &&its)
2726 : iounit{std::move(i)}, format{std::move(f)}, controls(std::move(cs)),
2727 items(std::move(its)) {}
2728 std::optional<IoUnit> iounit; // if first in controls without UNIT= &/or
2729 // followed by untagged format/namelist
2730 std::optional<Format> format; // if second in controls without FMT=/NML=, or
2731 // no (io-control-spec-list); might be
2732 // an untagged namelist group name
2733 std::list<IoControlSpec> controls;
2734 std::list<InputItem> items;
2735};
2736
2737// R1217 output-item -> expr | io-implied-do
2739 UNION_CLASS_BOILERPLATE(OutputItem);
2740 std::variant<Expr, common::Indirection<OutputImpliedDo>> u;
2741};
2742
2743// R1211 write-stmt -> WRITE ( io-control-spec-list ) [output-item-list]
2744struct WriteStmt {
2745 BOILERPLATE(WriteStmt);
2746 WriteStmt(std::optional<IoUnit> &&i, std::optional<Format> &&f,
2747 std::list<IoControlSpec> &&cs, std::list<OutputItem> &&its)
2748 : iounit{std::move(i)}, format{std::move(f)}, controls(std::move(cs)),
2749 items(std::move(its)) {}
2750 std::optional<IoUnit> iounit; // if first in controls without UNIT= &/or
2751 // followed by untagged format/namelist
2752 std::optional<Format> format; // if second in controls without FMT=/NML=;
2753 // might be an untagged namelist group, too
2754 std::list<IoControlSpec> controls;
2755 std::list<OutputItem> items;
2756};
2757
2758// R1212 print-stmt PRINT format [, output-item-list]
2760 TUPLE_CLASS_BOILERPLATE(PrintStmt);
2761 std::tuple<Format, std::list<OutputItem>> t;
2762};
2763
2764// R1220 io-implied-do-control ->
2765// do-variable = scalar-int-expr , scalar-int-expr [, scalar-int-expr]
2766using IoImpliedDoControl = LoopBounds<DoVariable, ScalarIntExpr>;
2767
2768// R1218 io-implied-do -> ( io-implied-do-object-list , io-implied-do-control )
2769// R1219 io-implied-do-object -> input-item | output-item
2771 TUPLE_CLASS_BOILERPLATE(InputImpliedDo);
2772 std::tuple<std::list<InputItem>, IoImpliedDoControl> t;
2773};
2774
2776 TUPLE_CLASS_BOILERPLATE(OutputImpliedDo);
2777 std::tuple<std::list<OutputItem>, IoImpliedDoControl> t;
2778};
2779
2780// R1223 wait-spec ->
2781// [UNIT =] file-unit-number | END = label | EOR = label | ERR = label |
2782// ID = scalar-int-expr | IOMSG = iomsg-variable |
2783// IOSTAT = scalar-int-variable
2784WRAPPER_CLASS(IdExpr, ScalarIntExpr);
2785struct WaitSpec {
2786 UNION_CLASS_BOILERPLATE(WaitSpec);
2787 std::variant<FileUnitNumber, EndLabel, EorLabel, ErrLabel, IdExpr,
2788 MsgVariable, StatVariable>
2789 u;
2790};
2791
2792// R1222 wait-stmt -> WAIT ( wait-spec-list )
2793WRAPPER_CLASS(WaitStmt, std::list<WaitSpec>);
2794
2795// R1227 position-spec ->
2796// [UNIT =] file-unit-number | IOMSG = iomsg-variable |
2797// IOSTAT = scalar-int-variable | ERR = label
2798// R1229 flush-spec ->
2799// [UNIT =] file-unit-number | IOSTAT = scalar-int-variable |
2800// IOMSG = iomsg-variable | ERR = label
2802 UNION_CLASS_BOILERPLATE(PositionOrFlushSpec);
2803 std::variant<FileUnitNumber, MsgVariable, StatVariable, ErrLabel> u;
2804};
2805
2806// R1224 backspace-stmt ->
2807// BACKSPACE file-unit-number | BACKSPACE ( position-spec-list )
2808WRAPPER_CLASS(BackspaceStmt, std::list<PositionOrFlushSpec>);
2809
2810// R1225 endfile-stmt ->
2811// ENDFILE file-unit-number | ENDFILE ( position-spec-list )
2812WRAPPER_CLASS(EndfileStmt, std::list<PositionOrFlushSpec>);
2813
2814// R1226 rewind-stmt -> REWIND file-unit-number | REWIND ( position-spec-list )
2815WRAPPER_CLASS(RewindStmt, std::list<PositionOrFlushSpec>);
2816
2817// R1228 flush-stmt -> FLUSH file-unit-number | FLUSH ( flush-spec-list )
2818WRAPPER_CLASS(FlushStmt, std::list<PositionOrFlushSpec>);
2819
2820// R1231 inquire-spec ->
2821// [UNIT =] file-unit-number | FILE = file-name-expr |
2822// ACCESS = scalar-default-char-variable |
2823// ACTION = scalar-default-char-variable |
2824// ASYNCHRONOUS = scalar-default-char-variable |
2825// BLANK = scalar-default-char-variable |
2826// DECIMAL = scalar-default-char-variable |
2827// DELIM = scalar-default-char-variable |
2828// DIRECT = scalar-default-char-variable |
2829// ENCODING = scalar-default-char-variable |
2830// ERR = label | EXIST = scalar-logical-variable |
2831// FORM = scalar-default-char-variable |
2832// FORMATTED = scalar-default-char-variable |
2833// ID = scalar-int-expr | IOMSG = iomsg-variable |
2834// IOSTAT = scalar-int-variable |
2835// NAME = scalar-default-char-variable |
2836// NAMED = scalar-logical-variable |
2837// NEXTREC = scalar-int-variable | NUMBER = scalar-int-variable |
2838// OPENED = scalar-logical-variable |
2839// PAD = scalar-default-char-variable |
2840// PENDING = scalar-logical-variable | POS = scalar-int-variable |
2841// POSITION = scalar-default-char-variable |
2842// READ = scalar-default-char-variable |
2843// READWRITE = scalar-default-char-variable |
2844// RECL = scalar-int-variable | ROUND = scalar-default-char-variable |
2845// SEQUENTIAL = scalar-default-char-variable |
2846// SIGN = scalar-default-char-variable |
2847// SIZE = scalar-int-variable |
2848// STREAM = scalar-default-char-variable |
2849// STATUS = scalar-default-char-variable |
2850// UNFORMATTED = scalar-default-char-variable |
2851// WRITE = scalar-default-char-variable
2852// @ | CARRIAGECONTROL = scalar-default-char-variable
2853// | CONVERT = scalar-default-char-variable
2854// | DISPOSE = scalar-default-char-variable
2856 UNION_CLASS_BOILERPLATE(InquireSpec);
2857 struct CharVar {
2858 ENUM_CLASS(Kind, Access, Action, Asynchronous, Blank, Decimal, Delim,
2859 Direct, Encoding, Form, Formatted, Iomsg, Name, Pad, Position, Read,
2860 Readwrite, Round, Sequential, Sign, Stream, Status, Unformatted, Write,
2861 /* extensions: */ Carriagecontrol, Convert, Dispose)
2862 TUPLE_CLASS_BOILERPLATE(CharVar);
2863 std::tuple<Kind, ScalarDefaultCharVariable> t;
2864 };
2865 struct IntVar {
2866 ENUM_CLASS(Kind, Iostat, Nextrec, Number, Pos, Recl, Size)
2867 TUPLE_CLASS_BOILERPLATE(IntVar);
2868 std::tuple<Kind, ScalarIntVariable> t;
2869 };
2870 struct LogVar {
2871 ENUM_CLASS(Kind, Exist, Named, Opened, Pending)
2872 TUPLE_CLASS_BOILERPLATE(LogVar);
2873 std::tuple<Kind, Scalar<Logical<Variable>>> t;
2874 };
2875 std::variant<FileUnitNumber, FileNameExpr, CharVar, IntVar, LogVar, IdExpr,
2876 ErrLabel>
2877 u;
2878};
2879
2880// R1230 inquire-stmt ->
2881// INQUIRE ( inquire-spec-list ) |
2882// INQUIRE ( IOLENGTH = scalar-int-variable ) output-item-list
2884 UNION_CLASS_BOILERPLATE(InquireStmt);
2885 struct Iolength {
2886 TUPLE_CLASS_BOILERPLATE(Iolength);
2887 std::tuple<ScalarIntVariable, std::list<OutputItem>> t;
2888 };
2889 std::variant<std::list<InquireSpec>, Iolength> u;
2890};
2891
2892// R1301 format-stmt -> FORMAT format-specification
2893WRAPPER_CLASS(FormatStmt, format::FormatSpecification);
2894
2895// R1402 program-stmt -> PROGRAM program-name
2896WRAPPER_CLASS(ProgramStmt, Name);
2897
2898// R1403 end-program-stmt -> END [PROGRAM [program-name]]
2899WRAPPER_CLASS(EndProgramStmt, std::optional<Name>);
2900
2901// R1401 main-program ->
2902// [program-stmt] [specification-part] [execution-part]
2903// [internal-subprogram-part] end-program-stmt
2905 TUPLE_CLASS_BOILERPLATE(MainProgram);
2906 std::tuple<std::optional<Statement<ProgramStmt>>, SpecificationPart,
2907 ExecutionPart, std::optional<InternalSubprogramPart>,
2909 t;
2910};
2911
2912// R1405 module-stmt -> MODULE module-name
2913WRAPPER_CLASS(ModuleStmt, Name);
2914
2915// R1408 module-subprogram ->
2916// function-subprogram | subroutine-subprogram |
2917// separate-module-subprogram
2919 UNION_CLASS_BOILERPLATE(ModuleSubprogram);
2920 std::variant<common::Indirection<FunctionSubprogram>,
2924 u;
2925};
2926
2927// R1407 module-subprogram-part -> contains-stmt [module-subprogram]...
2929 TUPLE_CLASS_BOILERPLATE(ModuleSubprogramPart);
2930 std::tuple<Statement<ContainsStmt>, std::list<ModuleSubprogram>> t;
2931};
2932
2933// R1406 end-module-stmt -> END [MODULE [module-name]]
2934WRAPPER_CLASS(EndModuleStmt, std::optional<Name>);
2935
2936// R1404 module ->
2937// module-stmt [specification-part] [module-subprogram-part]
2938// end-module-stmt
2939struct Module {
2940 TUPLE_CLASS_BOILERPLATE(Module);
2941 std::tuple<Statement<ModuleStmt>, SpecificationPart,
2942 std::optional<ModuleSubprogramPart>, Statement<EndModuleStmt>>
2943 t;
2944};
2945
2946// R1411 rename ->
2947// local-name => use-name |
2948// OPERATOR ( local-defined-operator ) =>
2949// OPERATOR ( use-defined-operator )
2950struct Rename {
2951 UNION_CLASS_BOILERPLATE(Rename);
2952 struct Names {
2953 TUPLE_CLASS_BOILERPLATE(Names);
2954 std::tuple<Name, Name> t;
2955 };
2956 struct Operators {
2957 TUPLE_CLASS_BOILERPLATE(Operators);
2958 std::tuple<DefinedOpName, DefinedOpName> t;
2959 };
2960 std::variant<Names, Operators> u;
2961};
2962
2963// R1418 parent-identifier -> ancestor-module-name [: parent-submodule-name]
2965 TUPLE_CLASS_BOILERPLATE(ParentIdentifier);
2966 std::tuple<Name, std::optional<Name>> t;
2967};
2968
2969// R1417 submodule-stmt -> SUBMODULE ( parent-identifier ) submodule-name
2971 TUPLE_CLASS_BOILERPLATE(SubmoduleStmt);
2972 std::tuple<ParentIdentifier, Name> t;
2973};
2974
2975// R1419 end-submodule-stmt -> END [SUBMODULE [submodule-name]]
2976WRAPPER_CLASS(EndSubmoduleStmt, std::optional<Name>);
2977
2978// R1416 submodule ->
2979// submodule-stmt [specification-part] [module-subprogram-part]
2980// end-submodule-stmt
2982 TUPLE_CLASS_BOILERPLATE(Submodule);
2983 std::tuple<Statement<SubmoduleStmt>, SpecificationPart,
2984 std::optional<ModuleSubprogramPart>, Statement<EndSubmoduleStmt>>
2985 t;
2986};
2987
2988// R1421 block-data-stmt -> BLOCK DATA [block-data-name]
2989WRAPPER_CLASS(BlockDataStmt, std::optional<Name>);
2990
2991// R1422 end-block-data-stmt -> END [BLOCK DATA [block-data-name]]
2992WRAPPER_CLASS(EndBlockDataStmt, std::optional<Name>);
2993
2994// R1420 block-data -> block-data-stmt [specification-part] end-block-data-stmt
2996 TUPLE_CLASS_BOILERPLATE(BlockData);
2997 std::tuple<Statement<BlockDataStmt>, SpecificationPart,
2999 t;
3000};
3001
3002// R1508 generic-spec ->
3003// generic-name | OPERATOR ( defined-operator ) |
3004// ASSIGNMENT ( = ) | defined-io-generic-spec
3005// R1509 defined-io-generic-spec ->
3006// READ ( FORMATTED ) | READ ( UNFORMATTED ) |
3007// WRITE ( FORMATTED ) | WRITE ( UNFORMATTED )
3009 UNION_CLASS_BOILERPLATE(GenericSpec);
3010 EMPTY_CLASS(Assignment);
3011 EMPTY_CLASS(ReadFormatted);
3012 EMPTY_CLASS(ReadUnformatted);
3013 EMPTY_CLASS(WriteFormatted);
3014 EMPTY_CLASS(WriteUnformatted);
3015 CharBlock source;
3016 std::variant<Name, DefinedOperator, Assignment, ReadFormatted,
3017 ReadUnformatted, WriteFormatted, WriteUnformatted>
3018 u;
3019};
3020
3021// R1510 generic-stmt ->
3022// GENERIC [, access-spec] :: generic-spec => specific-procedure-list
3024 TUPLE_CLASS_BOILERPLATE(GenericStmt);
3025 std::tuple<std::optional<AccessSpec>, GenericSpec, std::list<Name>> t;
3026};
3027
3028// R1503 interface-stmt -> INTERFACE [generic-spec] | ABSTRACT INTERFACE
3029struct InterfaceStmt {
3030 UNION_CLASS_BOILERPLATE(InterfaceStmt);
3031 // Workaround for clang with libstc++10 bug
3032 InterfaceStmt(Abstract x) : u{x} {}
3033
3034 std::variant<std::optional<GenericSpec>, Abstract> u;
3035};
3036
3037// R1412 only -> generic-spec | only-use-name | rename
3038// R1413 only-use-name -> use-name
3039struct Only {
3040 UNION_CLASS_BOILERPLATE(Only);
3041 std::variant<common::Indirection<GenericSpec>, Name, Rename> u;
3042};
3043
3044// R1409 use-stmt ->
3045// USE [[, module-nature] ::] module-name [, rename-list] |
3046// USE [[, module-nature] ::] module-name , ONLY : [only-list]
3047// R1410 module-nature -> INTRINSIC | NON_INTRINSIC
3048struct UseStmt {
3049 BOILERPLATE(UseStmt);
3050 ENUM_CLASS(ModuleNature, Intrinsic, Non_Intrinsic) // R1410
3051 template <typename A>
3052 UseStmt(std::optional<ModuleNature> &&nat, Name &&n, std::list<A> &&x)
3053 : nature(std::move(nat)), moduleName(std::move(n)), u(std::move(x)) {}
3054 std::optional<ModuleNature> nature;
3055 Name moduleName;
3056 std::variant<std::list<Rename>, std::list<Only>> u;
3057};
3058
3059// R1514 proc-attr-spec ->
3060// access-spec | proc-language-binding-spec | INTENT ( intent-spec ) |
3061// OPTIONAL | POINTER | PROTECTED | SAVE
3063 UNION_CLASS_BOILERPLATE(ProcAttrSpec);
3064 std::variant<AccessSpec, LanguageBindingSpec, IntentSpec, Optional, Pointer,
3065 Protected, Save>
3066 u;
3067};
3068
3069// R1512 procedure-declaration-stmt ->
3070// PROCEDURE ( [proc-interface] ) [[, proc-attr-spec]... ::]
3071// proc-decl-list
3073 TUPLE_CLASS_BOILERPLATE(ProcedureDeclarationStmt);
3074 std::tuple<std::optional<ProcInterface>, std::list<ProcAttrSpec>,
3075 std::list<ProcDecl>>
3076 t;
3077};
3078
3079// R1527 prefix-spec ->
3080// declaration-type-spec | ELEMENTAL | IMPURE | MODULE |
3081// NON_RECURSIVE | PURE | RECURSIVE |
3082// (CUDA) ATTRIBUTES ( (DEVICE | GLOBAL | GRID_GLOBAL | HOST)... )
3083// LAUNCH_BOUNDS(expr-list) | CLUSTER_DIMS(expr-list)
3085 UNION_CLASS_BOILERPLATE(PrefixSpec);
3086 EMPTY_CLASS(Elemental);
3087 EMPTY_CLASS(Impure);
3088 EMPTY_CLASS(Module);
3089 EMPTY_CLASS(Non_Recursive);
3090 EMPTY_CLASS(Pure);
3091 EMPTY_CLASS(Recursive);
3092 WRAPPER_CLASS(Attributes, std::list<common::CUDASubprogramAttrs>);
3093 WRAPPER_CLASS(Launch_Bounds, std::list<ScalarIntConstantExpr>);
3094 WRAPPER_CLASS(Cluster_Dims, std::list<ScalarIntConstantExpr>);
3095 std::variant<DeclarationTypeSpec, Elemental, Impure, Module, Non_Recursive,
3096 Pure, Recursive, Attributes, Launch_Bounds, Cluster_Dims>
3097 u;
3098};
3099
3100// R1532 suffix ->
3101// proc-language-binding-spec [RESULT ( result-name )] |
3102// RESULT ( result-name ) [proc-language-binding-spec]
3103struct Suffix {
3104 TUPLE_CLASS_BOILERPLATE(Suffix);
3105 Suffix(LanguageBindingSpec &&lbs, std::optional<Name> &&rn)
3106 : t(std::move(rn), std::move(lbs)) {}
3107 std::tuple<std::optional<Name>, std::optional<LanguageBindingSpec>> t;
3108};
3109
3110// R1530 function-stmt ->
3111// [prefix] FUNCTION function-name ( [dummy-arg-name-list] ) [suffix]
3112// R1526 prefix -> prefix-spec [prefix-spec]...
3113// R1531 dummy-arg-name -> name
3115 TUPLE_CLASS_BOILERPLATE(FunctionStmt);
3116 std::tuple<std::list<PrefixSpec>, Name, std::list<Name>,
3117 std::optional<Suffix>>
3118 t;
3119};
3120
3121// R1533 end-function-stmt -> END [FUNCTION [function-name]]
3122WRAPPER_CLASS(EndFunctionStmt, std::optional<Name>);
3123
3124// R1536 dummy-arg -> dummy-arg-name | *
3125struct DummyArg {
3126 UNION_CLASS_BOILERPLATE(DummyArg);
3127 std::variant<Name, Star> u;
3128};
3129
3130// R1535 subroutine-stmt ->
3131// [prefix] SUBROUTINE subroutine-name [( [dummy-arg-list] )
3132// [proc-language-binding-spec]]
3134 TUPLE_CLASS_BOILERPLATE(SubroutineStmt);
3135 std::tuple<std::list<PrefixSpec>, Name, std::list<DummyArg>,
3136 std::optional<LanguageBindingSpec>>
3137 t;
3138};
3139
3140// R1537 end-subroutine-stmt -> END [SUBROUTINE [subroutine-name]]
3141WRAPPER_CLASS(EndSubroutineStmt, std::optional<Name>);
3142
3143// R1505 interface-body ->
3144// function-stmt [specification-part] end-function-stmt |
3145// subroutine-stmt [specification-part] end-subroutine-stmt
3147 UNION_CLASS_BOILERPLATE(InterfaceBody);
3148 struct Function {
3149 TUPLE_CLASS_BOILERPLATE(Function);
3150 std::tuple<Statement<FunctionStmt>, common::Indirection<SpecificationPart>,
3152 t;
3153 };
3154 struct Subroutine {
3155 TUPLE_CLASS_BOILERPLATE(Subroutine);
3156 std::tuple<Statement<SubroutineStmt>,
3158 t;
3159 };
3160 std::variant<Function, Subroutine> u;
3161};
3162
3163// R1506 procedure-stmt -> [MODULE] PROCEDURE [::] specific-procedure-list
3165 ENUM_CLASS(Kind, ModuleProcedure, Procedure)
3166 TUPLE_CLASS_BOILERPLATE(ProcedureStmt);
3167 std::tuple<Kind, std::list<Name>> t;
3168};
3169
3170// R1502 interface-specification -> interface-body | procedure-stmt
3172 UNION_CLASS_BOILERPLATE(InterfaceSpecification);
3173 std::variant<InterfaceBody, Statement<ProcedureStmt>> u;
3174};
3175
3176// R1504 end-interface-stmt -> END INTERFACE [generic-spec]
3177WRAPPER_CLASS(EndInterfaceStmt, std::optional<GenericSpec>);
3178
3179// R1501 interface-block ->
3180// interface-stmt [interface-specification]... end-interface-stmt
3182 TUPLE_CLASS_BOILERPLATE(InterfaceBlock);
3183 std::tuple<Statement<InterfaceStmt>, std::list<InterfaceSpecification>,
3185 t;
3186};
3187
3188// R1511 external-stmt -> EXTERNAL [::] external-name-list
3189WRAPPER_CLASS(ExternalStmt, std::list<Name>);
3190
3191// R1519 intrinsic-stmt -> INTRINSIC [::] intrinsic-procedure-name-list
3192WRAPPER_CLASS(IntrinsicStmt, std::list<Name>);
3193
3194// R1522 procedure-designator ->
3195// procedure-name | proc-component-ref | data-ref % binding-name
3197 UNION_CLASS_BOILERPLATE(ProcedureDesignator);
3198 std::variant<Name, ProcComponentRef> u;
3199};
3200
3201// R1525 alt-return-spec -> * label
3202WRAPPER_CLASS(AltReturnSpec, Label);
3203
3204// R1524 actual-arg ->
3205// expr | variable | procedure-name | proc-component-ref |
3206// alt-return-spec
3207struct ActualArg {
3208 WRAPPER_CLASS(PercentRef, Expr); // %REF(x) extension
3209 WRAPPER_CLASS(PercentVal, Expr); // %VAL(x) extension
3210 UNION_CLASS_BOILERPLATE(ActualArg);
3211 ActualArg(Expr &&x) : u{common::Indirection<Expr>(std::move(x))} {}
3212 std::variant<common::Indirection<Expr>, AltReturnSpec, PercentRef, PercentVal>
3213 u;
3214};
3215
3216// R1523 actual-arg-spec -> [keyword =] actual-arg
3218 TUPLE_CLASS_BOILERPLATE(ActualArgSpec);
3219 std::tuple<std::optional<Keyword>, ActualArg> t;
3220};
3221
3222// R1520 function-reference -> procedure-designator
3223// ( [actual-arg-spec-list] )
3224struct Call {
3225 TUPLE_CLASS_BOILERPLATE(Call);
3226 std::tuple<ProcedureDesignator, std::list<ActualArgSpec>> t;
3227};
3228
3230 WRAPPER_CLASS_BOILERPLATE(FunctionReference, Call);
3231 CharBlock source;
3232 Designator ConvertToArrayElementRef();
3233 StructureConstructor ConvertToStructureConstructor(
3235};
3236
3237// R1521 call-stmt -> CALL procedure-designator [ chevrons ]
3238// [( [actual-arg-spec-list] )]
3239// (CUDA) chevrons -> <<< * | scalar-expr, scalar-expr [,
3240// scalar-expr [, scalar-int-expr ] ] >>>
3241struct CallStmt {
3242 TUPLE_CLASS_BOILERPLATE(CallStmt);
3243 WRAPPER_CLASS(StarOrExpr, std::optional<ScalarExpr>);
3244 struct Chevrons {
3245 TUPLE_CLASS_BOILERPLATE(Chevrons);
3246 std::tuple<StarOrExpr, ScalarExpr, std::optional<ScalarExpr>,
3247 std::optional<ScalarIntExpr>>
3248 t;
3249 };
3250 explicit CallStmt(ProcedureDesignator &&pd, std::optional<Chevrons> &&ch,
3251 std::list<ActualArgSpec> &&args)
3252 : CallStmt(Call{std::move(pd), std::move(args)}, std::move(ch)) {}
3253 std::tuple<Call, std::optional<Chevrons>> t;
3254 CharBlock source;
3255 mutable TypedCall typedCall; // filled by semantics
3256};
3257
3258// R1529 function-subprogram ->
3259// function-stmt [specification-part] [execution-part]
3260// [internal-subprogram-part] end-function-stmt
3262 TUPLE_CLASS_BOILERPLATE(FunctionSubprogram);
3263 std::tuple<Statement<FunctionStmt>, SpecificationPart, ExecutionPart,
3264 std::optional<InternalSubprogramPart>, Statement<EndFunctionStmt>>
3265 t;
3266};
3267
3268// R1534 subroutine-subprogram ->
3269// subroutine-stmt [specification-part] [execution-part]
3270// [internal-subprogram-part] end-subroutine-stmt
3272 TUPLE_CLASS_BOILERPLATE(SubroutineSubprogram);
3273 std::tuple<Statement<SubroutineStmt>, SpecificationPart, ExecutionPart,
3274 std::optional<InternalSubprogramPart>, Statement<EndSubroutineStmt>>
3275 t;
3276};
3277
3278// R1539 mp-subprogram-stmt -> MODULE PROCEDURE procedure-name
3279WRAPPER_CLASS(MpSubprogramStmt, Name);
3280
3281// R1540 end-mp-subprogram-stmt -> END [PROCEDURE [procedure-name]]
3282WRAPPER_CLASS(EndMpSubprogramStmt, std::optional<Name>);
3283
3284// R1538 separate-module-subprogram ->
3285// mp-subprogram-stmt [specification-part] [execution-part]
3286// [internal-subprogram-part] end-mp-subprogram-stmt
3288 TUPLE_CLASS_BOILERPLATE(SeparateModuleSubprogram);
3289 std::tuple<Statement<MpSubprogramStmt>, SpecificationPart, ExecutionPart,
3290 std::optional<InternalSubprogramPart>, Statement<EndMpSubprogramStmt>>
3291 t;
3292};
3293
3294// R1541 entry-stmt -> ENTRY entry-name [( [dummy-arg-list] ) [suffix]]
3296 TUPLE_CLASS_BOILERPLATE(EntryStmt);
3297 std::tuple<Name, std::list<DummyArg>, std::optional<Suffix>> t;
3298};
3299
3300// R1542 return-stmt -> RETURN [scalar-int-expr]
3301WRAPPER_CLASS(ReturnStmt, std::optional<ScalarIntExpr>);
3302
3303// R1544 stmt-function-stmt ->
3304// function-name ( [dummy-arg-name-list] ) = scalar-expr
3306 TUPLE_CLASS_BOILERPLATE(StmtFunctionStmt);
3307 std::tuple<Name, std::list<Name>, Scalar<Expr>> t;
3308 Statement<ActionStmt> ConvertToAssignment();
3309};
3310
3311// Compiler directives
3312// !DIR$ IGNORE_TKR [ [(tkrdmac...)] name ]...
3313// !DIR$ LOOP COUNT (n1[, n2]...)
3314// !DIR$ name[=value] [, name[=value]]... = can be :
3315// !DIR$ UNROLL [N]
3316// !DIR$ UNROLL_AND_JAM [N]
3317// !DIR$ NOVECTOR
3318// !DIR$ NOUNROLL
3319// !DIR$ NOUNROLL_AND_JAM
3320// !DIR$ PREFETCH designator[, designator]...
3321// !DIR$ FORCEINLINE
3322// !DIR$ INLINE
3323// !DIR$ NOINLINE
3324// !DIR$ IVDEP
3325// !DIR$ <anything else>
3327 UNION_CLASS_BOILERPLATE(CompilerDirective);
3328 struct IgnoreTKR {
3329 TUPLE_CLASS_BOILERPLATE(IgnoreTKR);
3330 std::tuple<std::optional<std::list<const char *>>, Name> t;
3331 };
3332 struct LoopCount {
3333 WRAPPER_CLASS_BOILERPLATE(LoopCount, std::list<std::uint64_t>);
3334 };
3336 TUPLE_CLASS_BOILERPLATE(AssumeAligned);
3337 std::tuple<common::Indirection<Designator>, uint64_t> t;
3338 };
3339 EMPTY_CLASS(VectorAlways);
3341 TUPLE_CLASS_BOILERPLATE(VectorLength);
3342 ENUM_CLASS(Kind, Auto, Fixed, Scalable);
3343
3344 std::tuple<std::uint64_t, Kind> t;
3345 };
3346 struct NameValue {
3347 TUPLE_CLASS_BOILERPLATE(NameValue);
3348 std::tuple<Name, std::optional<std::uint64_t>> t;
3349 };
3350 struct Unroll {
3351 WRAPPER_CLASS_BOILERPLATE(Unroll, std::optional<std::uint64_t>);
3352 };
3354 WRAPPER_CLASS_BOILERPLATE(UnrollAndJam, std::optional<std::uint64_t>);
3355 };
3356 struct Prefetch {
3357 WRAPPER_CLASS_BOILERPLATE(
3359 };
3360 EMPTY_CLASS(NoVector);
3361 EMPTY_CLASS(NoUnroll);
3362 EMPTY_CLASS(NoUnrollAndJam);
3363 EMPTY_CLASS(ForceInline);
3364 EMPTY_CLASS(Inline);
3365 EMPTY_CLASS(NoInline);
3366 EMPTY_CLASS(IVDep);
3367 EMPTY_CLASS(Unrecognized);
3368 CharBlock source;
3369 std::variant<std::list<IgnoreTKR>, LoopCount, std::list<AssumeAligned>,
3370 VectorAlways, VectorLength, std::list<NameValue>, Unroll, UnrollAndJam,
3371 Unrecognized, NoVector, NoUnroll, NoUnrollAndJam, ForceInline, Inline,
3372 NoInline, Prefetch, IVDep>
3373 u;
3374};
3375
3376// (CUDA) ATTRIBUTE(attribute) [::] name-list
3378 TUPLE_CLASS_BOILERPLATE(CUDAAttributesStmt);
3379 std::tuple<common::CUDADataAttr, std::list<Name>> t;
3380};
3381
3382// Legacy extensions
3384 TUPLE_CLASS_BOILERPLATE(BasedPointer);
3385 std::tuple<ObjectName, ObjectName, std::optional<ArraySpec>> t;
3386};
3387WRAPPER_CLASS(BasedPointerStmt, std::list<BasedPointer>);
3388
3389struct Union;
3390struct StructureDef;
3391
3393 UNION_CLASS_BOILERPLATE(StructureField);
3394 std::variant<Statement<DataComponentDefStmt>,
3396 u;
3397};
3398
3399struct Map {
3400 EMPTY_CLASS(MapStmt);
3401 EMPTY_CLASS(EndMapStmt);
3402 TUPLE_CLASS_BOILERPLATE(Map);
3403 std::tuple<Statement<MapStmt>, std::list<StructureField>,
3405 t;
3406};
3407
3408struct Union {
3409 EMPTY_CLASS(UnionStmt);
3410 EMPTY_CLASS(EndUnionStmt);
3411 TUPLE_CLASS_BOILERPLATE(Union);
3412 std::tuple<Statement<UnionStmt>, std::list<Map>, Statement<EndUnionStmt>> t;
3413};
3414
3416 TUPLE_CLASS_BOILERPLATE(StructureStmt);
3417 std::tuple<std::optional<Name>, std::list<EntityDecl>> t;
3418};
3419
3421 EMPTY_CLASS(EndStructureStmt);
3422 TUPLE_CLASS_BOILERPLATE(StructureDef);
3423 std::tuple<Statement<StructureStmt>, std::list<StructureField>,
3425 t;
3426};
3427
3428// Old style PARAMETER statement without parentheses.
3429// Types are determined entirely from the right-hand sides, not the names.
3430WRAPPER_CLASS(OldParameterStmt, std::list<NamedConstantDef>);
3431
3432// Deprecations
3434 TUPLE_CLASS_BOILERPLATE(ArithmeticIfStmt);
3435 std::tuple<Expr, Label, Label, Label> t;
3436};
3437
3439 TUPLE_CLASS_BOILERPLATE(AssignStmt);
3440 std::tuple<Label, Name> t;
3441};
3442
3444 TUPLE_CLASS_BOILERPLATE(AssignedGotoStmt);
3445 std::tuple<Name, std::list<Label>> t;
3446};
3447
3448WRAPPER_CLASS(PauseStmt, std::optional<StopCode>);
3449
3450// Parse tree nodes for OpenMP directives and clauses
3451
3452// --- Common definitions
3453
3454#define INHERITED_TUPLE_CLASS_BOILERPLATE(classname, basename) \
3455 using basename::basename; \
3456 classname(basename &&b) : basename(std::move(b)) {} \
3457 using TupleTrait = std::true_type; \
3458 BOILERPLATE(classname)
3459
3460#define INHERITED_WRAPPER_CLASS_BOILERPLATE(classname, basename) \
3461 BOILERPLATE(classname); \
3462 using basename::basename; \
3463 classname(basename &&base) : basename(std::move(base)) {} \
3464 using WrapperTrait = std::true_type
3465
3466struct OmpClause;
3468
3469struct OmpDirectiveName {
3470 // No boilerplates: this class should be copyable, movable, etc.
3471 constexpr OmpDirectiveName() = default;
3472 constexpr OmpDirectiveName(const OmpDirectiveName &) = default;
3473 constexpr OmpDirectiveName(llvm::omp::Directive x) : v(x) {}
3474 // Construct from an already parsed text. Use Verbatim for this because
3475 // Verbatim's source corresponds to an actual source location.
3476 // This allows "construct<OmpDirectiveName>(Verbatim("<name>"))".
3477 OmpDirectiveName(const Verbatim &name);
3478 using WrapperTrait = std::true_type;
3479
3480 bool IsExecutionPart() const; // Is allowed in the execution part
3481
3482 CharBlock source;
3483 llvm::omp::Directive v{llvm::omp::Directive::OMPD_unknown};
3484};
3485
3486// type-name list item
3488 CharBlock source;
3489 mutable const semantics::DeclTypeSpec *declTypeSpec{nullptr};
3490 UNION_CLASS_BOILERPLATE(OmpTypeName);
3491 std::variant<TypeSpec, DeclarationTypeSpec> u;
3492};
3493
3495 WRAPPER_CLASS_BOILERPLATE(OmpTypeNameList, std::list<OmpTypeName>);
3496};
3497
3498// 2.1 Directives or clauses may accept a list or extended-list.
3499// A list item is a variable, array section or common block name (enclosed
3500// in slashes). An extended list item is a list item or a procedure Name.
3501// variable-name | / common-block / | array-sections
3503 // Blank common blocks are not valid objects. Parse them to emit meaningful
3504 // diagnostics.
3505 struct Invalid {
3506 ENUM_CLASS(Kind, BlankCommonBlock);
3507 WRAPPER_CLASS_BOILERPLATE(Invalid, Kind);
3508 CharBlock source;
3509 };
3510 UNION_CLASS_BOILERPLATE(OmpObject);
3511 std::variant<Designator, /*common block*/ Name, Invalid> u;
3512};
3513
3515 WRAPPER_CLASS_BOILERPLATE(OmpObjectList, std::list<OmpObject>);
3516};
3517
3519 COPY_AND_ASSIGN_BOILERPLATE(OmpStylizedDeclaration);
3520 // Since "Reference" isn't handled by parse-tree-visitor, add EmptyTrait,
3521 // and visit the members by hand when needed.
3522 using EmptyTrait = std::true_type;
3524 EntityDecl var;
3525};
3526
3528 struct Instance {
3529 UNION_CLASS_BOILERPLATE(Instance);
3530 std::variant<AssignmentStmt, CallStmt, common::Indirection<Expr>> u;
3531 };
3532 TUPLE_CLASS_BOILERPLATE(OmpStylizedInstance);
3533 std::tuple<std::list<OmpStylizedDeclaration>, Instance> t;
3534};
3535
3536class ParseState;
3537
3538// Ref: [5.2:76], [6.0:185]
3539//
3541 CharBlock source;
3542 // Pointer to a temporary copy of the ParseState that is used to create
3543 // additional parse subtrees for the stylized expression. This is only
3544 // used internally during parsing and conveys no information to the
3545 // consumers of the AST.
3546 const ParseState *state{nullptr};
3547 WRAPPER_CLASS_BOILERPLATE(
3548 OmpStylizedExpression, std::list<OmpStylizedInstance>);
3549};
3550
3551// Ref: [4.5:201-207], [5.0:293-299], [5.1:325-331], [5.2:124]
3552//
3553// reduction-identifier ->
3554// base-language-identifier | // since 4.5
3555// - | // since 4.5, until 5.2
3556// + | * | .AND. | .OR. | .EQV. | .NEQV. | // since 4.5
3557// MIN | MAX | IAND | IOR | IEOR // since 4.5
3559 UNION_CLASS_BOILERPLATE(OmpReductionIdentifier);
3560 std::variant<DefinedOperator, ProcedureDesignator> u;
3561};
3562
3563// Ref: [4.5:222:6], [5.0:305:27], [5.1:337:19], [5.2:126:3-4], [6.0:240:27-28]
3564//
3565// combiner-expression -> // since 4.5
3566// assignment-statement |
3567// function-reference
3569 INHERITED_WRAPPER_CLASS_BOILERPLATE(
3571 static llvm::ArrayRef<CharBlock> Variables();
3572};
3573
3574// Ref: [4.5:222:7-8], [5.0:305:28-29], [5.1:337:20-21], [5.2:127:6-8],
3575// [6.0:242:3-5]
3576//
3577// initializer-expression -> // since 4.5
3578// OMP_PRIV = expression |
3579// subroutine-name(argument-list)
3581 INHERITED_WRAPPER_CLASS_BOILERPLATE(
3583 static llvm::ArrayRef<CharBlock> Variables();
3584};
3585
3586inline namespace arguments {
3588 UNION_CLASS_BOILERPLATE(OmpLocator);
3589 std::variant<OmpObject, FunctionReference> u;
3590};
3591
3593 WRAPPER_CLASS_BOILERPLATE(OmpLocatorList, std::list<OmpLocator>);
3594};
3595
3596// Ref: [4.5:58-60], [5.0:58-60], [5.1:63-68], [5.2:197-198], [6.0:334-336]
3597//
3598// Argument to DECLARE VARIANT with the base-name present. (When only
3599// variant-name is present, it is a simple OmpObject).
3600//
3601// base-name-variant-name -> // since 4.5
3602// base-name : variant-name
3604 TUPLE_CLASS_BOILERPLATE(OmpBaseVariantNames);
3605 std::tuple<OmpObject, OmpObject> t;
3606};
3607
3608// Ref: [5.0:326:10-16], [5.1:359:5-11], [5.2:163:2-7], [6.0:293:16-21]
3609//
3610// mapper-specifier ->
3611// [mapper-identifier :] type :: var | // since 5.0
3612// DEFAULT type :: var
3614 // Absent mapper-identifier is equivalent to DEFAULT.
3615 TUPLE_CLASS_BOILERPLATE(OmpMapperSpecifier);
3616 std::tuple<std::string, TypeSpec, Name> t;
3617};
3618
3619// Ref: [4.5:222:1-5], [5.0:305:20-27], [5.1:337:11-19], [5.2:139:18-23],
3620// [6.0:260:16-20]
3621//
3622// reduction-specifier ->
3623// reduction-identifier : typename-list
3624// : combiner-expression // since 4.5, until 5.2
3625// reduction-identifier : typename-list // since 6.0
3627 TUPLE_CLASS_BOILERPLATE(OmpReductionSpecifier);
3629 std::optional<OmpCombinerExpression>>
3630 t;
3631};
3632
3634 CharBlock source;
3635 UNION_CLASS_BOILERPLATE(OmpArgument);
3636 std::variant<OmpLocator, // {variable, extended, locator}-list-item
3637 OmpBaseVariantNames, // base-name:variant-name
3639 u;
3640};
3641
3643 WRAPPER_CLASS_BOILERPLATE(OmpArgumentList, std::list<OmpArgument>);
3644 CharBlock source;
3645};
3646} // namespace arguments
3647
3648inline namespace traits {
3649// trait-property-name ->
3650// identifier | string-literal
3651//
3652// This is a bit of a problematic case. The spec says that a word in quotes,
3653// and the same word without quotes are equivalent. We currently parse both
3654// as a string, but it's likely just a temporary solution.
3655//
3656// The problem is that trait-property can be (among other things) a
3657// trait-property-name or a trait-property-expression. A simple identifier
3658// can be either, there is no reasonably simple way of telling them apart
3659// in the parser. There is a similar issue with extensions. Some of that
3660// disambiguation may need to be done in the "canonicalization" pass and
3661// then some of those AST nodes would be rewritten into different ones.
3662//
3664 CharBlock source;
3665 WRAPPER_CLASS_BOILERPLATE(OmpTraitPropertyName, std::string);
3666};
3667
3668// trait-score ->
3669// SCORE(non-negative-const-integer-expression)
3671 CharBlock source;
3672 WRAPPER_CLASS_BOILERPLATE(OmpTraitScore, ScalarIntExpr);
3673};
3674
3675// trait-property-extension ->
3676// trait-property-name |
3677// scalar-expr |
3678// trait-property-name (trait-property-extension, ...)
3679//
3681 CharBlock source;
3682 UNION_CLASS_BOILERPLATE(OmpTraitPropertyExtension);
3683 struct Complex { // name (prop-ext, prop-ext, ...)
3684 CharBlock source;
3685 TUPLE_CLASS_BOILERPLATE(Complex);
3686 std::tuple<OmpTraitPropertyName,
3687 std::list<common::Indirection<OmpTraitPropertyExtension>>>
3688 t;
3689 };
3690
3691 std::variant<OmpTraitPropertyName, ScalarExpr, Complex> u;
3692};
3693
3694// trait-property ->
3695// trait-property-name | OmpClause |
3696// trait-property-expression | trait-property-extension
3697// trait-property-expression ->
3698// scalar-logical-expression | scalar-integer-expression
3699//
3700// The parser for a logical expression will accept an integer expression,
3701// and if it's not logical, it will flag an error later. The same thing
3702// will happen if the scalar integer expression sees a logical expresion.
3703// To avoid this, parse all expressions as scalar expressions.
3705 CharBlock source;
3706 UNION_CLASS_BOILERPLATE(OmpTraitProperty);
3707 std::variant<OmpTraitPropertyName, common::Indirection<OmpClause>,
3708 ScalarExpr, // trait-property-expresion
3710 u;
3711};
3712
3713// trait-selector-name ->
3714// KIND | DT // name-list (host, nohost, +/add-def-doc)
3715// ISA | DT // name-list (isa_name, ... /impl-defined)
3716// ARCH | DT // name-list (arch_name, ... /impl-defined)
3717// directive-name | C // no properties
3718// SIMD | C // clause-list (from declare_simd)
3719// // (at least simdlen, inbranch/notinbranch)
3720// DEVICE_NUM | T // device-number
3721// UID | T // unique-string-id /impl-defined
3722// VENDOR | I // name-list (vendor-id /add-def-doc)
3723// EXTENSION | I // name-list (ext_name /impl-defined)
3724// ATOMIC_DEFAULT_MEM_ORDER I | // clause-list (value of admo)
3725// REQUIRES | I // clause-list (from requires)
3726// CONDITION U // logical-expr
3727// <other name> I // treated as extension
3728//
3729// Trait-set-selectors:
3730// [D]evice, [T]arget_device, [C]onstruct, [I]mplementation, [U]ser.
3732 std::string ToString() const;
3733 CharBlock source;
3734 UNION_CLASS_BOILERPLATE(OmpTraitSelectorName);
3735 ENUM_CLASS(Value, Arch, Atomic_Default_Mem_Order, Condition, Device_Num,
3736 Extension, Isa, Kind, Requires, Simd, Uid, Vendor)
3737 std::variant<Value, llvm::omp::Directive, std::string> u;
3738};
3739
3740// trait-selector ->
3741// trait-selector-name |
3742// trait-selector-name ([trait-score:] trait-property, ...)
3744 CharBlock source;
3745 TUPLE_CLASS_BOILERPLATE(OmpTraitSelector);
3746 struct Properties {
3747 TUPLE_CLASS_BOILERPLATE(Properties);
3748 std::tuple<std::optional<OmpTraitScore>, std::list<OmpTraitProperty>> t;
3749 };
3750 std::tuple<OmpTraitSelectorName, std::optional<Properties>> t;
3751};
3752
3753// trait-set-selector-name ->
3754// CONSTRUCT | DEVICE | IMPLEMENTATION | USER | // since 5.0
3755// TARGET_DEVICE // since 5.1
3757 std::string ToString() const;
3758 CharBlock source;
3759 ENUM_CLASS(Value, Construct, Device, Implementation, Target_Device, User)
3760 WRAPPER_CLASS_BOILERPLATE(OmpTraitSetSelectorName, Value);
3761};
3762
3763// trait-set-selector ->
3764// trait-set-selector-name = {trait-selector, ...}
3766 CharBlock source;
3767 TUPLE_CLASS_BOILERPLATE(OmpTraitSetSelector);
3768 std::tuple<OmpTraitSetSelectorName, std::list<OmpTraitSelector>> t;
3769};
3770
3771// context-selector-specification ->
3772// trait-set-selector, ...
3774 CharBlock source;
3775 WRAPPER_CLASS_BOILERPLATE(
3776 OmpContextSelectorSpecification, std::list<OmpTraitSetSelector>);
3777};
3778} // namespace traits
3779
3780#define MODIFIER_BOILERPLATE(...) \
3781 struct Modifier { \
3782 using Variant = std::variant<__VA_ARGS__>; \
3783 UNION_CLASS_BOILERPLATE(Modifier); \
3784 CharBlock source; \
3785 Variant u; \
3786 }
3787
3788#define MODIFIERS() std::optional<std::list<Modifier>>
3789
3790inline namespace modifier {
3791// For uniformity, in all keyword modifiers the name of the type defined
3792// by ENUM_CLASS is "Value", e.g.
3793// struct Foo {
3794// ENUM_CLASS(Value, Keyword1, Keyword2);
3795// };
3796
3798 ENUM_CLASS(Value, Cgroup);
3799 WRAPPER_CLASS_BOILERPLATE(OmpAccessGroup, Value);
3800};
3801
3802// Ref: [4.5:72-81], [5.0:110-119], [5.1:134-143], [5.2:169-170]
3803//
3804// alignment ->
3805// scalar-integer-expression // since 4.5
3807 WRAPPER_CLASS_BOILERPLATE(OmpAlignment, ScalarIntExpr);
3808};
3809
3810// Ref: [5.1:184-185], [5.2:178-179]
3811//
3812// align-modifier ->
3813// ALIGN(alignment) // since 5.1
3815 WRAPPER_CLASS_BOILERPLATE(OmpAlignModifier, ScalarIntExpr);
3816};
3817
3818// Ref: [5.0:158-159], [5.1:184-185], [5.2:178-179]
3819//
3820// allocator-simple-modifier ->
3821// allocator // since 5.0
3823 WRAPPER_CLASS_BOILERPLATE(OmpAllocatorSimpleModifier, ScalarIntExpr);
3824};
3825
3826// Ref: [5.1:184-185], [5.2:178-179]
3827//
3828// allocator-complex-modifier ->
3829// ALLOCATOR(allocator) // since 5.1
3831 WRAPPER_CLASS_BOILERPLATE(OmpAllocatorComplexModifier, ScalarIntExpr);
3832};
3833
3834// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
3835// [6.0:279-288]
3836//
3837// always-modifier ->
3838// ALWAYS // since 4.5
3839//
3840// Until 5.2, it was a part of map-type-modifier. Since 6.0 the
3841// map-type-modifier has been split into individual modifiers.
3843 ENUM_CLASS(Value, Always)
3844 WRAPPER_CLASS_BOILERPLATE(OmpAlwaysModifier, Value);
3845};
3846
3847// Ref: [coming in 6.1]
3848//
3849// attach-modifier ->
3850// ATTACH(attachment-mode) // since 6.1
3851//
3852// attachment-mode ->
3853// ALWAYS | AUTO | NEVER
3855 ENUM_CLASS(Value, Always, Never, Auto)
3856 WRAPPER_CLASS_BOILERPLATE(OmpAttachModifier, Value);
3857};
3858
3859// Ref: [6.0:289-290]
3860//
3861// automap-modifier ->
3862// automap // since 6.0
3863//
3865 ENUM_CLASS(Value, Automap);
3866 WRAPPER_CLASS_BOILERPLATE(OmpAutomapModifier, Value);
3867};
3868
3869// Ref: [5.2:252-254]
3870//
3871// chunk-modifier ->
3872// SIMD // since 5.2
3873//
3874// Prior to 5.2 "chunk-modifier" was a part of "modifier" on SCHEDULE clause.
3876 ENUM_CLASS(Value, Simd)
3877 WRAPPER_CLASS_BOILERPLATE(OmpChunkModifier, Value);
3878};
3879
3880// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
3881// [6.0:279-288]
3882//
3883// close-modifier ->
3884// CLOSE // since 5.0
3885//
3886// Until 5.2, it was a part of map-type-modifier. Since 6.0 the
3887// map-type-modifier has been split into individual modifiers.
3889 ENUM_CLASS(Value, Close)
3890 WRAPPER_CLASS_BOILERPLATE(OmpCloseModifier, Value);
3891};
3892
3893// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
3894// [6.0:279-288]
3895//
3896// delete-modifier ->
3897// DELETE // since 6.0
3898//
3899// Until 5.2, it was a part of map-type.
3901 ENUM_CLASS(Value, Delete)
3902 WRAPPER_CLASS_BOILERPLATE(OmpDeleteModifier, Value);
3903};
3904
3905// Ref: [4.5:169-170], [5.0:255-256], [5.1:288-289]
3906//
3907// dependence-type ->
3908// SINK | SOURCE | // since 4.5
3909// IN | OUT | INOUT | // since 4.5, until 5.1
3910// MUTEXINOUTSET | DEPOBJ | // since 5.0, until 5.1
3911// INOUTSET // since 5.1, until 5.1
3912//
3913// All of these, except SINK and SOURCE became task-dependence-type in 5.2.
3914//
3915// Keeping these two as separate types, since having them all together
3916// creates conflicts when parsing the DEPEND clause. For DEPEND(SINK: ...),
3917// the SINK may be parsed as 'task-dependence-type', and the list after
3918// the ':' would then be parsed as OmpObjectList (instead of the iteration
3919// vector). This would accept the vector "i, j, k" (although interpreted
3920// incorrectly), while flagging a syntax error for "i+1, j, k".
3922 ENUM_CLASS(Value, Sink, Source);
3923 WRAPPER_CLASS_BOILERPLATE(OmpDependenceType, Value);
3924};
3925
3926// Ref: [6.0:180-181]
3927//
3928// depinfo-modifier -> // since 6.0
3929// keyword (locator-list-item)
3930// keyword ->
3931// IN | INOUT | INOUTSET | MUTEXINOUTSET | OUT // since 6.0
3933 using Value = common::OmpDependenceKind;
3934 TUPLE_CLASS_BOILERPLATE(OmpDepinfoModifier);
3935 std::tuple<Value, OmpObject> t;
3936};
3937
3938// Ref: [5.0:170-176], [5.1:197-205], [5.2:276-277]
3939//
3940// device-modifier ->
3941// ANCESTOR | DEVICE_NUM // since 5.0
3943 ENUM_CLASS(Value, Ancestor, Device_Num)
3944 WRAPPER_CLASS_BOILERPLATE(OmpDeviceModifier, Value);
3945};
3946
3947// Ref: TODO
3948//
3949// dims-modifier ->
3950// constant integer expression // since 6.1
3952 WRAPPER_CLASS_BOILERPLATE(OmpDimsModifier, ScalarIntConstantExpr);
3953};
3954
3955// Ref: [5.2:72-73,230-323], in 4.5-5.1 it's scattered over individual
3956// directives that allow the IF clause.
3957//
3958// directive-name-modifier ->
3959// PARALLEL | TARGET | TARGET DATA |
3960// TARGET ENTER DATA | TARGET EXIT DATA |
3961// TARGET UPDATE | TASK | TASKLOOP | // since 4.5
3962// CANCEL[*] | SIMD | // since 5.0
3963// TEAMS // since 5.2
3964//
3965// [*] The IF clause is allowed on CANCEL in OpenMP 4.5, but only without
3966// the directive-name-modifier. For the sake of uniformity CANCEL can be
3967// considered a valid value in 4.5 as well.
3968struct OmpDirectiveNameModifier : public OmpDirectiveName {
3969 INHERITED_WRAPPER_CLASS_BOILERPLATE(
3970 OmpDirectiveNameModifier, OmpDirectiveName);
3971};
3972
3973// Ref: [5.1:205-209], [5.2:166-168]
3974//
3975// motion-modifier ->
3976// PRESENT | // since 5.0, until 5.0
3977// mapper | iterator
3978// expectation ->
3979// PRESENT // since 5.1
3980//
3981// The PRESENT value was a part of motion-modifier in 5.1, and became a
3982// value of expectation in 5.2.
3984 ENUM_CLASS(Value, Present);
3985 WRAPPER_CLASS_BOILERPLATE(OmpExpectation, Value);
3986};
3987
3988// Ref: [6.1:tbd]
3989//
3990// fallback-modifier ->
3991// FALLBACK(fallback-mode) // since 6.1
3992// fallback-mode ->
3993// ABORT | DEFAULT_MEM | NULL // since 6.1
3995 ENUM_CLASS(Value, Abort, Default_Mem, Null);
3996 WRAPPER_CLASS_BOILERPLATE(OmpFallbackModifier, Value);
3997};
3998
3999// REF: [5.1:217-220], [5.2:293-294], [6.0:470-471]
4000//
4001// interop-type -> // since 5.1
4002// TARGET |
4003// TARGETSYNC
4004// There can be at most only two interop-type.
4006 ENUM_CLASS(Value, Target, Targetsync)
4007 WRAPPER_CLASS_BOILERPLATE(OmpInteropType, Value);
4008};
4009
4010// Ref: [5.0:47-49], [5.1:49-51], [5.2:67-69]
4011//
4012// iterator-specifier ->
4013// [iterator-type] iterator-identifier
4014// = range-specification | // since 5.0
4015// [iterator-type ::] iterator-identifier
4016// = range-specification // since 5.2
4018 TUPLE_CLASS_BOILERPLATE(OmpIteratorSpecifier);
4019 CharBlock source;
4020 std::tuple<TypeDeclarationStmt, SubscriptTriplet> t;
4021};
4022
4023// Ref: [5.0:47-49], [5.1:49-51], [5.2:67-69]
4024//
4025// iterator-modifier ->
4026// ITERATOR(iterator-specifier [, ...]) // since 5.0
4028 WRAPPER_CLASS_BOILERPLATE(OmpIterator, std::list<OmpIteratorSpecifier>);
4029};
4030
4031// Ref: [5.0:288-290], [5.1:321-322], [5.2:115-117]
4032//
4033// lastprivate-modifier ->
4034// CONDITIONAL // since 5.0
4036 ENUM_CLASS(Value, Conditional)
4037 WRAPPER_CLASS_BOILERPLATE(OmpLastprivateModifier, Value);
4038};
4039
4040// Ref: [4.5:207-210], [5.0:290-293], [5.1:323-325], [5.2:117-120]
4041//
4042// linear-modifier ->
4043// REF | UVAL | VAL // since 4.5
4045 ENUM_CLASS(Value, Ref, Uval, Val);
4046 WRAPPER_CLASS_BOILERPLATE(OmpLinearModifier, Value);
4047};
4048
4049// Ref: [5.1:100-104], [5.2:277], [6.0:452-453]
4050//
4051// lower-bound ->
4052// scalar-integer-expression // since 5.1
4054 WRAPPER_CLASS_BOILERPLATE(OmpLowerBound, ScalarIntExpr);
4055};
4056
4057// Ref: [5.0:176-180], [5.1:205-210], [5.2:149-150]
4058//
4059// mapper ->
4060// identifier // since 4.5
4062 WRAPPER_CLASS_BOILERPLATE(OmpMapper, Name);
4063};
4064
4065// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
4066// [6.0:279-288]
4067//
4068// map-type ->
4069// ALLOC | DELETE | RELEASE | // since 4.5, until 5.2
4070// FROM | TO | TOFROM | // since 4.5
4071// STORAGE // since 6.0
4072//
4073// Since 6.0 DELETE is a separate delete-modifier.
4075 ENUM_CLASS(Value, Alloc, Delete, From, Release, Storage, To, Tofrom);
4076 WRAPPER_CLASS_BOILERPLATE(OmpMapType, Value);
4077};
4078
4079// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158]
4080//
4081// map-type-modifier ->
4082// ALWAYS | // since 4.5, until 5.2
4083// CLOSE | // since 5.0, until 5.2
4084// PRESENT // since 5.1, until 5.2
4085// Since 6.0 the map-type-modifier has been split into individual modifiers.
4086//
4088 ENUM_CLASS(Value, Always, Close, Present, Ompx_Hold)
4089 WRAPPER_CLASS_BOILERPLATE(OmpMapTypeModifier, Value);
4090};
4091
4092// Ref: [4.5:56-63], [5.0:101-109], [5.1:126-133], [5.2:252-254]
4093//
4094// modifier ->
4095// MONOTONIC | NONMONOTONIC | SIMD // since 4.5, until 5.1
4096// ordering-modifier ->
4097// MONOTONIC | NONMONOTONIC // since 5.2
4098//
4099// Until 5.1, the SCHEDULE clause accepted up to two instances of "modifier".
4100// Since 5.2 "modifier" was replaced with "ordering-modifier" and "chunk-
4101// modifier".
4103 ENUM_CLASS(Value, Monotonic, Nonmonotonic, Simd)
4104 WRAPPER_CLASS_BOILERPLATE(OmpOrderingModifier, Value);
4105};
4106
4107// Ref: [5.1:125-126], [5.2:233-234]
4108//
4109// order-modifier ->
4110// REPRODUCIBLE | UNCONSTRAINED // since 5.1
4112 ENUM_CLASS(Value, Reproducible, Unconstrained)
4113 WRAPPER_CLASS_BOILERPLATE(OmpOrderModifier, Value);
4114};
4115
4116// Ref: [6.0:470-471]
4117//
4118// preference-selector -> // since 6.0
4119// FR(foreign-runtime-identifier) |
4120// ATTR(preference-property-extension, ...)
4122 UNION_CLASS_BOILERPLATE(OmpPreferenceSelector);
4123 using ForeignRuntimeIdentifier = common::Indirection<Expr>;
4124 using PreferencePropertyExtension = common::Indirection<Expr>;
4125 using Extensions = std::list<PreferencePropertyExtension>;
4126 std::variant<ForeignRuntimeIdentifier, Extensions> u;
4127};
4128
4129// Ref: [6.0:470-471]
4130//
4131// preference-specification ->
4132// {preference-selector...} | // since 6.0
4133// foreign-runtime-identifier // since 5.1
4135 UNION_CLASS_BOILERPLATE(OmpPreferenceSpecification);
4136 using ForeignRuntimeIdentifier =
4137 OmpPreferenceSelector::ForeignRuntimeIdentifier;
4138 std::variant<std::list<OmpPreferenceSelector>, ForeignRuntimeIdentifier> u;
4139};
4140
4141// REF: [5.1:217-220], [5.2:293-294], [6.0:470-471]
4142//
4143// prefer-type -> // since 5.1
4144// PREFER_TYPE(preference-specification...)
4146 WRAPPER_CLASS_BOILERPLATE(
4147 OmpPreferType, std::list<OmpPreferenceSpecification>);
4148};
4149
4150// Ref: [5.1:166-171], [5.2:269-270]
4151//
4152// prescriptiveness ->
4153// STRICT // since 5.1
4155 ENUM_CLASS(Value, Strict)
4156 WRAPPER_CLASS_BOILERPLATE(OmpPrescriptiveness, Value);
4157};
4158
4159// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
4160// [6.0:279-288]
4161//
4162// present-modifier ->
4163// PRESENT // since 5.1
4164//
4165// Until 5.2, it was a part of map-type-modifier. Since 6.0 the
4166// map-type-modifier has been split into individual modifiers.
4168 ENUM_CLASS(Value, Present)
4169 WRAPPER_CLASS_BOILERPLATE(OmpPresentModifier, Value);
4170};
4171
4172// Ref: [5.0:300-302], [5.1:332-334], [5.2:134-137]
4173//
4174// reduction-modifier ->
4175// DEFAULT | INSCAN | TASK // since 5.0
4177 ENUM_CLASS(Value, Default, Inscan, Task);
4178 WRAPPER_CLASS_BOILERPLATE(OmpReductionModifier, Value);
4179};
4180
4181// Ref: [6.0:279-288]
4182//
4183// ref-modifier ->
4184// REF_PTEE | REF_PTR | REF_PTR_PTEE // since 6.0
4185//
4187 ENUM_CLASS(Value, Ref_Ptee, Ref_Ptr, Ref_Ptr_Ptee)
4188 WRAPPER_CLASS_BOILERPLATE(OmpRefModifier, Value);
4189};
4190
4191// Ref: [6.0:279-288]
4192//
4193// self-modifier ->
4194// SELF // since 6.0
4195//
4197 ENUM_CLASS(Value, Self)
4198 WRAPPER_CLASS_BOILERPLATE(OmpSelfModifier, Value);
4199};
4200
4201// Ref: [5.2:117-120]
4202//
4203// step-complex-modifier ->
4204// STEP(integer-expression) // since 5.2
4206 WRAPPER_CLASS_BOILERPLATE(OmpStepComplexModifier, ScalarIntExpr);
4207};
4208
4209// Ref: [4.5:207-210], [5.0:290-293], [5.1:323-325], [5.2:117-120]
4210//
4211// step-simple-modifier ->
4212// integer-expresion // since 4.5
4214 WRAPPER_CLASS_BOILERPLATE(OmpStepSimpleModifier, ScalarIntExpr);
4215};
4216
4217// Ref: [4.5:169-170], [5.0:254-256], [5.1:287-289], [5.2:321]
4218//
4219// task-dependence-type -> // "dependence-type" in 5.1 and before
4220// IN | OUT | INOUT | // since 4.5
4221// MUTEXINOUTSET | DEPOBJ | // since 5.0
4222// INOUTSET // since 5.2
4224 using Value = common::OmpDependenceKind;
4225 WRAPPER_CLASS_BOILERPLATE(OmpTaskDependenceType, Value);
4226};
4227
4228// Ref: [4.5:229-230], [5.0:324-325], [5.1:357-358], [5.2:161-162]
4229//
4230// variable-category ->
4231// SCALAR | // since 4.5
4232// AGGREGATE | ALLOCATABLE | POINTER | // since 5.0
4233// ALL // since 5.2
4235 ENUM_CLASS(Value, Aggregate, All, Allocatable, Pointer, Scalar)
4236 WRAPPER_CLASS_BOILERPLATE(OmpVariableCategory, Value);
4237};
4238
4239// Extension:
4240// https://openmp.llvm.org//openacc/OpenMPExtensions.html#ompx-hold
4241//
4242// ompx-hold-modifier ->
4243// OMPX_HOLD // since 4.5
4244//
4245// Until 5.2, it was a part of map-type-modifier. Since 6.0 the
4246// map-type-modifier has been split into individual modifiers.
4248 ENUM_CLASS(Value, Ompx_Hold)
4249 WRAPPER_CLASS_BOILERPLATE(OmpxHoldModifier, Value);
4250};
4251
4252// context-selector
4253using OmpContextSelector = traits::OmpContextSelectorSpecification;
4254} // namespace modifier
4255
4256// --- Clauses
4257
4258using OmpDirectiveList = std::list<llvm::omp::Directive>;
4259
4260// Ref: [5.2:214]
4261//
4262// absent-clause ->
4263// ABSENT(directive-name[, directive-name])
4265 WRAPPER_CLASS_BOILERPLATE(OmpAbsentClause, OmpDirectiveList);
4266};
4267
4269 TUPLE_CLASS_BOILERPLATE(OmpAdjustArgsClause);
4271 ENUM_CLASS(Value, Nothing, Need_Device_Ptr)
4272 WRAPPER_CLASS_BOILERPLATE(OmpAdjustOp, Value);
4273 };
4274 std::tuple<OmpAdjustOp, OmpObjectList> t;
4275};
4276
4277// Ref: [5.0:135-140], [5.1:161-166], [5.2:264-265]
4278//
4279// affinity-clause ->
4280// AFFINITY([aff-modifier:] locator-list) // since 5.0
4281// aff-modifier ->
4282// interator-modifier // since 5.0
4284 TUPLE_CLASS_BOILERPLATE(OmpAffinityClause);
4285 MODIFIER_BOILERPLATE(OmpIterator);
4286 std::tuple<MODIFIERS(), OmpObjectList> t;
4287};
4288
4289// Ref: 5.2: [174]
4291 WRAPPER_CLASS_BOILERPLATE(OmpAlignClause, ScalarIntConstantExpr);
4292};
4293
4294// Ref: [4.5:72-81], [5.0:110-119], [5.1:134-143], [5.2:169-170]
4295//
4296// aligned-clause ->
4297// ALIGNED(list [: alignment]) // since 4.5
4299 TUPLE_CLASS_BOILERPLATE(OmpAlignedClause);
4300 MODIFIER_BOILERPLATE(OmpAlignment);
4301 std::tuple<OmpObjectList, MODIFIERS()> t;
4302};
4303
4304// Ref: [5.0:158-159], [5.1:184-185], [5.2:178-179]
4305//
4306// allocate-clause ->
4307// ALLOCATE(
4308// [allocator-simple-modifier:] list) | // since 5.0
4309// ALLOCATE([modifier...:] list) // since 5.1
4310// modifier ->
4311// allocator-simple-modifier |
4312// allocator-complex-modifier | align-modifier // since 5.1
4314 MODIFIER_BOILERPLATE(OmpAlignModifier, OmpAllocatorSimpleModifier,
4316 TUPLE_CLASS_BOILERPLATE(OmpAllocateClause);
4317 std::tuple<MODIFIERS(), OmpObjectList> t;
4318};
4319
4322 WRAPPER_CLASS_BOILERPLATE(OmpAppendOp, std::list<OmpInteropType>);
4323 };
4324 WRAPPER_CLASS_BOILERPLATE(OmpAppendArgsClause, std::list<OmpAppendOp>);
4325};
4326
4327// Ref: [5.2:216-217 (sort of, as it's only mentioned in passing)
4328// AT(compilation|execution)
4330 ENUM_CLASS(ActionTime, Compilation, Execution);
4331 WRAPPER_CLASS_BOILERPLATE(OmpAtClause, ActionTime);
4332};
4333
4334// Ref: [5.0:60-63], [5.1:83-86], [5.2:210-213]
4335//
4336// atomic-default-mem-order-clause ->
4337// ATOMIC_DEFAULT_MEM_ORDER(memory-order) // since 5.0
4338// memory-order ->
4339// SEQ_CST | ACQ_REL | RELAXED | // since 5.0
4340// ACQUIRE | RELEASE // since 5.2
4342 using MemoryOrder = common::OmpMemoryOrderType;
4343 WRAPPER_CLASS_BOILERPLATE(OmpAtomicDefaultMemOrderClause, MemoryOrder);
4344};
4345
4346// Ref: [5.0:128-131], [5.1:151-154], [5.2:258-259]
4347//
4348// bind-clause ->
4349// BIND(binding) // since 5.0
4350// binding ->
4351// TEAMS | PARALLEL | THREAD // since 5.0
4353 ENUM_CLASS(Binding, Parallel, Teams, Thread)
4354 WRAPPER_CLASS_BOILERPLATE(OmpBindClause, Binding);
4355};
4356
4357// Artificial clause to represent a cancellable construct.
4359 TUPLE_CLASS_BOILERPLATE(OmpCancellationConstructTypeClause);
4360 std::tuple<OmpDirectiveName, std::optional<ScalarLogicalExpr>> t;
4361};
4362
4363// Ref: [6.0:262]
4364//
4365// combiner-clause -> // since 6.0
4366// COMBINER(combiner-expr)
4368 WRAPPER_CLASS_BOILERPLATE(OmpCombinerClause, OmpCombinerExpression);
4369};
4370
4371// Ref: [5.2:214]
4372//
4373// contains-clause ->
4374// CONTAINS(directive-name[, directive-name])
4376 WRAPPER_CLASS_BOILERPLATE(OmpContainsClause, OmpDirectiveList);
4377};
4378
4379// Ref: [4.5:46-50], [5.0:74-78], [5.1:92-96], [5.2:109]
4380//
4381// When used as a data-sharing clause:
4382// default-clause ->
4383// DEFAULT(data-sharing-attribute) // since 4.5
4384// data-sharing-attribute ->
4385// SHARED | NONE | // since 4.5
4386// PRIVATE | FIRSTPRIVATE // since 5.0
4387//
4388// When used in METADIRECTIVE:
4389// default-clause ->
4390// DEFAULT(directive-specification) // since 5.0, until 5.1
4391// See also otherwise-clause.
4393 ENUM_CLASS(DataSharingAttribute, Private, Firstprivate, Shared, None)
4394 UNION_CLASS_BOILERPLATE(OmpDefaultClause);
4395 std::variant<DataSharingAttribute,
4397 u;
4398};
4399
4400// Ref: [4.5:103-107], [5.0:324-325], [5.1:357-358], [5.2:161-162]
4401//
4402// defaultmap-clause ->
4403// DEFAULTMAP(implicit-behavior
4404// [: variable-category]) // since 5.0
4405// implicit-behavior ->
4406// TOFROM | // since 4.5
4407// ALLOC | TO | FROM | FIRSTPRIVATE | NONE |
4408// DEFAULT | // since 5.0
4409// PRESENT // since 5.1
4411 TUPLE_CLASS_BOILERPLATE(OmpDefaultmapClause);
4412 ENUM_CLASS(ImplicitBehavior, Alloc, To, From, Tofrom, Firstprivate, None,
4413 Default, Present)
4414 MODIFIER_BOILERPLATE(OmpVariableCategory);
4415 std::tuple<ImplicitBehavior, MODIFIERS()> t;
4416};
4417
4418// Ref: [4.5:169-172], [5.0:255-259], [5.1:288-292], [5.2:91-93]
4419//
4420// iteration-offset ->
4421// +|- non-negative-constant // since 4.5
4423 TUPLE_CLASS_BOILERPLATE(OmpIterationOffset);
4424 std::tuple<DefinedOperator, ScalarIntConstantExpr> t;
4425};
4426
4427// Ref: [4.5:169-172], [5.0:255-259], [5.1:288-292], [5.2:91-93]
4428//
4429// iteration ->
4430// induction-variable [iteration-offset] // since 4.5
4432 TUPLE_CLASS_BOILERPLATE(OmpIteration);
4433 std::tuple<Name, std::optional<OmpIterationOffset>> t;
4434};
4435
4436// Ref: [4.5:169-172], [5.0:255-259], [5.1:288-292], [5.2:91-93]
4437//
4438// iteration-vector ->
4439// [iteration...] // since 4.5
4441 WRAPPER_CLASS_BOILERPLATE(OmpIterationVector, std::list<OmpIteration>);
4442};
4443
4444// Extract this into a separate structure (instead of having it directly in
4445// OmpDoacrossClause), so that the context in TYPE_CONTEXT_PARSER can be set
4446// separately for OmpDependClause and OmpDoacrossClause.
4447//
4448// See: depend-clause, doacross-clause
4450 OmpDependenceType::Value GetDepType() const;
4451
4452 WRAPPER_CLASS(Sink, OmpIterationVector);
4453 EMPTY_CLASS(Source);
4454 UNION_CLASS_BOILERPLATE(OmpDoacross);
4455 std::variant<Sink, Source> u;
4456};
4457
4458// Ref: [4.5:169-172], [5.0:255-259], [5.1:288-292], [5.2:323-326]
4459//
4460// depend-clause ->
4461// DEPEND(SOURCE) | // since 4.5, until 5.1
4462// DEPEND(SINK: iteration-vector) | // since 4.5, until 5.1
4463// DEPEND([depend-modifier,]
4464// task-dependence-type: locator-list) // since 4.5
4465//
4466// depend-modifier -> iterator-modifier // since 5.0
4468 UNION_CLASS_BOILERPLATE(OmpDependClause);
4469 struct TaskDep {
4470 OmpTaskDependenceType::Value GetTaskDepType() const;
4471 TUPLE_CLASS_BOILERPLATE(TaskDep);
4472 MODIFIER_BOILERPLATE(OmpIterator, OmpTaskDependenceType);
4473 std::tuple<MODIFIERS(), OmpObjectList> t;
4474 };
4475 std::variant<TaskDep, OmpDoacross> u;
4476};
4477
4478// Ref: [5.2:326-328]
4479//
4480// doacross-clause ->
4481// DOACROSS(dependence-type: iteration-vector) // since 5.2
4483 WRAPPER_CLASS_BOILERPLATE(OmpDoacrossClause, OmpDoacross);
4484};
4485
4486// Ref: [5.0:254-255], [5.1:287-288], [5.2:73]
4487//
4488// destroy-clause ->
4489// DESTROY | // since 5.0, until 5.1
4490// DESTROY(variable) // since 5.2
4492 WRAPPER_CLASS_BOILERPLATE(OmpDestroyClause, OmpObject);
4493};
4494
4495// Ref: [5.0:135-140], [5.1:161-166], [5.2:265-266]
4496//
4497// detach-clause ->
4498// DETACH(event-handle) // since 5.0
4500 WRAPPER_CLASS_BOILERPLATE(OmpDetachClause, OmpObject);
4501};
4502
4503// Ref: [4.5:103-107], [5.0:170-176], [5.1:197-205], [5.2:276-277]
4504//
4505// device-clause ->
4506// DEVICE(scalar-integer-expression) | // since 4.5
4507// DEVICE([device-modifier:]
4508// scalar-integer-expression) // since 5.0
4510 TUPLE_CLASS_BOILERPLATE(OmpDeviceClause);
4511 MODIFIER_BOILERPLATE(OmpDeviceModifier);
4512 std::tuple<MODIFIERS(), ScalarIntExpr> t;
4513};
4514
4515// Ref: [6.0:356-362]
4516//
4517// device-safesync-clause ->
4518// DEVICE_SAFESYNC [(scalar-logical-const-expr)] // since 6.0
4520 WRAPPER_CLASS_BOILERPLATE(OmpDeviceSafesyncClause, ScalarLogicalConstantExpr);
4521};
4522
4523// Ref: [5.0:180-185], [5.1:210-216], [5.2:275]
4524//
4525// device-type-clause ->
4526// DEVICE_TYPE(ANY | HOST | NOHOST) // since 5.0
4528 ENUM_CLASS(DeviceTypeDescription, Any, Host, Nohost)
4529 WRAPPER_CLASS_BOILERPLATE(OmpDeviceTypeClause, DeviceTypeDescription);
4530};
4531
4532// Ref: [5.0:60-63], [5.1:83-86], [5.2:212-213], [6.0:356-362]
4533//
4534// dynamic-allocators-clause ->
4535// DYNAMIC_ALLOCATORS // since 5.0
4536// [(scalar-logical-const-expr)] // since 6.0
4538 WRAPPER_CLASS_BOILERPLATE(
4539 OmpDynamicAllocatorsClause, ScalarLogicalConstantExpr);
4540};
4541
4543 TUPLE_CLASS_BOILERPLATE(OmpDynGroupprivateClause);
4544 MODIFIER_BOILERPLATE(OmpAccessGroup, OmpFallbackModifier);
4545 std::tuple<MODIFIERS(), ScalarIntExpr> t;
4546};
4547
4548// Ref: [5.2:158-159], [6.0:289-290]
4549//
4550// enter-clause ->
4551// ENTER(locator-list) |
4552// ENTER(automap-modifier: locator-list) | // since 6.0
4554 TUPLE_CLASS_BOILERPLATE(OmpEnterClause);
4555 MODIFIER_BOILERPLATE(OmpAutomapModifier);
4556 std::tuple<MODIFIERS(), OmpObjectList> t;
4557};
4558
4559// OMP 5.2 15.8.3 extended-atomic, fail-clause ->
4560// FAIL(memory-order)
4562 using MemoryOrder = common::OmpMemoryOrderType;
4563 WRAPPER_CLASS_BOILERPLATE(OmpFailClause, MemoryOrder);
4564};
4565
4566// Ref: [4.5:107-109], [5.0:176-180], [5.1:205-210], [5.2:167-168]
4567//
4568// from-clause ->
4569// FROM(locator-list) |
4570// FROM(mapper-modifier: locator-list) | // since 5.0
4571// FROM(motion-modifier[,] ...: locator-list) // since 5.1
4572// motion-modifier ->
4573// PRESENT | mapper-modifier | iterator-modifier
4575 TUPLE_CLASS_BOILERPLATE(OmpFromClause);
4576 MODIFIER_BOILERPLATE(OmpExpectation, OmpIterator, OmpMapper);
4577 std::tuple<MODIFIERS(), OmpObjectList, /*CommaSeparated=*/bool> t;
4578};
4579
4580// Ref: [4.5:87-91], [5.0:140-146], [5.1:166-171], [5.2:269]
4581//
4582// grainsize-clause ->
4583// GRAINSIZE(grain-size) | // since 4.5
4584// GRAINSIZE([prescriptiveness:] grain-size) // since 5.1
4586 TUPLE_CLASS_BOILERPLATE(OmpGrainsizeClause);
4587 MODIFIER_BOILERPLATE(OmpPrescriptiveness);
4588 std::tuple<MODIFIERS(), ScalarIntExpr> t;
4589};
4590
4591// Ref: [6.0:438]
4592//
4593// graph_id-clause ->
4594// GRAPH_ID(graph-id-value) // since 6.0
4596 WRAPPER_CLASS_BOILERPLATE(OmpGraphIdClause, ScalarIntExpr);
4597};
4598
4599// Ref: [6.0:438-439]
4600//
4601// graph_reset-clause ->
4602// GRAPH_RESET[(graph-reset-expression)] // since 6.0
4604 WRAPPER_CLASS_BOILERPLATE(OmpGraphResetClause, ScalarLogicalExpr);
4605};
4606
4607// Ref: [5.0:234-242], [5.1:266-275], [5.2:299], [6.0:472-473]
4609 WRAPPER_CLASS_BOILERPLATE(OmpHintClause, ScalarIntConstantExpr);
4610};
4611
4612// Ref: [5.2: 214]
4613//
4614// holds-clause ->
4615// HOLDS(expr)
4617 WRAPPER_CLASS_BOILERPLATE(OmpHoldsClause, common::Indirection<Expr>);
4618};
4619
4620// Ref: [5.2: 209]
4622 WRAPPER_CLASS_BOILERPLATE(
4623 OmpIndirectClause, std::optional<ScalarLogicalExpr>);
4624};
4625
4626// Ref: [5.2:72-73], in 4.5-5.1 it's scattered over individual directives
4627// that allow the IF clause.
4628//
4629// if-clause ->
4630// IF([directive-name-modifier:]
4631// scalar-logical-expression) // since 4.5
4633 TUPLE_CLASS_BOILERPLATE(OmpIfClause);
4634 MODIFIER_BOILERPLATE(OmpDirectiveNameModifier);
4635 std::tuple<MODIFIERS(), ScalarLogicalExpr> t;
4636};
4637
4638// Ref: [5.1:217-220], [5.2:293-294], [6.0:180-181]
4639//
4640// init-clause ->
4641// INIT ([modifier... :] interop-var) // since 5.1
4642// modifier ->
4643// prefer-type | interop-type | // since 5.1
4644// depinfo-modifier // since 6.0
4646 TUPLE_CLASS_BOILERPLATE(OmpInitClause);
4647 MODIFIER_BOILERPLATE(OmpPreferType, OmpInteropType, OmpDepinfoModifier);
4648 std::tuple<MODIFIERS(), OmpObject> t;
4649};
4650
4651// Ref: [5.0:170-176], [5.1:197-205], [5.2:138-139]
4652//
4653// in-reduction-clause ->
4654// IN_REDUCTION(reduction-identifier: list) // since 5.0
4656 TUPLE_CLASS_BOILERPLATE(OmpInReductionClause);
4657 MODIFIER_BOILERPLATE(OmpReductionIdentifier);
4658 std::tuple<MODIFIERS(), OmpObjectList> t;
4659};
4660
4661// Initialization for declare reduction construct
4663 WRAPPER_CLASS_BOILERPLATE(OmpInitializerClause, OmpInitializerExpression);
4664};
4665
4666// Ref: [4.5:199-201], [5.0:288-290], [5.1:321-322], [5.2:115-117]
4667//
4668// lastprivate-clause ->
4669// LASTPRIVATE(list) | // since 4.5
4670// LASTPRIVATE([lastprivate-modifier:] list) // since 5.0
4672 TUPLE_CLASS_BOILERPLATE(OmpLastprivateClause);
4673 MODIFIER_BOILERPLATE(OmpLastprivateModifier);
4674 std::tuple<MODIFIERS(), OmpObjectList> t;
4675};
4676
4677// Ref: [4.5:207-210], [5.0:290-293], [5.1:323-325], [5.2:117-120]
4678//
4679// linear-clause ->
4680// LINEAR(list [: step-simple-modifier]) | // since 4.5
4681// LINEAR(linear-modifier(list)
4682// [: step-simple-modifier]) | // since 4.5, until 5.2[*]
4683// LINEAR(list [: linear-modifier,
4684// step-complex-modifier]) // since 5.2
4685// [*] Still allowed in 5.2 when on DECLARE SIMD, but deprecated.
4687 TUPLE_CLASS_BOILERPLATE(OmpLinearClause);
4688 MODIFIER_BOILERPLATE(
4690 std::tuple<OmpObjectList, MODIFIERS(), /*PostModified=*/bool> t;
4691};
4692
4693// Ref: [6.0:207-208]
4694//
4695// looprange-clause ->
4696// LOOPRANGE(first, count) // since 6.0
4698 TUPLE_CLASS_BOILERPLATE(OmpLooprangeClause);
4699 std::tuple<ScalarIntConstantExpr, ScalarIntConstantExpr> t;
4700};
4701
4702// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158]
4703//
4704// map-clause ->
4705// MAP([modifier...:] locator-list) // since 4.5
4706// modifier ->
4707// map-type-modifier [replaced] | // since 4.5, until 5.2
4708// always-modifier | // since 6.0
4709// attach-modifier | // since 6.1
4710// close-modifier | // since 6.0
4711// delete-modifier | // since 6.0
4712// present-modifier | // since 6.0
4713// ref-modifier | // since 6.0
4714// self-modifier | // since 6.0
4715// mapper | // since 5.0
4716// iterator | // since 5.1
4717// map-type // since 4.5
4718// ompx-hold-modifier | // since 6.0
4719//
4720// Since 6.0 the map-type-modifier has been split into individual modifiers,
4721// and delete-modifier has been split from map-type.
4723 TUPLE_CLASS_BOILERPLATE(OmpMapClause);
4727 std::tuple<MODIFIERS(), OmpObjectList, /*CommaSeparated=*/bool> t;
4728};
4729
4730// Ref: [5.0:58-60], [5.1:63-68], [5.2:194-195]
4731//
4732// match-clause ->
4733// MATCH (context-selector-specification) // since 5.0
4735 // The context-selector is an argument.
4736 WRAPPER_CLASS_BOILERPLATE(
4738};
4739
4740// Ref: [5.2:217-218]
4741// message-clause ->
4742// MESSAGE("message-text")
4744 WRAPPER_CLASS_BOILERPLATE(OmpMessageClause, Expr);
4745};
4746
4747// Ref: [5.2: 214]
4748//
4749// no_openmp_clause -> NO_OPENMP
4750EMPTY_CLASS(OmpNoOpenMPClause);
4751
4752// Ref: [5.2: 214]
4753//
4754// no_openmp_routines_clause -> NO_OPENMP_ROUTINES
4755EMPTY_CLASS(OmpNoOpenMPRoutinesClause);
4756
4757// Ref: [5.2: 214]
4758//
4759// no_parallelism_clause -> NO_PARALELISM
4760EMPTY_CLASS(OmpNoParallelismClause);
4761
4762// Ref: [4.5:87-91], [5.0:140-146], [5.1:166-171], [5.2:270]
4763//
4764// num-tasks-clause ->
4765// NUM_TASKS(num-tasks) | // since 4.5
4766// NUM_TASKS([prescriptiveness:] num-tasks) // since 5.1
4768 TUPLE_CLASS_BOILERPLATE(OmpNumTasksClause);
4769 MODIFIER_BOILERPLATE(OmpPrescriptiveness);
4770 std::tuple<MODIFIERS(), ScalarIntExpr> t;
4771};
4772
4773// Ref: [4.5:114-116], [5.0:82-85], [5.1:100-104], [5.2:277], [6.0:452-453]
4774//
4775// num-teams-clause ->
4776// NUM_TEAMS(expr) | // since 4.5
4777// NUM_TEAMS([lower-bound:] upper-bound) | // since 5.1
4778// NUM_TEAMS([dims: upper-bound...) // since 6.1
4780 TUPLE_CLASS_BOILERPLATE(OmpNumTeamsClause);
4781 MODIFIER_BOILERPLATE(OmpDimsModifier, OmpLowerBound);
4782 std::tuple<MODIFIERS(), std::list<ScalarIntExpr>> t;
4783};
4784
4785// Ref: [4.5:46-50], [5.0:74-78], [5.1:92-96], [5.2:227], [6.0:388-389]
4786//
4787// num-threads-clause
4788// NUM_THREADS(expr) | // since 4.5
4789// NUM_THREADS(expr...) | // since 6.0
4790// NUM_THREADS([dims-modifier:] expr...) // since 6.1
4792 TUPLE_CLASS_BOILERPLATE(OmpNumThreadsClause);
4793 MODIFIER_BOILERPLATE(OmpDimsModifier);
4794 std::tuple<MODIFIERS(), std::list<ScalarIntExpr>> t;
4795};
4796
4797// Ref: [5.0:101-109], [5.1:126-134], [5.2:233-234]
4798//
4799// order-clause ->
4800// ORDER(CONCURRENT) | // since 5.0
4801// ORDER([order-modifier:] CONCURRENT) // since 5.1
4803 TUPLE_CLASS_BOILERPLATE(OmpOrderClause);
4804 ENUM_CLASS(Ordering, Concurrent)
4805 MODIFIER_BOILERPLATE(OmpOrderModifier);
4806 std::tuple<MODIFIERS(), Ordering> t;
4807};
4808
4809// Ref: [5.0:56-57], [5.1:60-62], [5.2:191]
4810//
4811// otherwise-clause ->
4812// DEFAULT ([directive-specification]) // since 5.0, until 5.1
4813// otherwise-clause ->
4814// OTHERWISE ([directive-specification])] // since 5.2
4816 WRAPPER_CLASS_BOILERPLATE(OmpOtherwiseClause,
4818};
4819
4820// Ref: [4.5:46-50], [5.0:74-78], [5.1:92-96], [5.2:229-230]
4821//
4822// proc-bind-clause ->
4823// PROC_BIND(affinity-policy) // since 4.5
4824// affinity-policy ->
4825// CLOSE | PRIMARY | SPREAD | // since 4.5
4826// MASTER // since 4.5, until 5.2
4828 ENUM_CLASS(AffinityPolicy, Close, Master, Spread, Primary)
4829 WRAPPER_CLASS_BOILERPLATE(OmpProcBindClause, AffinityPolicy);
4830};
4831
4832// Ref: [4.5:201-207], [5.0:300-302], [5.1:332-334], [5.2:134-137]
4833//
4834// reduction-clause ->
4835// REDUCTION(reduction-identifier: list) | // since 4.5
4836// REDUCTION([reduction-modifier,]
4837// reduction-identifier: list) // since 5.0
4839 TUPLE_CLASS_BOILERPLATE(OmpReductionClause);
4840 MODIFIER_BOILERPLATE(OmpReductionModifier, OmpReductionIdentifier);
4841 std::tuple<MODIFIERS(), OmpObjectList> t;
4842};
4843
4844// Ref: [6.0:440:441]
4845//
4846// replayable-clause ->
4847// REPLAYABLE[(replayable-expression)] // since 6.0
4849 WRAPPER_CLASS_BOILERPLATE(OmpReplayableClause, ScalarLogicalConstantExpr);
4850};
4851
4852// Ref: [5.0:60-63], [5.1:83-86], [5.2:212-213], [6.0:356-362]
4853//
4854// reverse-offload-clause ->
4855// REVERSE_OFFLOAD // since 5.0
4856// [(scalar-logical-const-expr)] // since 6.0
4858 WRAPPER_CLASS_BOILERPLATE(OmpReverseOffloadClause, ScalarLogicalConstantExpr);
4859};
4860
4861// Ref: [4.5:56-63], [5.0:101-109], [5.1:126-133], [5.2:252-254]
4862//
4863// schedule-clause ->
4864// SCHEDULE([modifier[, modifier]:]
4865// kind[, chunk-size]) // since 4.5, until 5.1
4866// schedule-clause ->
4867// SCHEDULE([ordering-modifier], chunk-modifier],
4868// kind[, chunk_size]) // since 5.2
4870 TUPLE_CLASS_BOILERPLATE(OmpScheduleClause);
4871 ENUM_CLASS(Kind, Static, Dynamic, Guided, Auto, Runtime)
4872 MODIFIER_BOILERPLATE(OmpOrderingModifier, OmpChunkModifier);
4873 std::tuple<MODIFIERS(), Kind, std::optional<ScalarIntExpr>> t;
4874};
4875
4876// ref: [6.0:361-362]
4877//
4878// self-maps-clause ->
4879// SELF_MAPS [(scalar-logical-const-expr)] // since 6.0
4881 WRAPPER_CLASS_BOILERPLATE(OmpSelfMapsClause, ScalarLogicalConstantExpr);
4882};
4883
4884// REF: [5.2:217]
4885// severity-clause ->
4886// SEVERITY(warning|fatal)
4888 ENUM_CLASS(SevLevel, Fatal, Warning);
4889 WRAPPER_CLASS_BOILERPLATE(OmpSeverityClause, SevLevel);
4890};
4891
4892// Ref: [5.0:232-234], [5.1:264-266], [5.2:137]
4893//
4894// task-reduction-clause ->
4895// TASK_REDUCTION(reduction-identifier: list) // since 5.0
4897 TUPLE_CLASS_BOILERPLATE(OmpTaskReductionClause);
4898 MODIFIER_BOILERPLATE(OmpReductionIdentifier);
4899 std::tuple<MODIFIERS(), OmpObjectList> t;
4900};
4901
4902// Ref: [4.5:114-116], [5.0:82-85], [5.1:100-104], [5.2:277], [6.0:452-453]
4903//
4904// thread-limit-clause ->
4905// THREAD_LIMIT(threadlim) // since 4.5
4906// THREAD_LIMIT([dims-modifier:] threadlim...) // since 6.1
4908 TUPLE_CLASS_BOILERPLATE(OmpThreadLimitClause);
4909 MODIFIER_BOILERPLATE(OmpDimsModifier);
4910 std::tuple<MODIFIERS(), std::list<ScalarIntExpr>> t;
4911};
4912
4913// Ref: [6.0:442]
4914// threadset-clause ->
4915// THREADSET(omp_pool|omp_team)
4917 ENUM_CLASS(ThreadsetPolicy, Omp_Pool, Omp_Team)
4918 WRAPPER_CLASS_BOILERPLATE(OmpThreadsetClause, ThreadsetPolicy);
4919};
4920
4921// Ref: [4.5:107-109], [5.0:176-180], [5.1:205-210], [5.2:167-168]
4922//
4923// to-clause (in DECLARE TARGET) ->
4924// TO(extended-list) | // until 5.1
4925// to-clause (in TARGET UPDATE) ->
4926// TO(locator-list) |
4927// TO(mapper-modifier: locator-list) | // since 5.0
4928// TO(motion-modifier[,] ...: locator-list) // since 5.1
4929// motion-modifier ->
4930// PRESENT | mapper-modifier | iterator-modifier
4932 TUPLE_CLASS_BOILERPLATE(OmpToClause);
4933 MODIFIER_BOILERPLATE(OmpExpectation, OmpIterator, OmpMapper);
4934 std::tuple<MODIFIERS(), OmpObjectList, /*CommaSeparated=*/bool> t;
4935};
4936
4937// Ref: [6.0:510-511]
4938//
4939// transparent-clause ->
4940// TRANSPARENT[(impex-type)] // since 6.0
4942 WRAPPER_CLASS_BOILERPLATE(OmpTransparentClause, ScalarIntExpr);
4943};
4944
4945// Ref: [5.0:60-63], [5.1:83-86], [5.2:212-213], [6.0:356-362]
4946//
4947// unified-address-clause ->
4948// UNIFIED_ADDRESS // since 5.0
4949// [(scalar-logical-const-expr)] // since 6.0
4951 WRAPPER_CLASS_BOILERPLATE(OmpUnifiedAddressClause, ScalarLogicalConstantExpr);
4952};
4953
4954// Ref: [5.0:60-63], [5.1:83-86], [5.2:212-213], [6.0:356-362]
4955//
4956// unified-shared-memory-clause ->
4957// UNIFIED_SHARED_MEMORY // since 5.0
4958// [(scalar-logical-const-expr)] // since 6.0
4960 WRAPPER_CLASS_BOILERPLATE(
4961 OmpUnifiedSharedMemoryClause, ScalarLogicalConstantExpr);
4962};
4963
4964// Ref: [5.0:254-255], [5.1:287-288], [5.2:321-322]
4965//
4966// In ATOMIC construct
4967// update-clause ->
4968// UPDATE // Since 4.5
4969//
4970// In DEPOBJ construct
4971// update-clause ->
4972// UPDATE(dependence-type) // since 5.0, until 5.1
4973// update-clause ->
4974// UPDATE(task-dependence-type) // since 5.2
4976 UNION_CLASS_BOILERPLATE(OmpUpdateClause);
4977 // The dependence type is an argument here, not a modifier.
4978 std::variant<OmpDependenceType, OmpTaskDependenceType> u;
4979};
4980
4981// Ref: [5.0:56-57], [5.1:60-62], [5.2:190-191]
4982//
4983// when-clause ->
4984// WHEN (context-selector :
4985// [directive-specification]) // since 5.0
4987 TUPLE_CLASS_BOILERPLATE(OmpWhenClause);
4988 MODIFIER_BOILERPLATE(OmpContextSelector);
4989 std::tuple<MODIFIERS(),
4990 std::optional<common::Indirection<OmpDirectiveSpecification>>>
4991 t;
4992};
4993
4994// REF: [5.1:217-220], [5.2:294]
4995//
4996// 14.1.3 use-clause -> USE (interop-var)
4998 WRAPPER_CLASS_BOILERPLATE(OmpUseClause, OmpObject);
4999};
5000
5001// OpenMP Clauses
5003 UNION_CLASS_BOILERPLATE(OmpClause);
5004 llvm::omp::Clause Id() const;
5005
5006#define GEN_FLANG_CLAUSE_PARSER_CLASSES
5007#include "llvm/Frontend/OpenMP/OMP.inc"
5008
5009 CharBlock source;
5010
5011 std::variant<
5012#define GEN_FLANG_CLAUSE_PARSER_CLASSES_LIST
5013#include "llvm/Frontend/OpenMP/OMP.inc"
5014 >
5015 u;
5016};
5017
5019 WRAPPER_CLASS_BOILERPLATE(OmpClauseList, std::list<OmpClause>);
5020 CharBlock source;
5021};
5022
5023// --- Directives and constructs
5024
5026 ENUM_CLASS(Flag, DeprecatedSyntax, CrossesLabelDo)
5028
5029 TUPLE_CLASS_BOILERPLATE(OmpDirectiveSpecification);
5030 const OmpDirectiveName &DirName() const {
5031 return std::get<OmpDirectiveName>(t);
5032 }
5033 llvm::omp::Directive DirId() const { //
5034 return DirName().v;
5035 }
5036 const OmpArgumentList &Arguments() const;
5037 const OmpClauseList &Clauses() const;
5038
5039 CharBlock source;
5040 std::tuple<OmpDirectiveName, std::optional<OmpArgumentList>,
5041 std::optional<OmpClauseList>, Flags>
5042 t;
5043};
5044
5045// OmpBeginDirective and OmpEndDirective are needed for semantic analysis,
5046// where some checks are done specifically for either the begin or the end
5047// directive. The structure of both is identical, but the diffent types
5048// allow to distinguish them in the type-based parse-tree visitor.
5050 INHERITED_TUPLE_CLASS_BOILERPLATE(
5052};
5053
5055 INHERITED_TUPLE_CLASS_BOILERPLATE(OmpEndDirective, OmpDirectiveSpecification);
5056};
5057
5058// Common base class for block-associated constructs.
5060 TUPLE_CLASS_BOILERPLATE(OmpBlockConstruct);
5061 const OmpBeginDirective &BeginDir() const {
5062 return std::get<OmpBeginDirective>(t);
5063 }
5064 const std::optional<OmpEndDirective> &EndDir() const {
5065 return std::get<std::optional<OmpEndDirective>>(t);
5066 }
5067
5068 CharBlock source;
5069 std::tuple<OmpBeginDirective, Block, std::optional<OmpEndDirective>> t;
5070};
5071
5073 WRAPPER_CLASS_BOILERPLATE(
5075};
5076
5077// Ref: [5.1:89-90], [5.2:216]
5078//
5079// nothing-directive ->
5080// NOTHING // since 5.1
5082 WRAPPER_CLASS_BOILERPLATE(OmpNothingDirective, OmpDirectiveSpecification);
5083};
5084
5085// Ref: OpenMP [5.2:216-218]
5086// ERROR AT(compilation|execution) SEVERITY(fatal|warning) MESSAGE("msg-str)
5088 WRAPPER_CLASS_BOILERPLATE(OmpErrorDirective, OmpDirectiveSpecification);
5089};
5090
5092 UNION_CLASS_BOILERPLATE(OpenMPUtilityConstruct);
5093 CharBlock source;
5094 std::variant<OmpErrorDirective, OmpNothingDirective> u;
5095};
5096
5097// Ref: [5.2: 213-216]
5098//
5099// assumes-construct ->
5100// ASSUMES absent-clause | contains-clause | holds-clause | no-openmp-clause |
5101// no-openmp-routines-clause | no-parallelism-clause
5103 WRAPPER_CLASS_BOILERPLATE(
5105 CharBlock source;
5106};
5107
5108// Ref: [5.1:86-89], [5.2:215], [6.0:369]
5109//
5110// assume-directive -> // since 5.1
5111// ASSUME assumption-clause...
5112// block
5113// [END ASSUME]
5115 INHERITED_TUPLE_CLASS_BOILERPLATE(OpenMPAssumeConstruct, OmpBlockConstruct);
5116};
5117
5118// 2.7.2 SECTIONS
5119// 2.11.2 PARALLEL SECTIONS
5121 INHERITED_TUPLE_CLASS_BOILERPLATE(
5123};
5124
5126 INHERITED_TUPLE_CLASS_BOILERPLATE(OmpEndSectionsDirective, OmpEndDirective);
5127};
5128
5129// [!$omp section]
5130// structured-block
5131// [!$omp section
5132// structured-block]
5133// ...
5135 TUPLE_CLASS_BOILERPLATE(OpenMPSectionConstruct);
5136 std::tuple<std::optional<OmpDirectiveSpecification>, Block> t;
5137 CharBlock source;
5138};
5139
5141 TUPLE_CLASS_BOILERPLATE(OpenMPSectionsConstruct);
5142 CharBlock source;
5143 const OmpBeginSectionsDirective &BeginDir() const {
5144 return std::get<OmpBeginSectionsDirective>(t);
5145 }
5146 const std::optional<OmpEndSectionsDirective> &EndDir() const {
5147 return std::get<std::optional<OmpEndSectionsDirective>>(t);
5148 }
5149 // Each of the OpenMPConstructs in the list below contains an
5150 // OpenMPSectionConstruct. This is guaranteed by the parser.
5151 // The end sections directive is optional here because it is difficult to
5152 // generate helpful error messages for a missing end directive within the
5153 // parser. Semantics will generate an error if this is absent.
5154 std::tuple<OmpBeginSectionsDirective, std::list<OpenMPConstruct>,
5155 std::optional<OmpEndSectionsDirective>>
5156 t;
5157};
5158
5159// Ref: [4.5:58-60], [5.0:58-60], [5.1:63-68], [5.2:197-198], [6.0:334-336]
5160//
5161// declare-variant-directive ->
5162// DECLARE_VARIANT([base-name:]variant-name) // since 4.5
5164 WRAPPER_CLASS_BOILERPLATE(
5166 CharBlock source;
5167};
5168
5169// Ref: [4.5:110-113], [5.0:180-185], [5.1:210-216], [5.2:206-207],
5170// [6.0:346-348]
5171//
5172// declare-target-directive -> // since 4.5
5173// DECLARE_TARGET[(extended-list)] |
5174// DECLARE_TARGET clause-list
5176 WRAPPER_CLASS_BOILERPLATE(
5178 CharBlock source;
5179};
5180
5181// OMP v5.2: 5.8.8
5182// declare-mapper -> DECLARE MAPPER ([mapper-name :] type :: var) map-clauses
5184 WRAPPER_CLASS_BOILERPLATE(
5186 CharBlock source;
5187};
5188
5189// ref: 5.2: Section 5.5.11 139-141
5190// 2.16 declare-reduction -> DECLARE REDUCTION (reduction-identifier : type-list
5191// : combiner) [initializer-clause]
5193 WRAPPER_CLASS_BOILERPLATE(
5195 CharBlock source;
5196};
5197
5198// 2.8.2 declare-simd -> DECLARE SIMD [(proc-name)] [declare-simd-clause[ [,]
5199// declare-simd-clause]...]
5201 WRAPPER_CLASS_BOILERPLATE(
5203 CharBlock source;
5204};
5205
5206// ref: [6.0:301-303]
5207//
5208// groupprivate-directive ->
5209// GROUPPRIVATE (variable-list-item...) // since 6.0
5211 WRAPPER_CLASS_BOILERPLATE(OpenMPGroupprivate, OmpDirectiveSpecification);
5212 CharBlock source;
5213};
5214
5215// 2.4 requires -> REQUIRES requires-clause[ [ [,] requires-clause]...]
5217 WRAPPER_CLASS_BOILERPLATE(OpenMPRequiresConstruct, OmpDirectiveSpecification);
5218 CharBlock source;
5219};
5220
5221// 2.15.2 threadprivate -> THREADPRIVATE (variable-name-list)
5223 WRAPPER_CLASS_BOILERPLATE(OpenMPThreadprivate, OmpDirectiveSpecification);
5224 CharBlock source;
5225};
5226
5227// Ref: [4.5:310-312], [5.0:156-158], [5.1:181-184], [5.2:176-177],
5228// [6.0:310-312]
5229//
5230// allocate-directive ->
5231// ALLOCATE (variable-list-item...) | // since 4.5
5232// ALLOCATE (variable-list-item...) // since 5.0, until 5.1
5233// ...
5234// allocate-stmt
5235//
5236// The first form is the "declarative-allocate", and is a declarative
5237// directive. The second is the "executable-allocate" and is an executable
5238// directive. The executable form was deprecated in 5.2.
5239//
5240// The executable-allocate consists of several ALLOCATE directives. Since
5241// in the parse tree every type corresponding to a directive only corresponds
5242// to a single directive, the executable form is represented by a sequence
5243// of nested OmpAlocateDirectives, e.g.
5244// !$OMP ALLOCATE(x)
5245// !$OMP ALLOCATE(y)
5246// ALLOCATE(x, y)
5247// will become
5248// OmpAllocateDirective
5249// |- ALLOCATE(x) // begin directive
5250// `- OmpAllocateDirective // block
5251// |- ALLOCATE(y) // begin directive
5252// `- ALLOCATE(x, y) // block
5253//
5254// The block in the declarative-allocate will be empty.
5256 INHERITED_TUPLE_CLASS_BOILERPLATE(OmpAllocateDirective, OmpBlockConstruct);
5257};
5258
5270
5272 INHERITED_TUPLE_CLASS_BOILERPLATE(OpenMPCriticalConstruct, OmpBlockConstruct);
5273};
5274
5275// Ref: [5.2:180-181], [6.0:315]
5276//
5277// allocators-construct ->
5278// ALLOCATORS [allocate-clause...]
5279// block
5280// [END ALLOCATORS]
5282 INHERITED_TUPLE_CLASS_BOILERPLATE(
5284};
5285
5287 llvm::omp::Clause GetKind() const;
5288 bool IsCapture() const;
5289 bool IsCompare() const;
5290 INHERITED_TUPLE_CLASS_BOILERPLATE(OpenMPAtomicConstruct, OmpBlockConstruct);
5291
5292 // Information filled out during semantic checks to avoid duplication
5293 // of analyses.
5294 struct Analysis {
5295 static constexpr int None = 0;
5296 static constexpr int Read = 1;
5297 static constexpr int Write = 2;
5298 static constexpr int Update = Read | Write;
5299 static constexpr int Action = 3; // Bitmask for None, Read, Write, Update
5300 static constexpr int IfTrue = 4;
5301 static constexpr int IfFalse = 8;
5302 static constexpr int Condition = 12; // Bitmask for IfTrue, IfFalse
5303
5304 struct Op {
5305 int what;
5306 TypedAssignment assign;
5307 };
5308 TypedExpr atom, cond;
5309 Op op0, op1;
5310 };
5311
5312 mutable Analysis analysis;
5313};
5314
5315// 2.14.2 cancellation-point -> CANCELLATION POINT construct-type-clause
5317 WRAPPER_CLASS_BOILERPLATE(
5319 CharBlock source;
5320};
5321
5322// 2.14.1 cancel -> CANCEL construct-type-clause [ [,] if-clause]
5324 WRAPPER_CLASS_BOILERPLATE(OpenMPCancelConstruct, OmpDirectiveSpecification);
5325 CharBlock source;
5326};
5327
5328// Ref: [5.0:254-255], [5.1:287-288], [5.2:322-323]
5329//
5330// depobj-construct -> DEPOBJ(depend-object) depobj-clause // since 5.0
5331// depobj-clause -> depend-clause | // until 5.2
5332// destroy-clause |
5333// update-clause
5335 WRAPPER_CLASS_BOILERPLATE(OpenMPDepobjConstruct, OmpDirectiveSpecification);
5336 CharBlock source;
5337};
5338
5339// Ref: [5.2: 200-201]
5340//
5341// dispatch-construct -> DISPATCH dispatch-clause
5342// dispatch-clause -> depend-clause |
5343// device-clause |
5344// is_device_ptr-clause |
5345// nocontext-clause |
5346// novariants-clause |
5347// nowait-clause
5349 INHERITED_TUPLE_CLASS_BOILERPLATE(OpenMPDispatchConstruct, OmpBlockConstruct);
5350};
5351
5352// [4.5:162-165], [5.0:242-246], [5.1:275-279], [5.2:315-316], [6.0:498-500]
5353//
5354// flush-construct ->
5355// FLUSH [(list)] // since 4.5, until 4.5
5356// flush-construct ->
5357// FLUSH [memory-order-clause] [(list)] // since 5.0, until 5.1
5358// flush-construct ->
5359// FLUSH [(list)] [clause-list] // since 5.2
5360//
5361// memory-order-clause -> // since 5.0, until 5.1
5362// ACQ_REL | RELEASE | ACQUIRE | // since 5.0
5363// SEQ_CST // since 5.1
5365 WRAPPER_CLASS_BOILERPLATE(OpenMPFlushConstruct, OmpDirectiveSpecification);
5366 CharBlock source;
5367};
5368
5369// Ref: [5.1:217-220], [5.2:291-292]
5370//
5371// interop -> INTEROP clause[ [ [,] clause]...]
5373 WRAPPER_CLASS_BOILERPLATE(OpenMPInteropConstruct, OmpDirectiveSpecification);
5374 CharBlock source;
5375};
5376
5378 WRAPPER_CLASS_BOILERPLATE(
5380 CharBlock source;
5381};
5382
5391
5393 INHERITED_TUPLE_CLASS_BOILERPLATE(OmpBeginLoopDirective, OmpBeginDirective);
5394};
5395
5397 INHERITED_TUPLE_CLASS_BOILERPLATE(OmpEndLoopDirective, OmpEndDirective);
5398};
5399
5400// OpenMP directives enclosing do loop
5401struct OpenMPLoopConstruct {
5402 TUPLE_CLASS_BOILERPLATE(OpenMPLoopConstruct);
5403 OpenMPLoopConstruct(OmpBeginLoopDirective &&a)
5404 : t({std::move(a), Block{}, std::nullopt}) {}
5405
5406 const OmpBeginLoopDirective &BeginDir() const {
5407 return std::get<OmpBeginLoopDirective>(t);
5408 }
5409 const std::optional<OmpEndLoopDirective> &EndDir() const {
5410 return std::get<std::optional<OmpEndLoopDirective>>(t);
5411 }
5412 const DoConstruct *GetNestedLoop() const;
5413 const OpenMPLoopConstruct *GetNestedConstruct() const;
5414
5415 CharBlock source;
5416 std::tuple<OmpBeginLoopDirective, Block, std::optional<OmpEndLoopDirective>>
5417 t;
5418};
5419
5420// Lookahead class to identify execution-part OpenMP constructs without
5421// parsing the entire OpenMP construct.
5423 WRAPPER_CLASS_BOILERPLATE(OpenMPExecDirective, OmpDirectiveName);
5424 CharBlock source;
5425};
5426
5436
5437// Orphaned !$OMP END <directive>, i.e. not being a part of a valid OpenMP
5438// construct.
5440 INHERITED_TUPLE_CLASS_BOILERPLATE(
5442};
5443
5444// Unrecognized string after the !$OMP sentinel.
5446 using EmptyTrait = std::true_type;
5447 CharBlock source;
5448};
5449
5450// Parse tree nodes for OpenACC 3.3 directives and clauses
5451
5453 UNION_CLASS_BOILERPLATE(AccObject);
5454 std::variant<Designator, /*common block*/ Name> u;
5455};
5456
5457WRAPPER_CLASS(AccObjectList, std::list<AccObject>);
5458
5459// OpenACC directive beginning or ending a block
5461 WRAPPER_CLASS_BOILERPLATE(AccBlockDirective, llvm::acc::Directive);
5462 CharBlock source;
5463};
5464
5466 WRAPPER_CLASS_BOILERPLATE(AccLoopDirective, llvm::acc::Directive);
5467 CharBlock source;
5468};
5469
5471 WRAPPER_CLASS_BOILERPLATE(AccStandaloneDirective, llvm::acc::Directive);
5472 CharBlock source;
5473};
5474
5475// 2.11 Combined constructs
5477 WRAPPER_CLASS_BOILERPLATE(AccCombinedDirective, llvm::acc::Directive);
5478 CharBlock source;
5479};
5480
5482 WRAPPER_CLASS_BOILERPLATE(AccDeclarativeDirective, llvm::acc::Directive);
5483 CharBlock source;
5484};
5485
5486// OpenACC Clauses
5488 UNION_CLASS_BOILERPLATE(AccBindClause);
5489 std::variant<Name, ScalarDefaultCharExpr> u;
5490 CharBlock source;
5491};
5492
5494 WRAPPER_CLASS_BOILERPLATE(AccDefaultClause, llvm::acc::DefaultValue);
5495 CharBlock source;
5496};
5497
5499 ENUM_CLASS(Modifier, ReadOnly, Zero)
5500 WRAPPER_CLASS_BOILERPLATE(AccDataModifier, Modifier);
5501 CharBlock source;
5502};
5503
5505 TUPLE_CLASS_BOILERPLATE(AccObjectListWithModifier);
5506 std::tuple<std::optional<AccDataModifier>, AccObjectList> t;
5507};
5508
5510 TUPLE_CLASS_BOILERPLATE(AccObjectListWithReduction);
5511 std::tuple<ReductionOperator, AccObjectList> t;
5512};
5513
5515 TUPLE_CLASS_BOILERPLATE(AccWaitArgument);
5516 std::tuple<std::optional<ScalarIntExpr>, std::list<ScalarIntExpr>> t;
5517};
5518
5520 WRAPPER_CLASS_BOILERPLATE(
5521 AccDeviceTypeExpr, Fortran::common::OpenACCDeviceType);
5522 CharBlock source;
5523};
5524
5526 WRAPPER_CLASS_BOILERPLATE(
5527 AccDeviceTypeExprList, std::list<AccDeviceTypeExpr>);
5528};
5529
5531 TUPLE_CLASS_BOILERPLATE(AccTileExpr);
5532 CharBlock source;
5533 std::tuple<std::optional<ScalarIntConstantExpr>> t; // if null then *
5534};
5535
5537 WRAPPER_CLASS_BOILERPLATE(AccTileExprList, std::list<AccTileExpr>);
5538};
5539
5541 WRAPPER_CLASS_BOILERPLATE(AccSizeExpr, std::optional<ScalarIntExpr>);
5542};
5543
5545 WRAPPER_CLASS_BOILERPLATE(AccSizeExprList, std::list<AccSizeExpr>);
5546};
5547
5549 UNION_CLASS_BOILERPLATE(AccSelfClause);
5550 std::variant<std::optional<ScalarLogicalExpr>, AccObjectList> u;
5551 CharBlock source;
5552};
5553
5554// num, dim, static
5556 UNION_CLASS_BOILERPLATE(AccGangArg);
5557 WRAPPER_CLASS(Num, ScalarIntExpr);
5558 WRAPPER_CLASS(Dim, ScalarIntExpr);
5559 WRAPPER_CLASS(Static, AccSizeExpr);
5560 std::variant<Num, Dim, Static> u;
5561 CharBlock source;
5562};
5563
5565 WRAPPER_CLASS_BOILERPLATE(AccGangArgList, std::list<AccGangArg>);
5566};
5567
5569 TUPLE_CLASS_BOILERPLATE(AccCollapseArg);
5570 std::tuple<bool, ScalarIntConstantExpr> t;
5571};
5572
5574 UNION_CLASS_BOILERPLATE(AccClause);
5575
5576#define GEN_FLANG_CLAUSE_PARSER_CLASSES
5577#include "llvm/Frontend/OpenACC/ACC.inc"
5578
5579 CharBlock source;
5580
5581 std::variant<
5582#define GEN_FLANG_CLAUSE_PARSER_CLASSES_LIST
5583#include "llvm/Frontend/OpenACC/ACC.inc"
5584 >
5585 u;
5586};
5587
5589 WRAPPER_CLASS_BOILERPLATE(AccClauseList, std::list<AccClause>);
5590 CharBlock source;
5591};
5592
5594 TUPLE_CLASS_BOILERPLATE(OpenACCRoutineConstruct);
5595 CharBlock source;
5596 std::tuple<Verbatim, std::optional<Name>, AccClauseList> t;
5597};
5598
5600 TUPLE_CLASS_BOILERPLATE(OpenACCCacheConstruct);
5601 CharBlock source;
5602 std::tuple<Verbatim, AccObjectListWithModifier> t;
5603};
5604
5606 TUPLE_CLASS_BOILERPLATE(OpenACCWaitConstruct);
5607 CharBlock source;
5608 std::tuple<Verbatim, std::optional<AccWaitArgument>, AccClauseList> t;
5609};
5610
5612 TUPLE_CLASS_BOILERPLATE(AccBeginLoopDirective);
5613 std::tuple<AccLoopDirective, AccClauseList> t;
5614 CharBlock source;
5615};
5616
5618 TUPLE_CLASS_BOILERPLATE(AccBeginBlockDirective);
5619 CharBlock source;
5620 std::tuple<AccBlockDirective, AccClauseList> t;
5621};
5622
5624 CharBlock source;
5625 WRAPPER_CLASS_BOILERPLATE(AccEndBlockDirective, AccBlockDirective);
5626};
5627
5628// ACC END ATOMIC
5629EMPTY_CLASS(AccEndAtomic);
5630
5631// ACC ATOMIC READ
5633 TUPLE_CLASS_BOILERPLATE(AccAtomicRead);
5634 std::tuple<Verbatim, AccClauseList, Statement<AssignmentStmt>,
5635 std::optional<AccEndAtomic>>
5636 t;
5637};
5638
5639// ACC ATOMIC WRITE
5641 TUPLE_CLASS_BOILERPLATE(AccAtomicWrite);
5642 std::tuple<Verbatim, AccClauseList, Statement<AssignmentStmt>,
5643 std::optional<AccEndAtomic>>
5644 t;
5645};
5646
5647// ACC ATOMIC UPDATE
5649 TUPLE_CLASS_BOILERPLATE(AccAtomicUpdate);
5650 std::tuple<std::optional<Verbatim>, AccClauseList, Statement<AssignmentStmt>,
5651 std::optional<AccEndAtomic>>
5652 t;
5653};
5654
5655// ACC ATOMIC CAPTURE
5657 TUPLE_CLASS_BOILERPLATE(AccAtomicCapture);
5658 WRAPPER_CLASS(Stmt1, Statement<AssignmentStmt>);
5659 WRAPPER_CLASS(Stmt2, Statement<AssignmentStmt>);
5660 std::tuple<Verbatim, AccClauseList, Stmt1, Stmt2, AccEndAtomic> t;
5661};
5662
5664 UNION_CLASS_BOILERPLATE(OpenACCAtomicConstruct);
5665 std::variant<AccAtomicRead, AccAtomicWrite, AccAtomicCapture, AccAtomicUpdate>
5666 u;
5667 CharBlock source;
5668};
5669
5671 TUPLE_CLASS_BOILERPLATE(OpenACCBlockConstruct);
5672 std::tuple<AccBeginBlockDirective, Block, AccEndBlockDirective> t;
5673};
5674
5676 TUPLE_CLASS_BOILERPLATE(OpenACCStandaloneDeclarativeConstruct);
5677 CharBlock source;
5678 std::tuple<AccDeclarativeDirective, AccClauseList> t;
5679};
5680
5682 TUPLE_CLASS_BOILERPLATE(AccBeginCombinedDirective);
5683 CharBlock source;
5684 std::tuple<AccCombinedDirective, AccClauseList> t;
5685};
5686
5688 WRAPPER_CLASS_BOILERPLATE(AccEndCombinedDirective, AccCombinedDirective);
5689 CharBlock source;
5690};
5691
5692struct OpenACCCombinedConstruct {
5693 TUPLE_CLASS_BOILERPLATE(OpenACCCombinedConstruct);
5694 CharBlock source;
5695 OpenACCCombinedConstruct(AccBeginCombinedDirective &&a)
5696 : t({std::move(a), std::nullopt, std::nullopt}) {}
5697 std::tuple<AccBeginCombinedDirective, std::optional<DoConstruct>,
5698 std::optional<AccEndCombinedDirective>>
5699 t;
5700};
5701
5703 UNION_CLASS_BOILERPLATE(OpenACCDeclarativeConstruct);
5704 CharBlock source;
5705 std::variant<OpenACCStandaloneDeclarativeConstruct, OpenACCRoutineConstruct>
5706 u;
5707};
5708
5709// OpenACC directives enclosing do loop
5710EMPTY_CLASS(AccEndLoop);
5711struct OpenACCLoopConstruct {
5712 TUPLE_CLASS_BOILERPLATE(OpenACCLoopConstruct);
5713 OpenACCLoopConstruct(AccBeginLoopDirective &&a)
5714 : t({std::move(a), std::nullopt, std::nullopt}) {}
5715 std::tuple<AccBeginLoopDirective, std::optional<DoConstruct>,
5716 std::optional<AccEndLoop>>
5717 t;
5718};
5719
5721 WRAPPER_CLASS_BOILERPLATE(OpenACCEndConstruct, llvm::acc::Directive);
5722 CharBlock source;
5723};
5724
5726 TUPLE_CLASS_BOILERPLATE(OpenACCStandaloneConstruct);
5727 CharBlock source;
5728 std::tuple<AccStandaloneDirective, AccClauseList> t;
5729};
5730
5738
5739// CUF-kernel-do-construct ->
5740// !$CUF KERNEL DO [ (scalar-int-constant-expr) ]
5741// <<< grid, block [, stream] >>>
5742// [ cuf-reduction... ]
5743// do-construct
5744// star-or-expr -> * | scalar-int-expr
5745// grid -> * | scalar-int-expr | ( star-or-expr-list )
5746// block -> * | scalar-int-expr | ( star-or-expr-list )
5747// stream -> 0, scalar-int-expr | STREAM = scalar-int-expr
5748// cuf-reduction -> [ REDUCE | REDUCTION ] (
5749// reduction-op : scalar-variable-list )
5750
5752 TUPLE_CLASS_BOILERPLATE(CUFReduction);
5753 using Operator = ReductionOperator;
5754 std::tuple<Operator, std::list<Scalar<Variable>>> t;
5755};
5756
5758 TUPLE_CLASS_BOILERPLATE(CUFKernelDoConstruct);
5759 WRAPPER_CLASS(StarOrExpr, std::optional<ScalarIntExpr>);
5761 TUPLE_CLASS_BOILERPLATE(LaunchConfiguration);
5762 std::tuple<std::list<StarOrExpr>, std::list<StarOrExpr>,
5763 std::optional<ScalarIntExpr>>
5764 t;
5765 };
5766 struct Directive {
5767 TUPLE_CLASS_BOILERPLATE(Directive);
5768 CharBlock source;
5769 std::tuple<std::optional<ScalarIntConstantExpr>,
5770 std::optional<LaunchConfiguration>, std::list<CUFReduction>>
5771 t;
5772 };
5773 std::tuple<Directive, std::optional<DoConstruct>> t;
5774};
5775
5776} // namespace Fortran::parser
5777#endif // FORTRAN_PARSER_PARSE_TREE_H_
Definition enum-set.h:28
Definition indirection.h:127
Definition indirection.h:31
Definition reference.h:18
Definition call.h:233
Definition char-block.h:28
Definition parse-state.h:35
Definition symbol.h:809
Definition FIRType.h:92
Definition call.h:34
Definition check-expression.h:19
Definition expression.h:896
Definition format-specification.h:135
Definition parse-tree.h:1275
Definition parse-tree.h:1282
Definition parse-tree.h:1246
Definition parse-tree.h:1235
Definition parse-tree.h:1234
Definition parse-tree.h:5656
Definition parse-tree.h:5632
Definition parse-tree.h:5648
Definition parse-tree.h:5640
Definition parse-tree.h:5617
Definition parse-tree.h:5681
Definition parse-tree.h:5611
Definition parse-tree.h:5487
Definition parse-tree.h:5460
Definition parse-tree.h:5588
Definition parse-tree.h:5573
Definition parse-tree.h:5568
Definition parse-tree.h:5476
Definition parse-tree.h:5498
Definition parse-tree.h:5481
Definition parse-tree.h:5493
Definition parse-tree.h:5525
Definition parse-tree.h:5519
Definition parse-tree.h:5623
Definition parse-tree.h:5687
Definition parse-tree.h:5564
Definition parse-tree.h:5555
Definition parse-tree.h:5465
Definition parse-tree.h:5504
Definition parse-tree.h:5452
Definition parse-tree.h:5548
Definition parse-tree.h:5544
Definition parse-tree.h:5540
Definition parse-tree.h:5470
Definition parse-tree.h:5536
Definition parse-tree.h:5530
Definition parse-tree.h:5514
Definition parse-tree.h:895
Definition parse-tree.h:1399
Definition parse-tree.h:496
Definition parse-tree.h:3217
Definition parse-tree.h:3207
Definition parse-tree.h:1949
Definition parse-tree.h:1914
Definition parse-tree.h:1893
Definition parse-tree.h:1905
Definition parse-tree.h:1960
Definition parse-tree.h:1922
Definition parse-tree.h:3433
Definition parse-tree.h:1879
Definition parse-tree.h:1330
Definition parse-tree.h:3438
Definition parse-tree.h:3443
Definition parse-tree.h:1986
Definition parse-tree.h:2141
Definition parse-tree.h:2132
Definition parse-tree.h:2125
Definition parse-tree.h:1312
Definition parse-tree.h:1360
Definition parse-tree.h:3383
Definition parse-tree.h:1113
Definition parse-tree.h:1421
Definition parse-tree.h:1428
Definition parse-tree.h:2163
Definition parse-tree.h:2995
Definition parse-tree.h:1996
Definition parse-tree.h:3377
Definition parse-tree.h:5757
Definition parse-tree.h:5751
Definition parse-tree.h:3244
Definition parse-tree.h:3241
Definition parse-tree.h:3224
Definition parse-tree.h:2405
Definition parse-tree.h:2404
Definition parse-tree.h:2386
Definition parse-tree.h:2392
Definition parse-tree.h:2375
Definition parse-tree.h:2373
Definition parse-tree.h:2194
Definition parse-tree.h:2179
Definition parse-tree.h:670
Definition parse-tree.h:854
Definition parse-tree.h:686
Definition parse-tree.h:2663
Definition parse-tree.h:2662
Definition parse-tree.h:2171
Definition parse-tree.h:970
Definition parse-tree.h:1434
Definition parse-tree.h:1873
Definition parse-tree.h:1601
Definition parse-tree.h:1610
Definition parse-tree.h:1609
Definition parse-tree.h:3350
Definition parse-tree.h:3326
Definition parse-tree.h:840
Definition parse-tree.h:832
Definition parse-tree.h:981
Definition parse-tree.h:994
Definition parse-tree.h:1102
Definition parse-tree.h:1047
Definition parse-tree.h:1197
Definition parse-tree.h:2491
Definition parse-tree.h:2219
Definition parse-tree.h:2228
Definition parse-tree.h:2640
Definition parse-tree.h:2638
Definition parse-tree.h:303
Definition parse-tree.h:2210
Definition parse-tree.h:2201
Definition parse-tree.h:1055
Definition parse-tree.h:1491
Definition parse-tree.h:1503
Definition parse-tree.h:1789
Definition parse-tree.h:1462
Definition parse-tree.h:1511
Definition parse-tree.h:1477
Definition parse-tree.h:1517
Definition parse-tree.h:1483
Definition parse-tree.h:1980
Definition parse-tree.h:437
Definition parse-tree.h:764
Definition parse-tree.h:327
Definition parse-tree.h:612
Definition parse-tree.h:1182
Definition parse-tree.h:746
Definition parse-tree.h:912
Definition parse-tree.h:1828
Definition parse-tree.h:1528
Definition parse-tree.h:2306
Definition parse-tree.h:3125
Definition parse-tree.h:2326
Definition parse-tree.h:2188
Definition parse-tree.h:1375
Definition parse-tree.h:3295
Definition parse-tree.h:1226
Definition parse-tree.h:1212
Definition parse-tree.h:2545
Definition parse-tree.h:2551
Definition parse-tree.h:2559
Definition parse-tree.h:529
Definition parse-tree.h:554
Definition parse-tree.h:964
Definition parse-tree.h:951
Definition parse-tree.h:1741
Definition parse-tree.h:1714
Definition parse-tree.h:1755
Definition parse-tree.h:1720
Definition parse-tree.h:1759
Definition parse-tree.h:1696
Definition parse-tree.h:1711
Definition parse-tree.h:1747
Definition parse-tree.h:1729
Definition parse-tree.h:1735
Definition parse-tree.h:1738
Definition parse-tree.h:1701
Definition parse-tree.h:1726
Definition parse-tree.h:1723
Definition parse-tree.h:1708
Definition parse-tree.h:1750
Definition parse-tree.h:1732
Definition parse-tree.h:1690
Definition parse-tree.h:1687
Definition parse-tree.h:1744
Definition parse-tree.h:1681
Definition parse-tree.h:1705
Definition parse-tree.h:1717
Definition parse-tree.h:1684
Definition parse-tree.h:1677
Definition parse-tree.h:1041
Definition parse-tree.h:2082
Definition parse-tree.h:2098
Definition parse-tree.h:2076
Definition parse-tree.h:2111
Definition parse-tree.h:2088
Definition parse-tree.h:2571
Definition parse-tree.h:2674
Definition parse-tree.h:3229
Definition parse-tree.h:3114
Definition parse-tree.h:3261
Definition parse-tree.h:3008
Definition parse-tree.h:3023
Definition parse-tree.h:2345
Definition parse-tree.h:2341
Definition parse-tree.h:2340
Definition parse-tree.h:2356
Definition parse-tree.h:2319
Definition parse-tree.h:1661
Definition parse-tree.h:1671
Definition parse-tree.h:419
Definition parse-tree.h:1585
Definition parse-tree.h:1594
Definition parse-tree.h:625
Definition parse-tree.h:1012
Definition parse-tree.h:2770
Definition parse-tree.h:2714
Definition parse-tree.h:2857
Definition parse-tree.h:2865
Definition parse-tree.h:2870
Definition parse-tree.h:2855
Definition parse-tree.h:2885
Definition parse-tree.h:2883
Definition parse-tree.h:790
Definition parse-tree.h:311
Definition parse-tree.h:1338
Definition parse-tree.h:1537
Definition parse-tree.h:3181
Definition parse-tree.h:3148
Definition parse-tree.h:3154
Definition parse-tree.h:3146
Definition parse-tree.h:3171
Definition parse-tree.h:475
Definition parse-tree.h:463
Definition parse-tree.h:706
Definition parse-tree.h:704
Definition parse-tree.h:2698
Definition parse-tree.h:2696
Definition parse-tree.h:2610
Definition parse-tree.h:777
Definition parse-tree.h:658
Definition parse-tree.h:2283
Definition parse-tree.h:1291
Definition parse-tree.h:676
Definition parse-tree.h:1579
Definition parse-tree.h:886
Definition parse-tree.h:2255
Definition parse-tree.h:2251
Definition parse-tree.h:2586
Definition parse-tree.h:2585
Definition parse-tree.h:868
Definition parse-tree.h:319
Definition parse-tree.h:1258
Definition parse-tree.h:2273
Definition parse-tree.h:2271
Definition parse-tree.h:2904
Definition parse-tree.h:3399
Definition parse-tree.h:2043
Definition parse-tree.h:2928
Definition parse-tree.h:2918
Definition parse-tree.h:2939
Definition parse-tree.h:587
Definition parse-tree.h:1297
Definition parse-tree.h:639
Definition parse-tree.h:638
Definition parse-tree.h:2289
Definition parse-tree.h:2513
Definition parse-tree.h:1408
Definition parse-tree.h:4264
Definition parse-tree.h:4268
Definition parse-tree.h:4283
Definition parse-tree.h:4290
Definition parse-tree.h:4298
Definition parse-tree.h:4313
Definition parse-tree.h:5255
Definition parse-tree.h:4320
Definition parse-tree.h:4329
Definition parse-tree.h:5049
Definition parse-tree.h:5392
Definition parse-tree.h:5120
Definition parse-tree.h:4352
Definition parse-tree.h:5059
Definition parse-tree.h:5018
Definition parse-tree.h:5002
Definition parse-tree.h:4367
Definition parse-tree.h:3568
Definition parse-tree.h:4375
Definition parse-tree.h:4392
Definition parse-tree.h:4410
Definition parse-tree.h:4469
Definition parse-tree.h:4467
Definition parse-tree.h:4491
Definition parse-tree.h:4499
Definition parse-tree.h:4509
Definition parse-tree.h:4519
Definition parse-tree.h:4527
Definition parse-tree.h:3469
Definition parse-tree.h:5025
Definition parse-tree.h:4482
Definition parse-tree.h:4449
Definition parse-tree.h:4542
Definition parse-tree.h:5054
Definition parse-tree.h:5396
Definition parse-tree.h:5125
Definition parse-tree.h:4553
Definition parse-tree.h:5087
Definition parse-tree.h:4561
Definition parse-tree.h:4574
Definition parse-tree.h:4585
Definition parse-tree.h:4595
Definition parse-tree.h:4603
Definition parse-tree.h:4608
Definition parse-tree.h:4616
Definition parse-tree.h:4632
Definition parse-tree.h:4655
Definition parse-tree.h:4621
Definition parse-tree.h:4645
Definition parse-tree.h:4662
Definition parse-tree.h:3580
Definition parse-tree.h:4422
Definition parse-tree.h:4440
Definition parse-tree.h:4431
Definition parse-tree.h:4671
Definition parse-tree.h:4686
Definition parse-tree.h:4697
Definition parse-tree.h:4722
Definition parse-tree.h:4734
Definition parse-tree.h:4743
Definition parse-tree.h:5072
Definition parse-tree.h:5081
Definition parse-tree.h:4767
Definition parse-tree.h:4779
Definition parse-tree.h:4791
Definition parse-tree.h:3514
Definition parse-tree.h:3505
Definition parse-tree.h:3502
Definition parse-tree.h:4802
Definition parse-tree.h:4815
Definition parse-tree.h:4827
Definition parse-tree.h:4838
Definition parse-tree.h:3558
Definition parse-tree.h:4848
Definition parse-tree.h:4857
Definition parse-tree.h:4869
Definition parse-tree.h:4880
Definition parse-tree.h:4887
Definition parse-tree.h:3518
Definition parse-tree.h:3540
Definition parse-tree.h:3527
Definition parse-tree.h:4896
Definition parse-tree.h:4907
Definition parse-tree.h:4916
Definition parse-tree.h:4931
Definition parse-tree.h:4941
Definition parse-tree.h:3494
Definition parse-tree.h:3487
Definition parse-tree.h:4950
Definition parse-tree.h:4975
Definition parse-tree.h:4997
Definition parse-tree.h:4986
Definition parse-tree.h:3039
Definition parse-tree.h:5663
Definition parse-tree.h:5670
Definition parse-tree.h:5599
Definition parse-tree.h:5692
Definition parse-tree.h:5731
Definition parse-tree.h:5720
Definition parse-tree.h:5711
Definition parse-tree.h:5593
Definition parse-tree.h:5605
Definition parse-tree.h:5281
Definition parse-tree.h:5114
Definition parse-tree.h:5286
Definition parse-tree.h:5323
Definition parse-tree.h:5427
Definition parse-tree.h:5271
Definition parse-tree.h:5102
Definition parse-tree.h:5334
Definition parse-tree.h:5348
Definition parse-tree.h:5422
Definition parse-tree.h:5364
Definition parse-tree.h:5210
Definition parse-tree.h:5372
Definition parse-tree.h:5445
Definition parse-tree.h:5401
Definition parse-tree.h:5216
Definition parse-tree.h:5134
Definition parse-tree.h:5140
Definition parse-tree.h:5383
Definition parse-tree.h:5222
Definition parse-tree.h:5091
Definition parse-tree.h:376
Definition parse-tree.h:2775
Definition parse-tree.h:2738
Definition parse-tree.h:2964
Definition parse-tree.h:1783
Definition parse-tree.h:2008
Definition parse-tree.h:1547
Definition parse-tree.h:1969
Definition parse-tree.h:2801
Definition parse-tree.h:3084
Definition parse-tree.h:2759
Definition parse-tree.h:925
Definition parse-tree.h:3062
Definition parse-tree.h:1066
Definition parse-tree.h:1094
Definition parse-tree.h:1868
Definition parse-tree.h:1086
Definition parse-tree.h:1080
Definition parse-tree.h:1073
Definition parse-tree.h:3072
Definition parse-tree.h:3196
Definition parse-tree.h:3164
Definition parse-tree.h:571
Definition parse-tree.h:2722
Definition parse-tree.h:809
Definition parse-tree.h:2240
Definition parse-tree.h:2952
Definition parse-tree.h:2956
Definition parse-tree.h:2950
Definition parse-tree.h:1560
Definition parse-tree.h:295
Definition parse-tree.h:1646
Definition parse-tree.h:2363
Definition parse-tree.h:2428
Definition parse-tree.h:2427
Definition parse-tree.h:2439
Definition parse-tree.h:2418
Definition parse-tree.h:2473
Definition parse-tree.h:2453
Definition parse-tree.h:2119
Definition parse-tree.h:3287
Definition parse-tree.h:398
Definition parse-tree.h:451
Definition parse-tree.h:1938
Definition parse-tree.h:359
Definition parse-tree.h:3305
Definition parse-tree.h:2505
Definition parse-tree.h:1858
Definition parse-tree.h:1203
Definition parse-tree.h:3420
Definition parse-tree.h:3392
Definition parse-tree.h:3415
Definition parse-tree.h:2970
Definition parse-tree.h:2981
Definition parse-tree.h:3133
Definition parse-tree.h:3271
Definition parse-tree.h:1637
Definition parse-tree.h:1820
Definition parse-tree.h:1628
Definition parse-tree.h:1806
Definition parse-tree.h:2524
Definition parse-tree.h:2523
Definition parse-tree.h:2536
Definition parse-tree.h:903
Definition parse-tree.h:1146
Definition parse-tree.h:1159
Definition parse-tree.h:1121
Definition parse-tree.h:1168
Definition parse-tree.h:1131
Definition parse-tree.h:1389
Definition parse-tree.h:2463
Definition parse-tree.h:2462
Definition parse-tree.h:931
Definition parse-tree.h:939
Definition parse-tree.h:740
Definition parse-tree.h:649
Definition parse-tree.h:753
Definition parse-tree.h:3408
Definition parse-tree.h:354
Definition parse-tree.h:2595
Definition parse-tree.h:796
Definition parse-tree.h:3048
Definition parse-tree.h:1836
Definition parse-tree.h:726
Definition parse-tree.h:731
Definition parse-tree.h:282
Definition parse-tree.h:2785
Definition parse-tree.h:2034
Definition parse-tree.h:2027
Definition parse-tree.h:2063
Definition parse-tree.h:2058
Definition parse-tree.h:2021
Definition parse-tree.h:2744
Definition parse-tree.h:3633
Definition parse-tree.h:3592
Definition parse-tree.h:3587
Definition parse-tree.h:3797
Definition parse-tree.h:3806
Definition parse-tree.h:3951
Definition parse-tree.h:3983
Definition parse-tree.h:4005
Definition parse-tree.h:4027
Definition parse-tree.h:4053
Definition parse-tree.h:4074
Definition parse-tree.h:4061
Definition parse-tree.h:4145
Definition parse-tree.h:4186
Definition parse-tree.h:4196
Definition parse-tree.h:3680
Definition parse-tree.h:3663
Definition parse-tree.h:3704
Definition parse-tree.h:3670
Definition parse-tree.h:3731
Definition parse-tree.h:3743
Definition parse-tree.h:3756
Definition parse-tree.h:3765