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