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