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// NEWUNIT = scalar-int-variable | PAD = scalar-default-char-expr |
2634// POSITION = scalar-default-char-expr | RECL = scalar-int-expr |
2635// ROUND = scalar-default-char-expr | SIGN = scalar-default-char-expr |
2636// STATUS = scalar-default-char-expr
2637// @ | CARRIAGECONTROL = scalar-default-char-variable
2638// | CONVERT = scalar-default-char-variable
2639// | DISPOSE = scalar-default-char-variable
2640WRAPPER_CLASS(StatusExpr, ScalarDefaultCharExpr);
2641WRAPPER_CLASS(ErrLabel, Label);
2642
2644 UNION_CLASS_BOILERPLATE(ConnectSpec);
2645 struct CharExpr {
2646 ENUM_CLASS(Kind, Access, Action, Asynchronous, Blank, Decimal, Delim,
2647 Encoding, Form, Pad, Position, Round, Sign,
2648 /* extensions: */ Carriagecontrol, Convert, Dispose)
2649 TUPLE_CLASS_BOILERPLATE(CharExpr);
2650 std::tuple<Kind, ScalarDefaultCharExpr> t;
2651 };
2652 WRAPPER_CLASS(Recl, ScalarIntExpr);
2653 WRAPPER_CLASS(Newunit, ScalarIntVariable);
2654 std::variant<FileUnitNumber, FileNameExpr, CharExpr, MsgVariable,
2655 StatVariable, Recl, Newunit, ErrLabel, StatusExpr>
2656 u;
2657};
2658
2659// R1204 open-stmt -> OPEN ( connect-spec-list )
2660WRAPPER_CLASS(OpenStmt, std::list<ConnectSpec>);
2661
2662// R1208 close-stmt -> CLOSE ( close-spec-list )
2663// R1209 close-spec ->
2664// [UNIT =] file-unit-number | IOSTAT = scalar-int-variable |
2665// IOMSG = iomsg-variable | ERR = label |
2666// STATUS = scalar-default-char-expr
2668 struct CloseSpec {
2669 UNION_CLASS_BOILERPLATE(CloseSpec);
2670 std::variant<FileUnitNumber, StatVariable, MsgVariable, ErrLabel,
2671 StatusExpr>
2672 u;
2673 };
2674 WRAPPER_CLASS_BOILERPLATE(CloseStmt, std::list<CloseSpec>);
2675};
2676
2677// R1215 format -> default-char-expr | label | *
2678// deprecated(ASSIGN): | scalar-int-name
2679struct Format {
2680 UNION_CLASS_BOILERPLATE(Format);
2681 std::variant<Expr, Label, Star> u;
2682};
2683
2684// R1214 id-variable -> scalar-int-variable
2685WRAPPER_CLASS(IdVariable, ScalarIntVariable);
2686
2687// R1213 io-control-spec ->
2688// [UNIT =] io-unit | [FMT =] format | [NML =] namelist-group-name |
2689// ADVANCE = scalar-default-char-expr |
2690// ASYNCHRONOUS = scalar-default-char-constant-expr |
2691// BLANK = scalar-default-char-expr |
2692// DECIMAL = scalar-default-char-expr |
2693// DELIM = scalar-default-char-expr | END = label | EOR = label |
2694// ERR = label | ID = id-variable | IOMSG = iomsg-variable |
2695// IOSTAT = scalar-int-variable | PAD = scalar-default-char-expr |
2696// POS = scalar-int-expr | REC = scalar-int-expr |
2697// ROUND = scalar-default-char-expr | SIGN = scalar-default-char-expr |
2698// SIZE = scalar-int-variable
2699WRAPPER_CLASS(EndLabel, Label);
2700WRAPPER_CLASS(EorLabel, Label);
2702 UNION_CLASS_BOILERPLATE(IoControlSpec);
2703 struct CharExpr {
2704 ENUM_CLASS(Kind, Advance, Blank, Decimal, Delim, Pad, Round, Sign)
2705 TUPLE_CLASS_BOILERPLATE(CharExpr);
2706 std::tuple<Kind, ScalarDefaultCharExpr> t;
2707 };
2708 WRAPPER_CLASS(Asynchronous, ScalarDefaultCharConstantExpr);
2709 WRAPPER_CLASS(Pos, ScalarIntExpr);
2710 WRAPPER_CLASS(Rec, ScalarIntExpr);
2711 WRAPPER_CLASS(Size, ScalarIntVariable);
2712 std::variant<IoUnit, Format, Name, CharExpr, Asynchronous, EndLabel, EorLabel,
2713 ErrLabel, IdVariable, MsgVariable, StatVariable, Pos, Rec, Size,
2714 ErrorRecovery>
2715 u;
2716};
2717
2718// R1216 input-item -> variable | io-implied-do
2720 UNION_CLASS_BOILERPLATE(InputItem);
2721 std::variant<Variable, common::Indirection<InputImpliedDo>> u;
2722};
2723
2724// R1210 read-stmt ->
2725// READ ( io-control-spec-list ) [input-item-list] |
2726// READ format [, input-item-list]
2727struct ReadStmt {
2728 BOILERPLATE(ReadStmt);
2729 ReadStmt(std::optional<IoUnit> &&i, std::optional<Format> &&f,
2730 std::list<IoControlSpec> &&cs, std::list<InputItem> &&its)
2731 : iounit{std::move(i)}, format{std::move(f)}, controls(std::move(cs)),
2732 items(std::move(its)) {}
2733 std::optional<IoUnit> iounit; // if first in controls without UNIT= &/or
2734 // followed by untagged format/namelist
2735 std::optional<Format> format; // if second in controls without FMT=/NML=, or
2736 // no (io-control-spec-list); might be
2737 // an untagged namelist group name
2738 std::list<IoControlSpec> controls;
2739 std::list<InputItem> items;
2740};
2741
2742// R1217 output-item -> expr | io-implied-do
2744 UNION_CLASS_BOILERPLATE(OutputItem);
2745 std::variant<Expr, common::Indirection<OutputImpliedDo>> u;
2746};
2747
2748// R1211 write-stmt -> WRITE ( io-control-spec-list ) [output-item-list]
2749struct WriteStmt {
2750 BOILERPLATE(WriteStmt);
2751 WriteStmt(std::optional<IoUnit> &&i, std::optional<Format> &&f,
2752 std::list<IoControlSpec> &&cs, std::list<OutputItem> &&its)
2753 : iounit{std::move(i)}, format{std::move(f)}, controls(std::move(cs)),
2754 items(std::move(its)) {}
2755 std::optional<IoUnit> iounit; // if first in controls without UNIT= &/or
2756 // followed by untagged format/namelist
2757 std::optional<Format> format; // if second in controls without FMT=/NML=;
2758 // might be an untagged namelist group, too
2759 std::list<IoControlSpec> controls;
2760 std::list<OutputItem> items;
2761};
2762
2763// R1212 print-stmt PRINT format [, output-item-list]
2765 TUPLE_CLASS_BOILERPLATE(PrintStmt);
2766 std::tuple<Format, std::list<OutputItem>> t;
2767};
2768
2769// R1220 io-implied-do-control ->
2770// do-variable = scalar-int-expr , scalar-int-expr [, scalar-int-expr]
2771using IoImpliedDoControl = LoopBounds<DoVariable, ScalarIntExpr>;
2772
2773// R1218 io-implied-do -> ( io-implied-do-object-list , io-implied-do-control )
2774// R1219 io-implied-do-object -> input-item | output-item
2776 TUPLE_CLASS_BOILERPLATE(InputImpliedDo);
2777 std::tuple<std::list<InputItem>, IoImpliedDoControl> t;
2778};
2779
2781 TUPLE_CLASS_BOILERPLATE(OutputImpliedDo);
2782 std::tuple<std::list<OutputItem>, IoImpliedDoControl> t;
2783};
2784
2785// R1223 wait-spec ->
2786// [UNIT =] file-unit-number | END = label | EOR = label | ERR = label |
2787// ID = scalar-int-expr | IOMSG = iomsg-variable |
2788// IOSTAT = scalar-int-variable
2789WRAPPER_CLASS(IdExpr, ScalarIntExpr);
2790struct WaitSpec {
2791 UNION_CLASS_BOILERPLATE(WaitSpec);
2792 std::variant<FileUnitNumber, EndLabel, EorLabel, ErrLabel, IdExpr,
2793 MsgVariable, StatVariable>
2794 u;
2795};
2796
2797// R1222 wait-stmt -> WAIT ( wait-spec-list )
2798WRAPPER_CLASS(WaitStmt, std::list<WaitSpec>);
2799
2800// R1227 position-spec ->
2801// [UNIT =] file-unit-number | IOMSG = iomsg-variable |
2802// IOSTAT = scalar-int-variable | ERR = label
2803// R1229 flush-spec ->
2804// [UNIT =] file-unit-number | IOSTAT = scalar-int-variable |
2805// IOMSG = iomsg-variable | ERR = label
2807 UNION_CLASS_BOILERPLATE(PositionOrFlushSpec);
2808 std::variant<FileUnitNumber, MsgVariable, StatVariable, ErrLabel> u;
2809};
2810
2811// R1224 backspace-stmt ->
2812// BACKSPACE file-unit-number | BACKSPACE ( position-spec-list )
2813WRAPPER_CLASS(BackspaceStmt, std::list<PositionOrFlushSpec>);
2814
2815// R1225 endfile-stmt ->
2816// ENDFILE file-unit-number | ENDFILE ( position-spec-list )
2817WRAPPER_CLASS(EndfileStmt, std::list<PositionOrFlushSpec>);
2818
2819// R1226 rewind-stmt -> REWIND file-unit-number | REWIND ( position-spec-list )
2820WRAPPER_CLASS(RewindStmt, std::list<PositionOrFlushSpec>);
2821
2822// R1228 flush-stmt -> FLUSH file-unit-number | FLUSH ( flush-spec-list )
2823WRAPPER_CLASS(FlushStmt, std::list<PositionOrFlushSpec>);
2824
2825// R1231 inquire-spec ->
2826// [UNIT =] file-unit-number | FILE = file-name-expr |
2827// ACCESS = scalar-default-char-variable |
2828// ACTION = scalar-default-char-variable |
2829// ASYNCHRONOUS = scalar-default-char-variable |
2830// BLANK = scalar-default-char-variable |
2831// DECIMAL = scalar-default-char-variable |
2832// DELIM = scalar-default-char-variable |
2833// DIRECT = scalar-default-char-variable |
2834// ENCODING = scalar-default-char-variable |
2835// ERR = label | EXIST = scalar-logical-variable |
2836// FORM = scalar-default-char-variable |
2837// FORMATTED = scalar-default-char-variable |
2838// ID = scalar-int-expr | IOMSG = iomsg-variable |
2839// IOSTAT = scalar-int-variable |
2840// NAME = scalar-default-char-variable |
2841// NAMED = scalar-logical-variable |
2842// NEXTREC = scalar-int-variable | NUMBER = scalar-int-variable |
2843// OPENED = scalar-logical-variable |
2844// PAD = scalar-default-char-variable |
2845// PENDING = scalar-logical-variable | POS = scalar-int-variable |
2846// POSITION = scalar-default-char-variable |
2847// READ = scalar-default-char-variable |
2848// READWRITE = scalar-default-char-variable |
2849// RECL = scalar-int-variable | ROUND = scalar-default-char-variable |
2850// SEQUENTIAL = scalar-default-char-variable |
2851// SIGN = scalar-default-char-variable |
2852// SIZE = scalar-int-variable |
2853// STREAM = scalar-default-char-variable |
2854// STATUS = scalar-default-char-variable |
2855// UNFORMATTED = scalar-default-char-variable |
2856// WRITE = scalar-default-char-variable
2857// @ | CARRIAGECONTROL = scalar-default-char-variable
2858// | CONVERT = scalar-default-char-variable
2859// | DISPOSE = scalar-default-char-variable
2861 UNION_CLASS_BOILERPLATE(InquireSpec);
2862 struct CharVar {
2863 ENUM_CLASS(Kind, Access, Action, Asynchronous, Blank, Decimal, Delim,
2864 Direct, Encoding, Form, Formatted, Iomsg, Name, Pad, Position, Read,
2865 Readwrite, Round, Sequential, Sign, Stream, Status, Unformatted, Write,
2866 /* extensions: */ Carriagecontrol, Convert, Dispose)
2867 TUPLE_CLASS_BOILERPLATE(CharVar);
2868 std::tuple<Kind, ScalarDefaultCharVariable> t;
2869 };
2870 struct IntVar {
2871 ENUM_CLASS(Kind, Iostat, Nextrec, Number, Pos, Recl, Size)
2872 TUPLE_CLASS_BOILERPLATE(IntVar);
2873 std::tuple<Kind, ScalarIntVariable> t;
2874 };
2875 struct LogVar {
2876 ENUM_CLASS(Kind, Exist, Named, Opened, Pending)
2877 TUPLE_CLASS_BOILERPLATE(LogVar);
2878 std::tuple<Kind, Scalar<Logical<Variable>>> t;
2879 };
2880 std::variant<FileUnitNumber, FileNameExpr, CharVar, IntVar, LogVar, IdExpr,
2881 ErrLabel>
2882 u;
2883};
2884
2885// R1230 inquire-stmt ->
2886// INQUIRE ( inquire-spec-list ) |
2887// INQUIRE ( IOLENGTH = scalar-int-variable ) output-item-list
2889 UNION_CLASS_BOILERPLATE(InquireStmt);
2890 struct Iolength {
2891 TUPLE_CLASS_BOILERPLATE(Iolength);
2892 std::tuple<ScalarIntVariable, std::list<OutputItem>> t;
2893 };
2894 std::variant<std::list<InquireSpec>, Iolength> u;
2895};
2896
2897// R1301 format-stmt -> FORMAT format-specification
2898WRAPPER_CLASS(FormatStmt, format::FormatSpecification);
2899
2900// R1402 program-stmt -> PROGRAM program-name
2901WRAPPER_CLASS(ProgramStmt, Name);
2902
2903// R1403 end-program-stmt -> END [PROGRAM [program-name]]
2904WRAPPER_CLASS(EndProgramStmt, std::optional<Name>);
2905
2906// R1401 main-program ->
2907// [program-stmt] [specification-part] [execution-part]
2908// [internal-subprogram-part] end-program-stmt
2910 TUPLE_CLASS_BOILERPLATE(MainProgram);
2911 std::tuple<std::optional<Statement<ProgramStmt>>, SpecificationPart,
2912 ExecutionPart, std::optional<InternalSubprogramPart>,
2914 t;
2915};
2916
2917// R1405 module-stmt -> MODULE module-name
2918WRAPPER_CLASS(ModuleStmt, Name);
2919
2920// R1408 module-subprogram ->
2921// function-subprogram | subroutine-subprogram |
2922// separate-module-subprogram
2924 UNION_CLASS_BOILERPLATE(ModuleSubprogram);
2925 std::variant<common::Indirection<FunctionSubprogram>,
2929 u;
2930};
2931
2932// R1407 module-subprogram-part -> contains-stmt [module-subprogram]...
2934 TUPLE_CLASS_BOILERPLATE(ModuleSubprogramPart);
2935 std::tuple<Statement<ContainsStmt>, std::list<ModuleSubprogram>> t;
2936};
2937
2938// R1406 end-module-stmt -> END [MODULE [module-name]]
2939WRAPPER_CLASS(EndModuleStmt, std::optional<Name>);
2940
2941// R1404 module ->
2942// module-stmt [specification-part] [module-subprogram-part]
2943// end-module-stmt
2944struct Module {
2945 TUPLE_CLASS_BOILERPLATE(Module);
2946 std::tuple<Statement<ModuleStmt>, SpecificationPart,
2947 std::optional<ModuleSubprogramPart>, Statement<EndModuleStmt>>
2948 t;
2949};
2950
2951// R1411 rename ->
2952// local-name => use-name |
2953// OPERATOR ( local-defined-operator ) =>
2954// OPERATOR ( use-defined-operator )
2955struct Rename {
2956 UNION_CLASS_BOILERPLATE(Rename);
2957 struct Names {
2958 TUPLE_CLASS_BOILERPLATE(Names);
2959 std::tuple<Name, Name> t;
2960 };
2961 struct Operators {
2962 TUPLE_CLASS_BOILERPLATE(Operators);
2963 std::tuple<DefinedOpName, DefinedOpName> t;
2964 };
2965 std::variant<Names, Operators> u;
2966};
2967
2968// R1418 parent-identifier -> ancestor-module-name [: parent-submodule-name]
2970 TUPLE_CLASS_BOILERPLATE(ParentIdentifier);
2971 std::tuple<Name, std::optional<Name>> t;
2972};
2973
2974// R1417 submodule-stmt -> SUBMODULE ( parent-identifier ) submodule-name
2976 TUPLE_CLASS_BOILERPLATE(SubmoduleStmt);
2977 std::tuple<ParentIdentifier, Name> t;
2978};
2979
2980// R1419 end-submodule-stmt -> END [SUBMODULE [submodule-name]]
2981WRAPPER_CLASS(EndSubmoduleStmt, std::optional<Name>);
2982
2983// R1416 submodule ->
2984// submodule-stmt [specification-part] [module-subprogram-part]
2985// end-submodule-stmt
2987 TUPLE_CLASS_BOILERPLATE(Submodule);
2988 std::tuple<Statement<SubmoduleStmt>, SpecificationPart,
2989 std::optional<ModuleSubprogramPart>, Statement<EndSubmoduleStmt>>
2990 t;
2991};
2992
2993// R1421 block-data-stmt -> BLOCK DATA [block-data-name]
2994WRAPPER_CLASS(BlockDataStmt, std::optional<Name>);
2995
2996// R1422 end-block-data-stmt -> END [BLOCK DATA [block-data-name]]
2997WRAPPER_CLASS(EndBlockDataStmt, std::optional<Name>);
2998
2999// R1420 block-data -> block-data-stmt [specification-part] end-block-data-stmt
3001 TUPLE_CLASS_BOILERPLATE(BlockData);
3002 std::tuple<Statement<BlockDataStmt>, SpecificationPart,
3004 t;
3005};
3006
3007// R1508 generic-spec ->
3008// generic-name | OPERATOR ( defined-operator ) |
3009// ASSIGNMENT ( = ) | defined-io-generic-spec
3010// R1509 defined-io-generic-spec ->
3011// READ ( FORMATTED ) | READ ( UNFORMATTED ) |
3012// WRITE ( FORMATTED ) | WRITE ( UNFORMATTED )
3014 UNION_CLASS_BOILERPLATE(GenericSpec);
3015 EMPTY_CLASS(Assignment);
3016 EMPTY_CLASS(ReadFormatted);
3017 EMPTY_CLASS(ReadUnformatted);
3018 EMPTY_CLASS(WriteFormatted);
3019 EMPTY_CLASS(WriteUnformatted);
3020 CharBlock source;
3021 std::variant<Name, DefinedOperator, Assignment, ReadFormatted,
3022 ReadUnformatted, WriteFormatted, WriteUnformatted>
3023 u;
3024};
3025
3026// R1510 generic-stmt ->
3027// GENERIC [, access-spec] :: generic-spec => specific-procedure-list
3029 TUPLE_CLASS_BOILERPLATE(GenericStmt);
3030 std::tuple<std::optional<AccessSpec>, GenericSpec, std::list<Name>> t;
3031};
3032
3033// R1503 interface-stmt -> INTERFACE [generic-spec] | ABSTRACT INTERFACE
3034struct InterfaceStmt {
3035 UNION_CLASS_BOILERPLATE(InterfaceStmt);
3036 // Workaround for clang with libstc++10 bug
3037 InterfaceStmt(Abstract x) : u{x} {}
3038
3039 std::variant<std::optional<GenericSpec>, Abstract> u;
3040};
3041
3042// R1412 only -> generic-spec | only-use-name | rename
3043// R1413 only-use-name -> use-name
3044struct Only {
3045 UNION_CLASS_BOILERPLATE(Only);
3046 std::variant<common::Indirection<GenericSpec>, Name, Rename> u;
3047};
3048
3049// R1409 use-stmt ->
3050// USE [[, module-nature] ::] module-name [, rename-list] |
3051// USE [[, module-nature] ::] module-name , ONLY : [only-list]
3052// R1410 module-nature -> INTRINSIC | NON_INTRINSIC
3053struct UseStmt {
3054 BOILERPLATE(UseStmt);
3055 ENUM_CLASS(ModuleNature, Intrinsic, Non_Intrinsic) // R1410
3056 template <typename A>
3057 UseStmt(std::optional<ModuleNature> &&nat, Name &&n, std::list<A> &&x)
3058 : nature(std::move(nat)), moduleName(std::move(n)), u(std::move(x)) {}
3059 std::optional<ModuleNature> nature;
3060 Name moduleName;
3061 std::variant<std::list<Rename>, std::list<Only>> u;
3062};
3063
3064// R1514 proc-attr-spec ->
3065// access-spec | proc-language-binding-spec | INTENT ( intent-spec ) |
3066// OPTIONAL | POINTER | PROTECTED | SAVE
3068 UNION_CLASS_BOILERPLATE(ProcAttrSpec);
3069 std::variant<AccessSpec, LanguageBindingSpec, IntentSpec, Optional, Pointer,
3070 Protected, Save>
3071 u;
3072};
3073
3074// R1512 procedure-declaration-stmt ->
3075// PROCEDURE ( [proc-interface] ) [[, proc-attr-spec]... ::]
3076// proc-decl-list
3078 TUPLE_CLASS_BOILERPLATE(ProcedureDeclarationStmt);
3079 std::tuple<std::optional<ProcInterface>, std::list<ProcAttrSpec>,
3080 std::list<ProcDecl>>
3081 t;
3082};
3083
3084// R1527 prefix-spec ->
3085// declaration-type-spec | ELEMENTAL | IMPURE | MODULE |
3086// NON_RECURSIVE | PURE | RECURSIVE |
3087// (CUDA) ATTRIBUTES ( (DEVICE | GLOBAL | GRID_GLOBAL | HOST)... )
3088// LAUNCH_BOUNDS(expr-list) | CLUSTER_DIMS(expr-list)
3090 UNION_CLASS_BOILERPLATE(PrefixSpec);
3091 EMPTY_CLASS(Elemental);
3092 EMPTY_CLASS(Impure);
3093 EMPTY_CLASS(Module);
3094 EMPTY_CLASS(Non_Recursive);
3095 EMPTY_CLASS(Pure);
3096 EMPTY_CLASS(Recursive);
3097 WRAPPER_CLASS(Attributes, std::list<common::CUDASubprogramAttrs>);
3098 WRAPPER_CLASS(Launch_Bounds, std::list<ScalarIntConstantExpr>);
3099 WRAPPER_CLASS(Cluster_Dims, std::list<ScalarIntConstantExpr>);
3100 std::variant<DeclarationTypeSpec, Elemental, Impure, Module, Non_Recursive,
3101 Pure, Recursive, Attributes, Launch_Bounds, Cluster_Dims>
3102 u;
3103};
3104
3105// R1532 suffix ->
3106// proc-language-binding-spec [RESULT ( result-name )] |
3107// RESULT ( result-name ) [proc-language-binding-spec]
3108struct Suffix {
3109 TUPLE_CLASS_BOILERPLATE(Suffix);
3110 Suffix(LanguageBindingSpec &&lbs, std::optional<Name> &&rn)
3111 : t(std::move(rn), std::move(lbs)) {}
3112 std::tuple<std::optional<Name>, std::optional<LanguageBindingSpec>> t;
3113};
3114
3115// R1530 function-stmt ->
3116// [prefix] FUNCTION function-name ( [dummy-arg-name-list] ) [suffix]
3117// R1526 prefix -> prefix-spec [prefix-spec]...
3118// R1531 dummy-arg-name -> name
3120 TUPLE_CLASS_BOILERPLATE(FunctionStmt);
3121 std::tuple<std::list<PrefixSpec>, Name, std::list<Name>,
3122 std::optional<Suffix>>
3123 t;
3124};
3125
3126// R1533 end-function-stmt -> END [FUNCTION [function-name]]
3127WRAPPER_CLASS(EndFunctionStmt, std::optional<Name>);
3128
3129// R1536 dummy-arg -> dummy-arg-name | *
3130struct DummyArg {
3131 UNION_CLASS_BOILERPLATE(DummyArg);
3132 std::variant<Name, Star> u;
3133};
3134
3135// R1535 subroutine-stmt ->
3136// [prefix] SUBROUTINE subroutine-name [( [dummy-arg-list] )
3137// [proc-language-binding-spec]]
3139 TUPLE_CLASS_BOILERPLATE(SubroutineStmt);
3140 std::tuple<std::list<PrefixSpec>, Name, std::list<DummyArg>,
3141 std::optional<LanguageBindingSpec>>
3142 t;
3143};
3144
3145// R1537 end-subroutine-stmt -> END [SUBROUTINE [subroutine-name]]
3146WRAPPER_CLASS(EndSubroutineStmt, std::optional<Name>);
3147
3148// R1505 interface-body ->
3149// function-stmt [specification-part] end-function-stmt |
3150// subroutine-stmt [specification-part] end-subroutine-stmt
3152 UNION_CLASS_BOILERPLATE(InterfaceBody);
3153 struct Function {
3154 TUPLE_CLASS_BOILERPLATE(Function);
3155 std::tuple<Statement<FunctionStmt>, common::Indirection<SpecificationPart>,
3157 t;
3158 };
3159 struct Subroutine {
3160 TUPLE_CLASS_BOILERPLATE(Subroutine);
3161 std::tuple<Statement<SubroutineStmt>,
3163 t;
3164 };
3165 std::variant<Function, Subroutine> u;
3166};
3167
3168// R1506 procedure-stmt -> [MODULE] PROCEDURE [::] specific-procedure-list
3170 ENUM_CLASS(Kind, ModuleProcedure, Procedure)
3171 TUPLE_CLASS_BOILERPLATE(ProcedureStmt);
3172 std::tuple<Kind, std::list<Name>> t;
3173};
3174
3175// R1502 interface-specification -> interface-body | procedure-stmt
3177 UNION_CLASS_BOILERPLATE(InterfaceSpecification);
3178 std::variant<InterfaceBody, Statement<ProcedureStmt>> u;
3179};
3180
3181// R1504 end-interface-stmt -> END INTERFACE [generic-spec]
3182WRAPPER_CLASS(EndInterfaceStmt, std::optional<GenericSpec>);
3183
3184// R1501 interface-block ->
3185// interface-stmt [interface-specification]... end-interface-stmt
3187 TUPLE_CLASS_BOILERPLATE(InterfaceBlock);
3188 std::tuple<Statement<InterfaceStmt>, std::list<InterfaceSpecification>,
3190 t;
3191};
3192
3193// R1511 external-stmt -> EXTERNAL [::] external-name-list
3194WRAPPER_CLASS(ExternalStmt, std::list<Name>);
3195
3196// R1519 intrinsic-stmt -> INTRINSIC [::] intrinsic-procedure-name-list
3197WRAPPER_CLASS(IntrinsicStmt, std::list<Name>);
3198
3199// R1522 procedure-designator ->
3200// procedure-name | proc-component-ref | data-ref % binding-name
3202 UNION_CLASS_BOILERPLATE(ProcedureDesignator);
3203 std::variant<Name, ProcComponentRef> u;
3204};
3205
3206// R1525 alt-return-spec -> * label
3207WRAPPER_CLASS(AltReturnSpec, Label);
3208
3209// R1524 actual-arg ->
3210// expr | variable | procedure-name | proc-component-ref |
3211// alt-return-spec
3212struct ActualArg {
3213 WRAPPER_CLASS(PercentRef, Expr); // %REF(x) extension
3214 WRAPPER_CLASS(PercentVal, Expr); // %VAL(x) extension
3215 UNION_CLASS_BOILERPLATE(ActualArg);
3216 ActualArg(Expr &&x) : u{common::Indirection<Expr>(std::move(x))} {}
3217 std::variant<common::Indirection<Expr>, AltReturnSpec, PercentRef, PercentVal>
3218 u;
3219};
3220
3221// R1523 actual-arg-spec -> [keyword =] actual-arg
3223 TUPLE_CLASS_BOILERPLATE(ActualArgSpec);
3224 std::tuple<std::optional<Keyword>, ActualArg> t;
3225};
3226
3227// R1520 function-reference -> procedure-designator
3228// ( [actual-arg-spec-list] )
3229struct Call {
3230 TUPLE_CLASS_BOILERPLATE(Call);
3231 std::tuple<ProcedureDesignator, std::list<ActualArgSpec>> t;
3232};
3233
3235 WRAPPER_CLASS_BOILERPLATE(FunctionReference, Call);
3236 CharBlock source;
3237 Designator ConvertToArrayElementRef();
3238 StructureConstructor ConvertToStructureConstructor(
3240};
3241
3242// R1521 call-stmt -> CALL procedure-designator [ chevrons ]
3243// [( [actual-arg-spec-list] )]
3244// (CUDA) chevrons -> <<< * | scalar-expr, scalar-expr [,
3245// scalar-expr [, scalar-int-expr ] ] >>>
3246struct CallStmt {
3247 TUPLE_CLASS_BOILERPLATE(CallStmt);
3248 WRAPPER_CLASS(StarOrExpr, std::optional<ScalarExpr>);
3249 struct Chevrons {
3250 TUPLE_CLASS_BOILERPLATE(Chevrons);
3251 std::tuple<StarOrExpr, ScalarExpr, std::optional<ScalarExpr>,
3252 std::optional<ScalarIntExpr>>
3253 t;
3254 };
3255 explicit CallStmt(ProcedureDesignator &&pd, std::optional<Chevrons> &&ch,
3256 std::list<ActualArgSpec> &&args)
3257 : CallStmt(Call{std::move(pd), std::move(args)}, std::move(ch)) {}
3258 std::tuple<Call, std::optional<Chevrons>> t;
3259 CharBlock source;
3260 mutable TypedCall typedCall; // filled by semantics
3261};
3262
3263// R1529 function-subprogram ->
3264// function-stmt [specification-part] [execution-part]
3265// [internal-subprogram-part] end-function-stmt
3267 TUPLE_CLASS_BOILERPLATE(FunctionSubprogram);
3268 std::tuple<Statement<FunctionStmt>, SpecificationPart, ExecutionPart,
3269 std::optional<InternalSubprogramPart>, Statement<EndFunctionStmt>>
3270 t;
3271};
3272
3273// R1534 subroutine-subprogram ->
3274// subroutine-stmt [specification-part] [execution-part]
3275// [internal-subprogram-part] end-subroutine-stmt
3277 TUPLE_CLASS_BOILERPLATE(SubroutineSubprogram);
3278 std::tuple<Statement<SubroutineStmt>, SpecificationPart, ExecutionPart,
3279 std::optional<InternalSubprogramPart>, Statement<EndSubroutineStmt>>
3280 t;
3281};
3282
3283// R1539 mp-subprogram-stmt -> MODULE PROCEDURE procedure-name
3284WRAPPER_CLASS(MpSubprogramStmt, Name);
3285
3286// R1540 end-mp-subprogram-stmt -> END [PROCEDURE [procedure-name]]
3287WRAPPER_CLASS(EndMpSubprogramStmt, std::optional<Name>);
3288
3289// R1538 separate-module-subprogram ->
3290// mp-subprogram-stmt [specification-part] [execution-part]
3291// [internal-subprogram-part] end-mp-subprogram-stmt
3293 TUPLE_CLASS_BOILERPLATE(SeparateModuleSubprogram);
3294 std::tuple<Statement<MpSubprogramStmt>, SpecificationPart, ExecutionPart,
3295 std::optional<InternalSubprogramPart>, Statement<EndMpSubprogramStmt>>
3296 t;
3297};
3298
3299// R1541 entry-stmt -> ENTRY entry-name [( [dummy-arg-list] ) [suffix]]
3301 TUPLE_CLASS_BOILERPLATE(EntryStmt);
3302 std::tuple<Name, std::list<DummyArg>, std::optional<Suffix>> t;
3303};
3304
3305// R1542 return-stmt -> RETURN [scalar-int-expr]
3306WRAPPER_CLASS(ReturnStmt, std::optional<ScalarIntExpr>);
3307
3308// R1544 stmt-function-stmt ->
3309// function-name ( [dummy-arg-name-list] ) = scalar-expr
3311 TUPLE_CLASS_BOILERPLATE(StmtFunctionStmt);
3312 std::tuple<Name, std::list<Name>, Scalar<Expr>> t;
3313 Statement<ActionStmt> ConvertToAssignment();
3314};
3315
3316// Compiler directives
3317// !DIR$ IGNORE_TKR [ [(tkrdmac...)] name ]...
3318// !DIR$ LOOP COUNT (n1[, n2]...)
3319// !DIR$ name[=value] [, name[=value]]... = can be :
3320// !DIR$ UNROLL [N]
3321// !DIR$ UNROLL_AND_JAM [N]
3322// !DIR$ NOVECTOR
3323// !DIR$ NOUNROLL
3324// !DIR$ NOUNROLL_AND_JAM
3325// !DIR$ PREFETCH designator[, designator]...
3326// !DIR$ FORCEINLINE
3327// !DIR$ INLINE
3328// !DIR$ NOINLINE
3329// !DIR$ IVDEP
3330// !DIR$ <anything else>
3332 UNION_CLASS_BOILERPLATE(CompilerDirective);
3333 struct IgnoreTKR {
3334 TUPLE_CLASS_BOILERPLATE(IgnoreTKR);
3335 std::tuple<std::optional<std::list<const char *>>, Name> t;
3336 };
3337 struct LoopCount {
3338 WRAPPER_CLASS_BOILERPLATE(LoopCount, std::list<std::uint64_t>);
3339 };
3341 TUPLE_CLASS_BOILERPLATE(AssumeAligned);
3342 std::tuple<common::Indirection<Designator>, uint64_t> t;
3343 };
3344 EMPTY_CLASS(VectorAlways);
3346 TUPLE_CLASS_BOILERPLATE(VectorLength);
3347 ENUM_CLASS(Kind, Auto, Fixed, Scalable);
3348
3349 std::tuple<std::uint64_t, Kind> t;
3350 };
3351 struct NameValue {
3352 TUPLE_CLASS_BOILERPLATE(NameValue);
3353 std::tuple<Name, std::optional<std::uint64_t>> t;
3354 };
3355 struct Unroll {
3356 WRAPPER_CLASS_BOILERPLATE(Unroll, std::optional<std::uint64_t>);
3357 };
3359 WRAPPER_CLASS_BOILERPLATE(UnrollAndJam, std::optional<std::uint64_t>);
3360 };
3361 struct Prefetch {
3362 WRAPPER_CLASS_BOILERPLATE(
3364 };
3365 EMPTY_CLASS(NoVector);
3366 EMPTY_CLASS(NoUnroll);
3367 EMPTY_CLASS(NoUnrollAndJam);
3368 EMPTY_CLASS(ForceInline);
3369 EMPTY_CLASS(Inline);
3370 EMPTY_CLASS(NoInline);
3371 EMPTY_CLASS(IVDep);
3372 EMPTY_CLASS(Unrecognized);
3373 CharBlock source;
3374 std::variant<std::list<IgnoreTKR>, LoopCount, std::list<AssumeAligned>,
3375 VectorAlways, VectorLength, std::list<NameValue>, Unroll, UnrollAndJam,
3376 Unrecognized, NoVector, NoUnroll, NoUnrollAndJam, ForceInline, Inline,
3377 NoInline, Prefetch, IVDep>
3378 u;
3379};
3380
3381// (CUDA) ATTRIBUTE(attribute) [::] name-list
3383 TUPLE_CLASS_BOILERPLATE(CUDAAttributesStmt);
3384 std::tuple<common::CUDADataAttr, std::list<Name>> t;
3385};
3386
3387// Legacy extensions
3389 TUPLE_CLASS_BOILERPLATE(BasedPointer);
3390 std::tuple<ObjectName, ObjectName, std::optional<ArraySpec>> t;
3391};
3392WRAPPER_CLASS(BasedPointerStmt, std::list<BasedPointer>);
3393
3394struct Union;
3395struct StructureDef;
3396
3398 UNION_CLASS_BOILERPLATE(StructureField);
3399 std::variant<Statement<DataComponentDefStmt>,
3401 u;
3402};
3403
3404struct Map {
3405 EMPTY_CLASS(MapStmt);
3406 EMPTY_CLASS(EndMapStmt);
3407 TUPLE_CLASS_BOILERPLATE(Map);
3408 std::tuple<Statement<MapStmt>, std::list<StructureField>,
3410 t;
3411};
3412
3413struct Union {
3414 EMPTY_CLASS(UnionStmt);
3415 EMPTY_CLASS(EndUnionStmt);
3416 TUPLE_CLASS_BOILERPLATE(Union);
3417 std::tuple<Statement<UnionStmt>, std::list<Map>, Statement<EndUnionStmt>> t;
3418};
3419
3421 TUPLE_CLASS_BOILERPLATE(StructureStmt);
3422 std::tuple<std::optional<Name>, std::list<EntityDecl>> t;
3423};
3424
3426 EMPTY_CLASS(EndStructureStmt);
3427 TUPLE_CLASS_BOILERPLATE(StructureDef);
3428 std::tuple<Statement<StructureStmt>, std::list<StructureField>,
3430 t;
3431};
3432
3433// Old style PARAMETER statement without parentheses.
3434// Types are determined entirely from the right-hand sides, not the names.
3435WRAPPER_CLASS(OldParameterStmt, std::list<NamedConstantDef>);
3436
3437// Deprecations
3439 TUPLE_CLASS_BOILERPLATE(ArithmeticIfStmt);
3440 std::tuple<Expr, Label, Label, Label> t;
3441};
3442
3444 TUPLE_CLASS_BOILERPLATE(AssignStmt);
3445 std::tuple<Label, Name> t;
3446};
3447
3449 TUPLE_CLASS_BOILERPLATE(AssignedGotoStmt);
3450 std::tuple<Name, std::list<Label>> t;
3451};
3452
3453WRAPPER_CLASS(PauseStmt, std::optional<StopCode>);
3454
3455// Parse tree nodes for OpenMP directives and clauses
3456
3457// --- Common definitions
3458
3459#define INHERITED_TUPLE_CLASS_BOILERPLATE(classname, basename) \
3460 using basename::basename; \
3461 classname(basename &&b) : basename(std::move(b)) {} \
3462 using TupleTrait = std::true_type; \
3463 BOILERPLATE(classname)
3464
3465#define INHERITED_WRAPPER_CLASS_BOILERPLATE(classname, basename) \
3466 BOILERPLATE(classname); \
3467 using basename::basename; \
3468 classname(basename &&base) : basename(std::move(base)) {} \
3469 using WrapperTrait = std::true_type
3470
3471struct OmpClause;
3473
3474struct OmpDirectiveName {
3475 // No boilerplates: this class should be copyable, movable, etc.
3476 constexpr OmpDirectiveName() = default;
3477 constexpr OmpDirectiveName(const OmpDirectiveName &) = default;
3478 constexpr OmpDirectiveName(llvm::omp::Directive x) : v(x) {}
3479 // Construct from an already parsed text. Use Verbatim for this because
3480 // Verbatim's source corresponds to an actual source location.
3481 // This allows "construct<OmpDirectiveName>(Verbatim("<name>"))".
3482 OmpDirectiveName(const Verbatim &name);
3483 using WrapperTrait = std::true_type;
3484
3485 bool IsExecutionPart() const; // Is allowed in the execution part
3486
3487 CharBlock source;
3488 llvm::omp::Directive v{llvm::omp::Directive::OMPD_unknown};
3489};
3490
3491// type-name list item
3493 CharBlock source;
3494 mutable const semantics::DeclTypeSpec *declTypeSpec{nullptr};
3495 UNION_CLASS_BOILERPLATE(OmpTypeName);
3496 std::variant<TypeSpec, DeclarationTypeSpec> u;
3497};
3498
3500 WRAPPER_CLASS_BOILERPLATE(OmpTypeNameList, std::list<OmpTypeName>);
3501};
3502
3503// 2.1 Directives or clauses may accept a list or extended-list.
3504// A list item is a variable, array section or common block name (enclosed
3505// in slashes). An extended list item is a list item or a procedure Name.
3506// variable-name | / common-block / | array-sections
3508 // Blank common blocks are not valid objects. Parse them to emit meaningful
3509 // diagnostics.
3510 struct Invalid {
3511 ENUM_CLASS(Kind, BlankCommonBlock);
3512 WRAPPER_CLASS_BOILERPLATE(Invalid, Kind);
3513 CharBlock source;
3514 };
3515 UNION_CLASS_BOILERPLATE(OmpObject);
3516 std::variant<Designator, /*common block*/ Name, Invalid> u;
3517};
3518
3520 WRAPPER_CLASS_BOILERPLATE(OmpObjectList, std::list<OmpObject>);
3521};
3522
3524 COPY_AND_ASSIGN_BOILERPLATE(OmpStylizedDeclaration);
3525 // Since "Reference" isn't handled by parse-tree-visitor, add EmptyTrait,
3526 // and visit the members by hand when needed.
3527 using EmptyTrait = std::true_type;
3529 EntityDecl var;
3530};
3531
3533 struct Instance {
3534 UNION_CLASS_BOILERPLATE(Instance);
3535 std::variant<AssignmentStmt, CallStmt, common::Indirection<Expr>> u;
3536 };
3537 TUPLE_CLASS_BOILERPLATE(OmpStylizedInstance);
3538 std::tuple<std::list<OmpStylizedDeclaration>, Instance> t;
3539};
3540
3541class ParseState;
3542
3543// Ref: [5.2:76], [6.0:185]
3544//
3546 CharBlock source;
3547 // Pointer to a temporary copy of the ParseState that is used to create
3548 // additional parse subtrees for the stylized expression. This is only
3549 // used internally during parsing and conveys no information to the
3550 // consumers of the AST.
3551 const ParseState *state{nullptr};
3552 WRAPPER_CLASS_BOILERPLATE(
3553 OmpStylizedExpression, std::list<OmpStylizedInstance>);
3554};
3555
3556// Ref: [4.5:201-207], [5.0:293-299], [5.1:325-331], [5.2:124]
3557//
3558// reduction-identifier ->
3559// base-language-identifier | // since 4.5
3560// - | // since 4.5, until 5.2
3561// + | * | .AND. | .OR. | .EQV. | .NEQV. | // since 4.5
3562// MIN | MAX | IAND | IOR | IEOR // since 4.5
3564 UNION_CLASS_BOILERPLATE(OmpReductionIdentifier);
3565 std::variant<DefinedOperator, ProcedureDesignator> u;
3566};
3567
3568// Ref: [4.5:222:6], [5.0:305:27], [5.1:337:19], [5.2:126:3-4], [6.0:240:27-28]
3569//
3570// combiner-expression -> // since 4.5
3571// assignment-statement |
3572// function-reference
3574 INHERITED_WRAPPER_CLASS_BOILERPLATE(
3576 static llvm::ArrayRef<CharBlock> Variables();
3577};
3578
3579// Ref: [4.5:222:7-8], [5.0:305:28-29], [5.1:337:20-21], [5.2:127:6-8],
3580// [6.0:242:3-5]
3581//
3582// initializer-expression -> // since 4.5
3583// OMP_PRIV = expression |
3584// subroutine-name(argument-list)
3586 INHERITED_WRAPPER_CLASS_BOILERPLATE(
3588 static llvm::ArrayRef<CharBlock> Variables();
3589};
3590
3591inline namespace arguments {
3593 UNION_CLASS_BOILERPLATE(OmpLocator);
3594 std::variant<OmpObject, FunctionReference> u;
3595};
3596
3598 WRAPPER_CLASS_BOILERPLATE(OmpLocatorList, std::list<OmpLocator>);
3599};
3600
3601// Ref: [4.5:58-60], [5.0:58-60], [5.1:63-68], [5.2:197-198], [6.0:334-336]
3602//
3603// Argument to DECLARE VARIANT with the base-name present. (When only
3604// variant-name is present, it is a simple OmpObject).
3605//
3606// base-name-variant-name -> // since 4.5
3607// base-name : variant-name
3609 TUPLE_CLASS_BOILERPLATE(OmpBaseVariantNames);
3610 std::tuple<OmpObject, OmpObject> t;
3611};
3612
3613// Ref: [5.0:326:10-16], [5.1:359:5-11], [5.2:163:2-7], [6.0:293:16-21]
3614//
3615// mapper-specifier ->
3616// [mapper-identifier :] type :: var | // since 5.0
3617// DEFAULT type :: var
3619 // Absent mapper-identifier is equivalent to DEFAULT.
3620 TUPLE_CLASS_BOILERPLATE(OmpMapperSpecifier);
3621 std::tuple<std::string, TypeSpec, Name> t;
3622};
3623
3624// Ref: [4.5:222:1-5], [5.0:305:20-27], [5.1:337:11-19], [5.2:139:18-23],
3625// [6.0:260:16-20]
3626//
3627// reduction-specifier ->
3628// reduction-identifier : typename-list
3629// : combiner-expression // since 4.5, until 5.2
3630// reduction-identifier : typename-list // since 6.0
3632 TUPLE_CLASS_BOILERPLATE(OmpReductionSpecifier);
3634 std::optional<OmpCombinerExpression>>
3635 t;
3636};
3637
3639 CharBlock source;
3640 UNION_CLASS_BOILERPLATE(OmpArgument);
3641 std::variant<OmpLocator, // {variable, extended, locator}-list-item
3642 OmpBaseVariantNames, // base-name:variant-name
3644 u;
3645};
3646
3648 WRAPPER_CLASS_BOILERPLATE(OmpArgumentList, std::list<OmpArgument>);
3649 CharBlock source;
3650};
3651} // namespace arguments
3652
3653inline namespace traits {
3654// trait-property-name ->
3655// identifier | string-literal
3656//
3657// This is a bit of a problematic case. The spec says that a word in quotes,
3658// and the same word without quotes are equivalent. We currently parse both
3659// as a string, but it's likely just a temporary solution.
3660//
3661// The problem is that trait-property can be (among other things) a
3662// trait-property-name or a trait-property-expression. A simple identifier
3663// can be either, there is no reasonably simple way of telling them apart
3664// in the parser. There is a similar issue with extensions. Some of that
3665// disambiguation may need to be done in the "canonicalization" pass and
3666// then some of those AST nodes would be rewritten into different ones.
3667//
3669 CharBlock source;
3670 WRAPPER_CLASS_BOILERPLATE(OmpTraitPropertyName, std::string);
3671};
3672
3673// trait-score ->
3674// SCORE(non-negative-const-integer-expression)
3676 CharBlock source;
3677 WRAPPER_CLASS_BOILERPLATE(OmpTraitScore, ScalarIntExpr);
3678};
3679
3680// trait-property-extension ->
3681// trait-property-name |
3682// scalar-expr |
3683// trait-property-name (trait-property-extension, ...)
3684//
3686 CharBlock source;
3687 UNION_CLASS_BOILERPLATE(OmpTraitPropertyExtension);
3688 struct Complex { // name (prop-ext, prop-ext, ...)
3689 CharBlock source;
3690 TUPLE_CLASS_BOILERPLATE(Complex);
3691 std::tuple<OmpTraitPropertyName,
3692 std::list<common::Indirection<OmpTraitPropertyExtension>>>
3693 t;
3694 };
3695
3696 std::variant<OmpTraitPropertyName, ScalarExpr, Complex> u;
3697};
3698
3699// trait-property ->
3700// trait-property-name | OmpClause |
3701// trait-property-expression | trait-property-extension
3702// trait-property-expression ->
3703// scalar-logical-expression | scalar-integer-expression
3704//
3705// The parser for a logical expression will accept an integer expression,
3706// and if it's not logical, it will flag an error later. The same thing
3707// will happen if the scalar integer expression sees a logical expresion.
3708// To avoid this, parse all expressions as scalar expressions.
3710 CharBlock source;
3711 UNION_CLASS_BOILERPLATE(OmpTraitProperty);
3712 std::variant<OmpTraitPropertyName, common::Indirection<OmpClause>,
3713 ScalarExpr, // trait-property-expresion
3715 u;
3716};
3717
3718// trait-selector-name ->
3719// KIND | DT // name-list (host, nohost, +/add-def-doc)
3720// ISA | DT // name-list (isa_name, ... /impl-defined)
3721// ARCH | DT // name-list (arch_name, ... /impl-defined)
3722// directive-name | C // no properties
3723// SIMD | C // clause-list (from declare_simd)
3724// // (at least simdlen, inbranch/notinbranch)
3725// DEVICE_NUM | T // device-number
3726// UID | T // unique-string-id /impl-defined
3727// VENDOR | I // name-list (vendor-id /add-def-doc)
3728// EXTENSION | I // name-list (ext_name /impl-defined)
3729// ATOMIC_DEFAULT_MEM_ORDER I | // clause-list (value of admo)
3730// REQUIRES | I // clause-list (from requires)
3731// CONDITION U // logical-expr
3732// <other name> I // treated as extension
3733//
3734// Trait-set-selectors:
3735// [D]evice, [T]arget_device, [C]onstruct, [I]mplementation, [U]ser.
3737 std::string ToString() const;
3738 CharBlock source;
3739 UNION_CLASS_BOILERPLATE(OmpTraitSelectorName);
3740 ENUM_CLASS(Value, Arch, Atomic_Default_Mem_Order, Condition, Device_Num,
3741 Extension, Isa, Kind, Requires, Simd, Uid, Vendor)
3742 std::variant<Value, llvm::omp::Directive, std::string> u;
3743};
3744
3745// trait-selector ->
3746// trait-selector-name |
3747// trait-selector-name ([trait-score:] trait-property, ...)
3749 CharBlock source;
3750 TUPLE_CLASS_BOILERPLATE(OmpTraitSelector);
3751 struct Properties {
3752 TUPLE_CLASS_BOILERPLATE(Properties);
3753 std::tuple<std::optional<OmpTraitScore>, std::list<OmpTraitProperty>> t;
3754 };
3755 std::tuple<OmpTraitSelectorName, std::optional<Properties>> t;
3756};
3757
3758// trait-set-selector-name ->
3759// CONSTRUCT | DEVICE | IMPLEMENTATION | USER | // since 5.0
3760// TARGET_DEVICE // since 5.1
3762 std::string ToString() const;
3763 CharBlock source;
3764 ENUM_CLASS(Value, Construct, Device, Implementation, Target_Device, User)
3765 WRAPPER_CLASS_BOILERPLATE(OmpTraitSetSelectorName, Value);
3766};
3767
3768// trait-set-selector ->
3769// trait-set-selector-name = {trait-selector, ...}
3771 CharBlock source;
3772 TUPLE_CLASS_BOILERPLATE(OmpTraitSetSelector);
3773 std::tuple<OmpTraitSetSelectorName, std::list<OmpTraitSelector>> t;
3774};
3775
3776// context-selector-specification ->
3777// trait-set-selector, ...
3779 CharBlock source;
3780 WRAPPER_CLASS_BOILERPLATE(
3781 OmpContextSelectorSpecification, std::list<OmpTraitSetSelector>);
3782};
3783} // namespace traits
3784
3785#define MODIFIER_BOILERPLATE(...) \
3786 struct Modifier { \
3787 using Variant = std::variant<__VA_ARGS__>; \
3788 UNION_CLASS_BOILERPLATE(Modifier); \
3789 CharBlock source; \
3790 Variant u; \
3791 }
3792
3793#define MODIFIERS() std::optional<std::list<Modifier>>
3794
3795inline namespace modifier {
3796// For uniformity, in all keyword modifiers the name of the type defined
3797// by ENUM_CLASS is "Value", e.g.
3798// struct Foo {
3799// ENUM_CLASS(Value, Keyword1, Keyword2);
3800// };
3801
3803 ENUM_CLASS(Value, Cgroup);
3804 WRAPPER_CLASS_BOILERPLATE(OmpAccessGroup, Value);
3805};
3806
3807// Ref: [4.5:72-81], [5.0:110-119], [5.1:134-143], [5.2:169-170]
3808//
3809// alignment ->
3810// scalar-integer-expression // since 4.5
3812 WRAPPER_CLASS_BOILERPLATE(OmpAlignment, ScalarIntExpr);
3813};
3814
3815// Ref: [5.1:184-185], [5.2:178-179]
3816//
3817// align-modifier ->
3818// ALIGN(alignment) // since 5.1
3820 WRAPPER_CLASS_BOILERPLATE(OmpAlignModifier, ScalarIntExpr);
3821};
3822
3823// Ref: [5.0:158-159], [5.1:184-185], [5.2:178-179]
3824//
3825// allocator-simple-modifier ->
3826// allocator // since 5.0
3828 WRAPPER_CLASS_BOILERPLATE(OmpAllocatorSimpleModifier, ScalarIntExpr);
3829};
3830
3831// Ref: [5.1:184-185], [5.2:178-179]
3832//
3833// allocator-complex-modifier ->
3834// ALLOCATOR(allocator) // since 5.1
3836 WRAPPER_CLASS_BOILERPLATE(OmpAllocatorComplexModifier, ScalarIntExpr);
3837};
3838
3839// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
3840// [6.0:279-288]
3841//
3842// always-modifier ->
3843// ALWAYS // since 4.5
3844//
3845// Until 5.2, it was a part of map-type-modifier. Since 6.0 the
3846// map-type-modifier has been split into individual modifiers.
3848 ENUM_CLASS(Value, Always)
3849 WRAPPER_CLASS_BOILERPLATE(OmpAlwaysModifier, Value);
3850};
3851
3852// Ref: [coming in 6.1]
3853//
3854// attach-modifier ->
3855// ATTACH(attachment-mode) // since 6.1
3856//
3857// attachment-mode ->
3858// ALWAYS | AUTO | NEVER
3860 ENUM_CLASS(Value, Always, Never, Auto)
3861 WRAPPER_CLASS_BOILERPLATE(OmpAttachModifier, Value);
3862};
3863
3864// Ref: [6.0:289-290]
3865//
3866// automap-modifier ->
3867// automap // since 6.0
3868//
3870 ENUM_CLASS(Value, Automap);
3871 WRAPPER_CLASS_BOILERPLATE(OmpAutomapModifier, Value);
3872};
3873
3874// Ref: [5.2:252-254]
3875//
3876// chunk-modifier ->
3877// SIMD // since 5.2
3878//
3879// Prior to 5.2 "chunk-modifier" was a part of "modifier" on SCHEDULE clause.
3881 ENUM_CLASS(Value, Simd)
3882 WRAPPER_CLASS_BOILERPLATE(OmpChunkModifier, Value);
3883};
3884
3885// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
3886// [6.0:279-288]
3887//
3888// close-modifier ->
3889// CLOSE // since 5.0
3890//
3891// Until 5.2, it was a part of map-type-modifier. Since 6.0 the
3892// map-type-modifier has been split into individual modifiers.
3894 ENUM_CLASS(Value, Close)
3895 WRAPPER_CLASS_BOILERPLATE(OmpCloseModifier, Value);
3896};
3897
3898// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
3899// [6.0:279-288]
3900//
3901// delete-modifier ->
3902// DELETE // since 6.0
3903//
3904// Until 5.2, it was a part of map-type.
3906 ENUM_CLASS(Value, Delete)
3907 WRAPPER_CLASS_BOILERPLATE(OmpDeleteModifier, Value);
3908};
3909
3910// Ref: [4.5:169-170], [5.0:255-256], [5.1:288-289]
3911//
3912// dependence-type ->
3913// SINK | SOURCE | // since 4.5
3914// IN | OUT | INOUT | // since 4.5, until 5.1
3915// MUTEXINOUTSET | DEPOBJ | // since 5.0, until 5.1
3916// INOUTSET // since 5.1, until 5.1
3917//
3918// All of these, except SINK and SOURCE became task-dependence-type in 5.2.
3919//
3920// Keeping these two as separate types, since having them all together
3921// creates conflicts when parsing the DEPEND clause. For DEPEND(SINK: ...),
3922// the SINK may be parsed as 'task-dependence-type', and the list after
3923// the ':' would then be parsed as OmpObjectList (instead of the iteration
3924// vector). This would accept the vector "i, j, k" (although interpreted
3925// incorrectly), while flagging a syntax error for "i+1, j, k".
3927 ENUM_CLASS(Value, Sink, Source);
3928 WRAPPER_CLASS_BOILERPLATE(OmpDependenceType, Value);
3929};
3930
3931// Ref: [6.0:180-181]
3932//
3933// depinfo-modifier -> // since 6.0
3934// keyword (locator-list-item)
3935// keyword ->
3936// IN | INOUT | INOUTSET | MUTEXINOUTSET | OUT // since 6.0
3938 using Value = common::OmpDependenceKind;
3939 TUPLE_CLASS_BOILERPLATE(OmpDepinfoModifier);
3940 std::tuple<Value, OmpObject> t;
3941};
3942
3943// Ref: [5.0:170-176], [5.1:197-205], [5.2:276-277]
3944//
3945// device-modifier ->
3946// ANCESTOR | DEVICE_NUM // since 5.0
3948 ENUM_CLASS(Value, Ancestor, Device_Num)
3949 WRAPPER_CLASS_BOILERPLATE(OmpDeviceModifier, Value);
3950};
3951
3952// Ref: TODO
3953//
3954// dims-modifier ->
3955// constant integer expression // since 6.1
3957 WRAPPER_CLASS_BOILERPLATE(OmpDimsModifier, ScalarIntConstantExpr);
3958};
3959
3960// Ref: [5.2:72-73,230-323], in 4.5-5.1 it's scattered over individual
3961// directives that allow the IF clause.
3962//
3963// directive-name-modifier ->
3964// PARALLEL | TARGET | TARGET DATA |
3965// TARGET ENTER DATA | TARGET EXIT DATA |
3966// TARGET UPDATE | TASK | TASKLOOP | // since 4.5
3967// CANCEL[*] | SIMD | // since 5.0
3968// TEAMS // since 5.2
3969//
3970// [*] The IF clause is allowed on CANCEL in OpenMP 4.5, but only without
3971// the directive-name-modifier. For the sake of uniformity CANCEL can be
3972// considered a valid value in 4.5 as well.
3973struct OmpDirectiveNameModifier : public OmpDirectiveName {
3974 INHERITED_WRAPPER_CLASS_BOILERPLATE(
3975 OmpDirectiveNameModifier, OmpDirectiveName);
3976};
3977
3978// Ref: [5.1:205-209], [5.2:166-168]
3979//
3980// motion-modifier ->
3981// PRESENT | // since 5.0, until 5.0
3982// mapper | iterator
3983// expectation ->
3984// PRESENT // since 5.1
3985//
3986// The PRESENT value was a part of motion-modifier in 5.1, and became a
3987// value of expectation in 5.2.
3989 ENUM_CLASS(Value, Present);
3990 WRAPPER_CLASS_BOILERPLATE(OmpExpectation, Value);
3991};
3992
3993// Ref: [6.1:tbd]
3994//
3995// fallback-modifier ->
3996// FALLBACK(fallback-mode) // since 6.1
3997// fallback-mode ->
3998// ABORT | DEFAULT_MEM | NULL // since 6.1
4000 ENUM_CLASS(Value, Abort, Default_Mem, Null);
4001 WRAPPER_CLASS_BOILERPLATE(OmpFallbackModifier, Value);
4002};
4003
4004// REF: [5.1:217-220], [5.2:293-294], [6.0:470-471]
4005//
4006// interop-type -> // since 5.1
4007// TARGET |
4008// TARGETSYNC
4009// There can be at most only two interop-type.
4011 ENUM_CLASS(Value, Target, Targetsync)
4012 WRAPPER_CLASS_BOILERPLATE(OmpInteropType, Value);
4013};
4014
4015// Ref: [5.0:47-49], [5.1:49-51], [5.2:67-69]
4016//
4017// iterator-specifier ->
4018// [iterator-type] iterator-identifier
4019// = range-specification | // since 5.0
4020// [iterator-type ::] iterator-identifier
4021// = range-specification // since 5.2
4023 TUPLE_CLASS_BOILERPLATE(OmpIteratorSpecifier);
4024 CharBlock source;
4025 std::tuple<TypeDeclarationStmt, SubscriptTriplet> t;
4026};
4027
4028// Ref: [5.0:47-49], [5.1:49-51], [5.2:67-69]
4029//
4030// iterator-modifier ->
4031// ITERATOR(iterator-specifier [, ...]) // since 5.0
4033 WRAPPER_CLASS_BOILERPLATE(OmpIterator, std::list<OmpIteratorSpecifier>);
4034};
4035
4036// Ref: [5.0:288-290], [5.1:321-322], [5.2:115-117]
4037//
4038// lastprivate-modifier ->
4039// CONDITIONAL // since 5.0
4041 ENUM_CLASS(Value, Conditional)
4042 WRAPPER_CLASS_BOILERPLATE(OmpLastprivateModifier, Value);
4043};
4044
4045// Ref: [4.5:207-210], [5.0:290-293], [5.1:323-325], [5.2:117-120]
4046//
4047// linear-modifier ->
4048// REF | UVAL | VAL // since 4.5
4050 ENUM_CLASS(Value, Ref, Uval, Val);
4051 WRAPPER_CLASS_BOILERPLATE(OmpLinearModifier, Value);
4052};
4053
4054// Ref: [5.1:100-104], [5.2:277], [6.0:452-453]
4055//
4056// lower-bound ->
4057// scalar-integer-expression // since 5.1
4059 WRAPPER_CLASS_BOILERPLATE(OmpLowerBound, ScalarIntExpr);
4060};
4061
4062// Ref: [5.0:176-180], [5.1:205-210], [5.2:149-150]
4063//
4064// mapper ->
4065// identifier // since 4.5
4067 WRAPPER_CLASS_BOILERPLATE(OmpMapper, Name);
4068};
4069
4070// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
4071// [6.0:279-288]
4072//
4073// map-type ->
4074// ALLOC | DELETE | RELEASE | // since 4.5, until 5.2
4075// FROM | TO | TOFROM | // since 4.5
4076// STORAGE // since 6.0
4077//
4078// Since 6.0 DELETE is a separate delete-modifier.
4080 ENUM_CLASS(Value, Alloc, Delete, From, Release, Storage, To, Tofrom);
4081 WRAPPER_CLASS_BOILERPLATE(OmpMapType, Value);
4082};
4083
4084// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158]
4085//
4086// map-type-modifier ->
4087// ALWAYS | // since 4.5, until 5.2
4088// CLOSE | // since 5.0, until 5.2
4089// PRESENT // since 5.1, until 5.2
4090// Since 6.0 the map-type-modifier has been split into individual modifiers.
4091//
4093 ENUM_CLASS(Value, Always, Close, Present, Ompx_Hold)
4094 WRAPPER_CLASS_BOILERPLATE(OmpMapTypeModifier, Value);
4095};
4096
4097// Ref: [4.5:56-63], [5.0:101-109], [5.1:126-133], [5.2:252-254]
4098//
4099// modifier ->
4100// MONOTONIC | NONMONOTONIC | SIMD // since 4.5, until 5.1
4101// ordering-modifier ->
4102// MONOTONIC | NONMONOTONIC // since 5.2
4103//
4104// Until 5.1, the SCHEDULE clause accepted up to two instances of "modifier".
4105// Since 5.2 "modifier" was replaced with "ordering-modifier" and "chunk-
4106// modifier".
4108 ENUM_CLASS(Value, Monotonic, Nonmonotonic, Simd)
4109 WRAPPER_CLASS_BOILERPLATE(OmpOrderingModifier, Value);
4110};
4111
4112// Ref: [5.1:125-126], [5.2:233-234]
4113//
4114// order-modifier ->
4115// REPRODUCIBLE | UNCONSTRAINED // since 5.1
4117 ENUM_CLASS(Value, Reproducible, Unconstrained)
4118 WRAPPER_CLASS_BOILERPLATE(OmpOrderModifier, Value);
4119};
4120
4121// Ref: [6.0:470-471]
4122//
4123// preference-selector -> // since 6.0
4124// FR(foreign-runtime-identifier) |
4125// ATTR(preference-property-extension, ...)
4127 UNION_CLASS_BOILERPLATE(OmpPreferenceSelector);
4128 using ForeignRuntimeIdentifier = common::Indirection<Expr>;
4129 using PreferencePropertyExtension = common::Indirection<Expr>;
4130 using Extensions = std::list<PreferencePropertyExtension>;
4131 std::variant<ForeignRuntimeIdentifier, Extensions> u;
4132};
4133
4134// Ref: [6.0:470-471]
4135//
4136// preference-specification ->
4137// {preference-selector...} | // since 6.0
4138// foreign-runtime-identifier // since 5.1
4140 UNION_CLASS_BOILERPLATE(OmpPreferenceSpecification);
4141 using ForeignRuntimeIdentifier =
4142 OmpPreferenceSelector::ForeignRuntimeIdentifier;
4143 std::variant<std::list<OmpPreferenceSelector>, ForeignRuntimeIdentifier> u;
4144};
4145
4146// REF: [5.1:217-220], [5.2:293-294], [6.0:470-471]
4147//
4148// prefer-type -> // since 5.1
4149// PREFER_TYPE(preference-specification...)
4151 WRAPPER_CLASS_BOILERPLATE(
4152 OmpPreferType, std::list<OmpPreferenceSpecification>);
4153};
4154
4155// Ref: [5.1:166-171], [5.2:269-270]
4156//
4157// prescriptiveness ->
4158// STRICT // since 5.1
4160 ENUM_CLASS(Value, Strict)
4161 WRAPPER_CLASS_BOILERPLATE(OmpPrescriptiveness, Value);
4162};
4163
4164// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
4165// [6.0:279-288]
4166//
4167// present-modifier ->
4168// PRESENT // since 5.1
4169//
4170// Until 5.2, it was a part of map-type-modifier. Since 6.0 the
4171// map-type-modifier has been split into individual modifiers.
4173 ENUM_CLASS(Value, Present)
4174 WRAPPER_CLASS_BOILERPLATE(OmpPresentModifier, Value);
4175};
4176
4177// Ref: [5.0:300-302], [5.1:332-334], [5.2:134-137]
4178//
4179// reduction-modifier ->
4180// DEFAULT | INSCAN | TASK // since 5.0
4182 ENUM_CLASS(Value, Default, Inscan, Task);
4183 WRAPPER_CLASS_BOILERPLATE(OmpReductionModifier, Value);
4184};
4185
4186// Ref: [6.0:279-288]
4187//
4188// ref-modifier ->
4189// REF_PTEE | REF_PTR | REF_PTR_PTEE // since 6.0
4190//
4192 ENUM_CLASS(Value, Ref_Ptee, Ref_Ptr, Ref_Ptr_Ptee)
4193 WRAPPER_CLASS_BOILERPLATE(OmpRefModifier, Value);
4194};
4195
4196// Ref: [6.0:279-288]
4197//
4198// self-modifier ->
4199// SELF // since 6.0
4200//
4202 ENUM_CLASS(Value, Self)
4203 WRAPPER_CLASS_BOILERPLATE(OmpSelfModifier, Value);
4204};
4205
4206// Ref: [5.2:117-120]
4207//
4208// step-complex-modifier ->
4209// STEP(integer-expression) // since 5.2
4211 WRAPPER_CLASS_BOILERPLATE(OmpStepComplexModifier, ScalarIntExpr);
4212};
4213
4214// Ref: [4.5:207-210], [5.0:290-293], [5.1:323-325], [5.2:117-120]
4215//
4216// step-simple-modifier ->
4217// integer-expresion // since 4.5
4219 WRAPPER_CLASS_BOILERPLATE(OmpStepSimpleModifier, ScalarIntExpr);
4220};
4221
4222// Ref: [4.5:169-170], [5.0:254-256], [5.1:287-289], [5.2:321]
4223//
4224// task-dependence-type -> // "dependence-type" in 5.1 and before
4225// IN | OUT | INOUT | // since 4.5
4226// MUTEXINOUTSET | DEPOBJ | // since 5.0
4227// INOUTSET // since 5.2
4229 using Value = common::OmpDependenceKind;
4230 WRAPPER_CLASS_BOILERPLATE(OmpTaskDependenceType, Value);
4231};
4232
4233// Ref: [4.5:229-230], [5.0:324-325], [5.1:357-358], [5.2:161-162]
4234//
4235// variable-category ->
4236// SCALAR | // since 4.5
4237// AGGREGATE | ALLOCATABLE | POINTER | // since 5.0
4238// ALL // since 5.2
4240 ENUM_CLASS(Value, Aggregate, All, Allocatable, Pointer, Scalar)
4241 WRAPPER_CLASS_BOILERPLATE(OmpVariableCategory, Value);
4242};
4243
4244// Extension:
4245// https://openmp.llvm.org//openacc/OpenMPExtensions.html#ompx-hold
4246//
4247// ompx-hold-modifier ->
4248// OMPX_HOLD // since 4.5
4249//
4250// Until 5.2, it was a part of map-type-modifier. Since 6.0 the
4251// map-type-modifier has been split into individual modifiers.
4253 ENUM_CLASS(Value, Ompx_Hold)
4254 WRAPPER_CLASS_BOILERPLATE(OmpxHoldModifier, Value);
4255};
4256
4257// context-selector
4258using OmpContextSelector = traits::OmpContextSelectorSpecification;
4259} // namespace modifier
4260
4261// --- Clauses
4262
4263using OmpDirectiveList = std::list<llvm::omp::Directive>;
4264
4265// Ref: [5.2:214]
4266//
4267// absent-clause ->
4268// ABSENT(directive-name[, directive-name])
4270 WRAPPER_CLASS_BOILERPLATE(OmpAbsentClause, OmpDirectiveList);
4271};
4272
4274 TUPLE_CLASS_BOILERPLATE(OmpAdjustArgsClause);
4276 ENUM_CLASS(Value, Nothing, Need_Device_Ptr)
4277 WRAPPER_CLASS_BOILERPLATE(OmpAdjustOp, Value);
4278 };
4279 std::tuple<OmpAdjustOp, OmpObjectList> t;
4280};
4281
4282// Ref: [5.0:135-140], [5.1:161-166], [5.2:264-265]
4283//
4284// affinity-clause ->
4285// AFFINITY([aff-modifier:] locator-list) // since 5.0
4286// aff-modifier ->
4287// interator-modifier // since 5.0
4289 TUPLE_CLASS_BOILERPLATE(OmpAffinityClause);
4290 MODIFIER_BOILERPLATE(OmpIterator);
4291 std::tuple<MODIFIERS(), OmpObjectList> t;
4292};
4293
4294// Ref: 5.2: [174]
4296 WRAPPER_CLASS_BOILERPLATE(OmpAlignClause, ScalarIntConstantExpr);
4297};
4298
4299// Ref: [4.5:72-81], [5.0:110-119], [5.1:134-143], [5.2:169-170]
4300//
4301// aligned-clause ->
4302// ALIGNED(list [: alignment]) // since 4.5
4304 TUPLE_CLASS_BOILERPLATE(OmpAlignedClause);
4305 MODIFIER_BOILERPLATE(OmpAlignment);
4306 std::tuple<OmpObjectList, MODIFIERS()> t;
4307};
4308
4309// Ref: [5.0:158-159], [5.1:184-185], [5.2:178-179]
4310//
4311// allocate-clause ->
4312// ALLOCATE(
4313// [allocator-simple-modifier:] list) | // since 5.0
4314// ALLOCATE([modifier...:] list) // since 5.1
4315// modifier ->
4316// allocator-simple-modifier |
4317// allocator-complex-modifier | align-modifier // since 5.1
4319 MODIFIER_BOILERPLATE(OmpAlignModifier, OmpAllocatorSimpleModifier,
4321 TUPLE_CLASS_BOILERPLATE(OmpAllocateClause);
4322 std::tuple<MODIFIERS(), OmpObjectList> t;
4323};
4324
4327 WRAPPER_CLASS_BOILERPLATE(OmpAppendOp, std::list<OmpInteropType>);
4328 };
4329 WRAPPER_CLASS_BOILERPLATE(OmpAppendArgsClause, std::list<OmpAppendOp>);
4330};
4331
4332// Ref: [5.2:216-217 (sort of, as it's only mentioned in passing)
4333// AT(compilation|execution)
4335 ENUM_CLASS(ActionTime, Compilation, Execution);
4336 WRAPPER_CLASS_BOILERPLATE(OmpAtClause, ActionTime);
4337};
4338
4339// Ref: [5.0:60-63], [5.1:83-86], [5.2:210-213]
4340//
4341// atomic-default-mem-order-clause ->
4342// ATOMIC_DEFAULT_MEM_ORDER(memory-order) // since 5.0
4343// memory-order ->
4344// SEQ_CST | ACQ_REL | RELAXED | // since 5.0
4345// ACQUIRE | RELEASE // since 5.2
4347 using MemoryOrder = common::OmpMemoryOrderType;
4348 WRAPPER_CLASS_BOILERPLATE(OmpAtomicDefaultMemOrderClause, MemoryOrder);
4349};
4350
4351// Ref: [5.0:128-131], [5.1:151-154], [5.2:258-259]
4352//
4353// bind-clause ->
4354// BIND(binding) // since 5.0
4355// binding ->
4356// TEAMS | PARALLEL | THREAD // since 5.0
4358 ENUM_CLASS(Binding, Parallel, Teams, Thread)
4359 WRAPPER_CLASS_BOILERPLATE(OmpBindClause, Binding);
4360};
4361
4362// Artificial clause to represent a cancellable construct.
4364 TUPLE_CLASS_BOILERPLATE(OmpCancellationConstructTypeClause);
4365 std::tuple<OmpDirectiveName, std::optional<ScalarLogicalExpr>> t;
4366};
4367
4368// Ref: [6.0:262]
4369//
4370// combiner-clause -> // since 6.0
4371// COMBINER(combiner-expr)
4373 WRAPPER_CLASS_BOILERPLATE(OmpCombinerClause, OmpCombinerExpression);
4374};
4375
4376// Ref: [5.2:214]
4377//
4378// contains-clause ->
4379// CONTAINS(directive-name[, directive-name])
4381 WRAPPER_CLASS_BOILERPLATE(OmpContainsClause, OmpDirectiveList);
4382};
4383
4384// Ref: [4.5:46-50], [5.0:74-78], [5.1:92-96], [5.2:109]
4385//
4386// When used as a data-sharing clause:
4387// default-clause ->
4388// DEFAULT(data-sharing-attribute) // since 4.5
4389// data-sharing-attribute ->
4390// SHARED | NONE | // since 4.5
4391// PRIVATE | FIRSTPRIVATE // since 5.0
4392//
4393// When used in METADIRECTIVE:
4394// default-clause ->
4395// DEFAULT(directive-specification) // since 5.0, until 5.1
4396// See also otherwise-clause.
4398 ENUM_CLASS(DataSharingAttribute, Private, Firstprivate, Shared, None)
4399 UNION_CLASS_BOILERPLATE(OmpDefaultClause);
4400 std::variant<DataSharingAttribute,
4402 u;
4403};
4404
4405// Ref: [4.5:103-107], [5.0:324-325], [5.1:357-358], [5.2:161-162]
4406//
4407// defaultmap-clause ->
4408// DEFAULTMAP(implicit-behavior
4409// [: variable-category]) // since 5.0
4410// implicit-behavior ->
4411// TOFROM | // since 4.5
4412// ALLOC | TO | FROM | FIRSTPRIVATE | NONE |
4413// DEFAULT | // since 5.0
4414// PRESENT // since 5.1
4416 TUPLE_CLASS_BOILERPLATE(OmpDefaultmapClause);
4417 ENUM_CLASS(ImplicitBehavior, Alloc, To, From, Tofrom, Firstprivate, None,
4418 Default, Present)
4419 MODIFIER_BOILERPLATE(OmpVariableCategory);
4420 std::tuple<ImplicitBehavior, MODIFIERS()> t;
4421};
4422
4423// Ref: [4.5:169-172], [5.0:255-259], [5.1:288-292], [5.2:91-93]
4424//
4425// iteration-offset ->
4426// +|- non-negative-constant // since 4.5
4428 TUPLE_CLASS_BOILERPLATE(OmpIterationOffset);
4429 std::tuple<DefinedOperator, ScalarIntConstantExpr> t;
4430};
4431
4432// Ref: [4.5:169-172], [5.0:255-259], [5.1:288-292], [5.2:91-93]
4433//
4434// iteration ->
4435// induction-variable [iteration-offset] // since 4.5
4437 TUPLE_CLASS_BOILERPLATE(OmpIteration);
4438 std::tuple<Name, std::optional<OmpIterationOffset>> t;
4439};
4440
4441// Ref: [4.5:169-172], [5.0:255-259], [5.1:288-292], [5.2:91-93]
4442//
4443// iteration-vector ->
4444// [iteration...] // since 4.5
4446 WRAPPER_CLASS_BOILERPLATE(OmpIterationVector, std::list<OmpIteration>);
4447};
4448
4449// Extract this into a separate structure (instead of having it directly in
4450// OmpDoacrossClause), so that the context in TYPE_CONTEXT_PARSER can be set
4451// separately for OmpDependClause and OmpDoacrossClause.
4452//
4453// See: depend-clause, doacross-clause
4455 OmpDependenceType::Value GetDepType() const;
4456
4457 WRAPPER_CLASS(Sink, OmpIterationVector);
4458 EMPTY_CLASS(Source);
4459 UNION_CLASS_BOILERPLATE(OmpDoacross);
4460 std::variant<Sink, Source> u;
4461};
4462
4463// Ref: [4.5:169-172], [5.0:255-259], [5.1:288-292], [5.2:323-326]
4464//
4465// depend-clause ->
4466// DEPEND(SOURCE) | // since 4.5, until 5.1
4467// DEPEND(SINK: iteration-vector) | // since 4.5, until 5.1
4468// DEPEND([depend-modifier,]
4469// task-dependence-type: locator-list) // since 4.5
4470//
4471// depend-modifier -> iterator-modifier // since 5.0
4473 UNION_CLASS_BOILERPLATE(OmpDependClause);
4474 struct TaskDep {
4475 OmpTaskDependenceType::Value GetTaskDepType() const;
4476 TUPLE_CLASS_BOILERPLATE(TaskDep);
4477 MODIFIER_BOILERPLATE(OmpIterator, OmpTaskDependenceType);
4478 std::tuple<MODIFIERS(), OmpObjectList> t;
4479 };
4480 std::variant<TaskDep, OmpDoacross> u;
4481};
4482
4483// Ref: [5.2:326-328]
4484//
4485// doacross-clause ->
4486// DOACROSS(dependence-type: iteration-vector) // since 5.2
4488 WRAPPER_CLASS_BOILERPLATE(OmpDoacrossClause, OmpDoacross);
4489};
4490
4491// Ref: [5.0:254-255], [5.1:287-288], [5.2:73]
4492//
4493// destroy-clause ->
4494// DESTROY | // since 5.0, until 5.1
4495// DESTROY(variable) // since 5.2
4497 WRAPPER_CLASS_BOILERPLATE(OmpDestroyClause, OmpObject);
4498};
4499
4500// Ref: [5.0:135-140], [5.1:161-166], [5.2:265-266]
4501//
4502// detach-clause ->
4503// DETACH(event-handle) // since 5.0
4505 WRAPPER_CLASS_BOILERPLATE(OmpDetachClause, OmpObject);
4506};
4507
4508// Ref: [4.5:103-107], [5.0:170-176], [5.1:197-205], [5.2:276-277]
4509//
4510// device-clause ->
4511// DEVICE(scalar-integer-expression) | // since 4.5
4512// DEVICE([device-modifier:]
4513// scalar-integer-expression) // since 5.0
4515 TUPLE_CLASS_BOILERPLATE(OmpDeviceClause);
4516 MODIFIER_BOILERPLATE(OmpDeviceModifier);
4517 std::tuple<MODIFIERS(), ScalarIntExpr> t;
4518};
4519
4520// Ref: [6.0:356-362]
4521//
4522// device-safesync-clause ->
4523// DEVICE_SAFESYNC [(scalar-logical-const-expr)] // since 6.0
4525 WRAPPER_CLASS_BOILERPLATE(OmpDeviceSafesyncClause, ScalarLogicalConstantExpr);
4526};
4527
4528// Ref: [5.0:180-185], [5.1:210-216], [5.2:275]
4529//
4530// device-type-clause ->
4531// DEVICE_TYPE(ANY | HOST | NOHOST) // since 5.0
4533 ENUM_CLASS(DeviceTypeDescription, Any, Host, Nohost)
4534 WRAPPER_CLASS_BOILERPLATE(OmpDeviceTypeClause, DeviceTypeDescription);
4535};
4536
4537// Ref: [5.0:60-63], [5.1:83-86], [5.2:212-213], [6.0:356-362]
4538//
4539// dynamic-allocators-clause ->
4540// DYNAMIC_ALLOCATORS // since 5.0
4541// [(scalar-logical-const-expr)] // since 6.0
4543 WRAPPER_CLASS_BOILERPLATE(
4544 OmpDynamicAllocatorsClause, ScalarLogicalConstantExpr);
4545};
4546
4548 TUPLE_CLASS_BOILERPLATE(OmpDynGroupprivateClause);
4549 MODIFIER_BOILERPLATE(OmpAccessGroup, OmpFallbackModifier);
4550 std::tuple<MODIFIERS(), ScalarIntExpr> t;
4551};
4552
4553// Ref: [5.2:158-159], [6.0:289-290]
4554//
4555// enter-clause ->
4556// ENTER(locator-list) |
4557// ENTER(automap-modifier: locator-list) | // since 6.0
4559 TUPLE_CLASS_BOILERPLATE(OmpEnterClause);
4560 MODIFIER_BOILERPLATE(OmpAutomapModifier);
4561 std::tuple<MODIFIERS(), OmpObjectList> t;
4562};
4563
4564// OMP 5.2 15.8.3 extended-atomic, fail-clause ->
4565// FAIL(memory-order)
4567 using MemoryOrder = common::OmpMemoryOrderType;
4568 WRAPPER_CLASS_BOILERPLATE(OmpFailClause, MemoryOrder);
4569};
4570
4571// Ref: [4.5:107-109], [5.0:176-180], [5.1:205-210], [5.2:167-168]
4572//
4573// from-clause ->
4574// FROM(locator-list) |
4575// FROM(mapper-modifier: locator-list) | // since 5.0
4576// FROM(motion-modifier[,] ...: locator-list) // since 5.1
4577// motion-modifier ->
4578// PRESENT | mapper-modifier | iterator-modifier
4580 TUPLE_CLASS_BOILERPLATE(OmpFromClause);
4581 MODIFIER_BOILERPLATE(OmpExpectation, OmpIterator, OmpMapper);
4582 std::tuple<MODIFIERS(), OmpObjectList, /*CommaSeparated=*/bool> t;
4583};
4584
4585// Ref: [4.5:87-91], [5.0:140-146], [5.1:166-171], [5.2:269]
4586//
4587// grainsize-clause ->
4588// GRAINSIZE(grain-size) | // since 4.5
4589// GRAINSIZE([prescriptiveness:] grain-size) // since 5.1
4591 TUPLE_CLASS_BOILERPLATE(OmpGrainsizeClause);
4592 MODIFIER_BOILERPLATE(OmpPrescriptiveness);
4593 std::tuple<MODIFIERS(), ScalarIntExpr> t;
4594};
4595
4596// Ref: [6.0:438]
4597//
4598// graph_id-clause ->
4599// GRAPH_ID(graph-id-value) // since 6.0
4601 WRAPPER_CLASS_BOILERPLATE(OmpGraphIdClause, ScalarIntExpr);
4602};
4603
4604// Ref: [6.0:438-439]
4605//
4606// graph_reset-clause ->
4607// GRAPH_RESET[(graph-reset-expression)] // since 6.0
4609 WRAPPER_CLASS_BOILERPLATE(OmpGraphResetClause, ScalarLogicalExpr);
4610};
4611
4612// Ref: [5.0:234-242], [5.1:266-275], [5.2:299], [6.0:472-473]
4614 WRAPPER_CLASS_BOILERPLATE(OmpHintClause, ScalarIntConstantExpr);
4615};
4616
4617// Ref: [5.2: 214]
4618//
4619// holds-clause ->
4620// HOLDS(expr)
4622 WRAPPER_CLASS_BOILERPLATE(OmpHoldsClause, common::Indirection<Expr>);
4623};
4624
4625// Ref: [5.2: 209]
4627 WRAPPER_CLASS_BOILERPLATE(
4628 OmpIndirectClause, std::optional<ScalarLogicalExpr>);
4629};
4630
4631// Ref: [5.2:72-73], in 4.5-5.1 it's scattered over individual directives
4632// that allow the IF clause.
4633//
4634// if-clause ->
4635// IF([directive-name-modifier:]
4636// scalar-logical-expression) // since 4.5
4638 TUPLE_CLASS_BOILERPLATE(OmpIfClause);
4639 MODIFIER_BOILERPLATE(OmpDirectiveNameModifier);
4640 std::tuple<MODIFIERS(), ScalarLogicalExpr> t;
4641};
4642
4643// Ref: [5.1:217-220], [5.2:293-294], [6.0:180-181]
4644//
4645// init-clause ->
4646// INIT ([modifier... :] interop-var) // since 5.1
4647// modifier ->
4648// prefer-type | interop-type | // since 5.1
4649// depinfo-modifier // since 6.0
4651 TUPLE_CLASS_BOILERPLATE(OmpInitClause);
4652 MODIFIER_BOILERPLATE(OmpPreferType, OmpInteropType, OmpDepinfoModifier);
4653 std::tuple<MODIFIERS(), OmpObject> t;
4654};
4655
4656// Ref: [5.0:170-176], [5.1:197-205], [5.2:138-139]
4657//
4658// in-reduction-clause ->
4659// IN_REDUCTION(reduction-identifier: list) // since 5.0
4661 TUPLE_CLASS_BOILERPLATE(OmpInReductionClause);
4662 MODIFIER_BOILERPLATE(OmpReductionIdentifier);
4663 std::tuple<MODIFIERS(), OmpObjectList> t;
4664};
4665
4666// Initialization for declare reduction construct
4668 WRAPPER_CLASS_BOILERPLATE(OmpInitializerClause, OmpInitializerExpression);
4669};
4670
4671// Ref: [4.5:199-201], [5.0:288-290], [5.1:321-322], [5.2:115-117]
4672//
4673// lastprivate-clause ->
4674// LASTPRIVATE(list) | // since 4.5
4675// LASTPRIVATE([lastprivate-modifier:] list) // since 5.0
4677 TUPLE_CLASS_BOILERPLATE(OmpLastprivateClause);
4678 MODIFIER_BOILERPLATE(OmpLastprivateModifier);
4679 std::tuple<MODIFIERS(), OmpObjectList> t;
4680};
4681
4682// Ref: [4.5:207-210], [5.0:290-293], [5.1:323-325], [5.2:117-120]
4683//
4684// linear-clause ->
4685// LINEAR(list [: step-simple-modifier]) | // since 4.5
4686// LINEAR(linear-modifier(list)
4687// [: step-simple-modifier]) | // since 4.5, until 5.2[*]
4688// LINEAR(list [: linear-modifier,
4689// step-complex-modifier]) // since 5.2
4690// [*] Still allowed in 5.2 when on DECLARE SIMD, but deprecated.
4692 TUPLE_CLASS_BOILERPLATE(OmpLinearClause);
4693 MODIFIER_BOILERPLATE(
4695 std::tuple<OmpObjectList, MODIFIERS(), /*PostModified=*/bool> t;
4696};
4697
4698// Ref: [6.0:207-208]
4699//
4700// looprange-clause ->
4701// LOOPRANGE(first, count) // since 6.0
4703 TUPLE_CLASS_BOILERPLATE(OmpLooprangeClause);
4704 std::tuple<ScalarIntConstantExpr, ScalarIntConstantExpr> t;
4705};
4706
4707// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158]
4708//
4709// map-clause ->
4710// MAP([modifier...:] locator-list) // since 4.5
4711// modifier ->
4712// map-type-modifier [replaced] | // since 4.5, until 5.2
4713// always-modifier | // since 6.0
4714// attach-modifier | // since 6.1
4715// close-modifier | // since 6.0
4716// delete-modifier | // since 6.0
4717// present-modifier | // since 6.0
4718// ref-modifier | // since 6.0
4719// self-modifier | // since 6.0
4720// mapper | // since 5.0
4721// iterator | // since 5.1
4722// map-type // since 4.5
4723// ompx-hold-modifier | // since 6.0
4724//
4725// Since 6.0 the map-type-modifier has been split into individual modifiers,
4726// and delete-modifier has been split from map-type.
4728 TUPLE_CLASS_BOILERPLATE(OmpMapClause);
4732 std::tuple<MODIFIERS(), OmpObjectList, /*CommaSeparated=*/bool> t;
4733};
4734
4735// Ref: [5.0:58-60], [5.1:63-68], [5.2:194-195]
4736//
4737// match-clause ->
4738// MATCH (context-selector-specification) // since 5.0
4740 // The context-selector is an argument.
4741 WRAPPER_CLASS_BOILERPLATE(
4743};
4744
4745// Ref: [5.2:217-218]
4746// message-clause ->
4747// MESSAGE("message-text")
4749 WRAPPER_CLASS_BOILERPLATE(OmpMessageClause, Expr);
4750};
4751
4752// Ref: [5.2: 214]
4753//
4754// no_openmp_clause -> NO_OPENMP
4755EMPTY_CLASS(OmpNoOpenMPClause);
4756
4757// Ref: [5.2: 214]
4758//
4759// no_openmp_routines_clause -> NO_OPENMP_ROUTINES
4760EMPTY_CLASS(OmpNoOpenMPRoutinesClause);
4761
4762// Ref: [5.2: 214]
4763//
4764// no_parallelism_clause -> NO_PARALELISM
4765EMPTY_CLASS(OmpNoParallelismClause);
4766
4767// Ref: [4.5:87-91], [5.0:140-146], [5.1:166-171], [5.2:270]
4768//
4769// num-tasks-clause ->
4770// NUM_TASKS(num-tasks) | // since 4.5
4771// NUM_TASKS([prescriptiveness:] num-tasks) // since 5.1
4773 TUPLE_CLASS_BOILERPLATE(OmpNumTasksClause);
4774 MODIFIER_BOILERPLATE(OmpPrescriptiveness);
4775 std::tuple<MODIFIERS(), ScalarIntExpr> t;
4776};
4777
4778// Ref: [4.5:114-116], [5.0:82-85], [5.1:100-104], [5.2:277], [6.0:452-453]
4779//
4780// num-teams-clause ->
4781// NUM_TEAMS(expr) | // since 4.5
4782// NUM_TEAMS([lower-bound:] upper-bound) | // since 5.1
4783// NUM_TEAMS([dims: upper-bound...) // since 6.1
4785 TUPLE_CLASS_BOILERPLATE(OmpNumTeamsClause);
4786 MODIFIER_BOILERPLATE(OmpDimsModifier, OmpLowerBound);
4787 std::tuple<MODIFIERS(), std::list<ScalarIntExpr>> t;
4788};
4789
4790// Ref: [4.5:46-50], [5.0:74-78], [5.1:92-96], [5.2:227], [6.0:388-389]
4791//
4792// num-threads-clause
4793// NUM_THREADS(expr) | // since 4.5
4794// NUM_THREADS(expr...) | // since 6.0
4795// NUM_THREADS([dims-modifier:] expr...) // since 6.1
4797 TUPLE_CLASS_BOILERPLATE(OmpNumThreadsClause);
4798 MODIFIER_BOILERPLATE(OmpDimsModifier);
4799 std::tuple<MODIFIERS(), std::list<ScalarIntExpr>> t;
4800};
4801
4802// Ref: [5.0:101-109], [5.1:126-134], [5.2:233-234]
4803//
4804// order-clause ->
4805// ORDER(CONCURRENT) | // since 5.0
4806// ORDER([order-modifier:] CONCURRENT) // since 5.1
4808 TUPLE_CLASS_BOILERPLATE(OmpOrderClause);
4809 ENUM_CLASS(Ordering, Concurrent)
4810 MODIFIER_BOILERPLATE(OmpOrderModifier);
4811 std::tuple<MODIFIERS(), Ordering> t;
4812};
4813
4814// Ref: [5.0:56-57], [5.1:60-62], [5.2:191]
4815//
4816// otherwise-clause ->
4817// DEFAULT ([directive-specification]) // since 5.0, until 5.1
4818// otherwise-clause ->
4819// OTHERWISE ([directive-specification])] // since 5.2
4821 WRAPPER_CLASS_BOILERPLATE(OmpOtherwiseClause,
4823};
4824
4825// Ref: [4.5:46-50], [5.0:74-78], [5.1:92-96], [5.2:229-230]
4826//
4827// proc-bind-clause ->
4828// PROC_BIND(affinity-policy) // since 4.5
4829// affinity-policy ->
4830// CLOSE | PRIMARY | SPREAD | // since 4.5
4831// MASTER // since 4.5, until 5.2
4833 ENUM_CLASS(AffinityPolicy, Close, Master, Spread, Primary)
4834 WRAPPER_CLASS_BOILERPLATE(OmpProcBindClause, AffinityPolicy);
4835};
4836
4837// Ref: [4.5:201-207], [5.0:300-302], [5.1:332-334], [5.2:134-137]
4838//
4839// reduction-clause ->
4840// REDUCTION(reduction-identifier: list) | // since 4.5
4841// REDUCTION([reduction-modifier,]
4842// reduction-identifier: list) // since 5.0
4844 TUPLE_CLASS_BOILERPLATE(OmpReductionClause);
4845 MODIFIER_BOILERPLATE(OmpReductionModifier, OmpReductionIdentifier);
4846 std::tuple<MODIFIERS(), OmpObjectList> t;
4847};
4848
4849// Ref: [6.0:440:441]
4850//
4851// replayable-clause ->
4852// REPLAYABLE[(replayable-expression)] // since 6.0
4854 WRAPPER_CLASS_BOILERPLATE(OmpReplayableClause, ScalarLogicalConstantExpr);
4855};
4856
4857// Ref: [5.0:60-63], [5.1:83-86], [5.2:212-213], [6.0:356-362]
4858//
4859// reverse-offload-clause ->
4860// REVERSE_OFFLOAD // since 5.0
4861// [(scalar-logical-const-expr)] // since 6.0
4863 WRAPPER_CLASS_BOILERPLATE(OmpReverseOffloadClause, ScalarLogicalConstantExpr);
4864};
4865
4866// Ref: [4.5:56-63], [5.0:101-109], [5.1:126-133], [5.2:252-254]
4867//
4868// schedule-clause ->
4869// SCHEDULE([modifier[, modifier]:]
4870// kind[, chunk-size]) // since 4.5, until 5.1
4871// schedule-clause ->
4872// SCHEDULE([ordering-modifier], chunk-modifier],
4873// kind[, chunk_size]) // since 5.2
4875 TUPLE_CLASS_BOILERPLATE(OmpScheduleClause);
4876 ENUM_CLASS(Kind, Static, Dynamic, Guided, Auto, Runtime)
4877 MODIFIER_BOILERPLATE(OmpOrderingModifier, OmpChunkModifier);
4878 std::tuple<MODIFIERS(), Kind, std::optional<ScalarIntExpr>> t;
4879};
4880
4881// ref: [6.0:361-362]
4882//
4883// self-maps-clause ->
4884// SELF_MAPS [(scalar-logical-const-expr)] // since 6.0
4886 WRAPPER_CLASS_BOILERPLATE(OmpSelfMapsClause, ScalarLogicalConstantExpr);
4887};
4888
4889// REF: [5.2:217]
4890// severity-clause ->
4891// SEVERITY(warning|fatal)
4893 ENUM_CLASS(SevLevel, Fatal, Warning);
4894 WRAPPER_CLASS_BOILERPLATE(OmpSeverityClause, SevLevel);
4895};
4896
4897// Ref: [5.0:232-234], [5.1:264-266], [5.2:137]
4898//
4899// task-reduction-clause ->
4900// TASK_REDUCTION(reduction-identifier: list) // since 5.0
4902 TUPLE_CLASS_BOILERPLATE(OmpTaskReductionClause);
4903 MODIFIER_BOILERPLATE(OmpReductionIdentifier);
4904 std::tuple<MODIFIERS(), OmpObjectList> t;
4905};
4906
4907// Ref: [4.5:114-116], [5.0:82-85], [5.1:100-104], [5.2:277], [6.0:452-453]
4908//
4909// thread-limit-clause ->
4910// THREAD_LIMIT(threadlim) // since 4.5
4911// THREAD_LIMIT([dims-modifier:] threadlim...) // since 6.1
4913 TUPLE_CLASS_BOILERPLATE(OmpThreadLimitClause);
4914 MODIFIER_BOILERPLATE(OmpDimsModifier);
4915 std::tuple<MODIFIERS(), std::list<ScalarIntExpr>> t;
4916};
4917
4918// Ref: [6.0:442]
4919// threadset-clause ->
4920// THREADSET(omp_pool|omp_team)
4922 ENUM_CLASS(ThreadsetPolicy, Omp_Pool, Omp_Team)
4923 WRAPPER_CLASS_BOILERPLATE(OmpThreadsetClause, ThreadsetPolicy);
4924};
4925
4926// Ref: [4.5:107-109], [5.0:176-180], [5.1:205-210], [5.2:167-168]
4927//
4928// to-clause (in DECLARE TARGET) ->
4929// TO(extended-list) | // until 5.1
4930// to-clause (in TARGET UPDATE) ->
4931// TO(locator-list) |
4932// TO(mapper-modifier: locator-list) | // since 5.0
4933// TO(motion-modifier[,] ...: locator-list) // since 5.1
4934// motion-modifier ->
4935// PRESENT | mapper-modifier | iterator-modifier
4937 TUPLE_CLASS_BOILERPLATE(OmpToClause);
4938 MODIFIER_BOILERPLATE(OmpExpectation, OmpIterator, OmpMapper);
4939 std::tuple<MODIFIERS(), OmpObjectList, /*CommaSeparated=*/bool> t;
4940};
4941
4942// Ref: [6.0:510-511]
4943//
4944// transparent-clause ->
4945// TRANSPARENT[(impex-type)] // since 6.0
4947 WRAPPER_CLASS_BOILERPLATE(OmpTransparentClause, ScalarIntExpr);
4948};
4949
4950// Ref: [5.0:60-63], [5.1:83-86], [5.2:212-213], [6.0:356-362]
4951//
4952// unified-address-clause ->
4953// UNIFIED_ADDRESS // since 5.0
4954// [(scalar-logical-const-expr)] // since 6.0
4956 WRAPPER_CLASS_BOILERPLATE(OmpUnifiedAddressClause, ScalarLogicalConstantExpr);
4957};
4958
4959// Ref: [5.0:60-63], [5.1:83-86], [5.2:212-213], [6.0:356-362]
4960//
4961// unified-shared-memory-clause ->
4962// UNIFIED_SHARED_MEMORY // since 5.0
4963// [(scalar-logical-const-expr)] // since 6.0
4965 WRAPPER_CLASS_BOILERPLATE(
4966 OmpUnifiedSharedMemoryClause, ScalarLogicalConstantExpr);
4967};
4968
4969// Ref: [5.0:254-255], [5.1:287-288], [5.2:321-322]
4970//
4971// In ATOMIC construct
4972// update-clause ->
4973// UPDATE // Since 4.5
4974//
4975// In DEPOBJ construct
4976// update-clause ->
4977// UPDATE(dependence-type) // since 5.0, until 5.1
4978// update-clause ->
4979// UPDATE(task-dependence-type) // since 5.2
4981 UNION_CLASS_BOILERPLATE(OmpUpdateClause);
4982 // The dependence type is an argument here, not a modifier.
4983 std::variant<OmpDependenceType, OmpTaskDependenceType> u;
4984};
4985
4986// Ref: [5.0:56-57], [5.1:60-62], [5.2:190-191]
4987//
4988// when-clause ->
4989// WHEN (context-selector :
4990// [directive-specification]) // since 5.0
4992 TUPLE_CLASS_BOILERPLATE(OmpWhenClause);
4993 MODIFIER_BOILERPLATE(OmpContextSelector);
4994 std::tuple<MODIFIERS(),
4995 std::optional<common::Indirection<OmpDirectiveSpecification>>>
4996 t;
4997};
4998
4999// REF: [5.1:217-220], [5.2:294]
5000//
5001// 14.1.3 use-clause -> USE (interop-var)
5003 WRAPPER_CLASS_BOILERPLATE(OmpUseClause, OmpObject);
5004};
5005
5006// OpenMP Clauses
5008 UNION_CLASS_BOILERPLATE(OmpClause);
5009 llvm::omp::Clause Id() const;
5010
5011#define GEN_FLANG_CLAUSE_PARSER_CLASSES
5012#include "llvm/Frontend/OpenMP/OMP.inc"
5013
5014 CharBlock source;
5015
5016 std::variant<
5017#define GEN_FLANG_CLAUSE_PARSER_CLASSES_LIST
5018#include "llvm/Frontend/OpenMP/OMP.inc"
5019 >
5020 u;
5021};
5022
5024 WRAPPER_CLASS_BOILERPLATE(OmpClauseList, std::list<OmpClause>);
5025 CharBlock source;
5026};
5027
5028// --- Directives and constructs
5029
5031 ENUM_CLASS(Flag, DeprecatedSyntax, CrossesLabelDo)
5033
5034 TUPLE_CLASS_BOILERPLATE(OmpDirectiveSpecification);
5035 const OmpDirectiveName &DirName() const {
5036 return std::get<OmpDirectiveName>(t);
5037 }
5038 llvm::omp::Directive DirId() const { //
5039 return DirName().v;
5040 }
5041 const OmpArgumentList &Arguments() const;
5042 const OmpClauseList &Clauses() const;
5043
5044 CharBlock source;
5045 std::tuple<OmpDirectiveName, std::optional<OmpArgumentList>,
5046 std::optional<OmpClauseList>, Flags>
5047 t;
5048};
5049
5050// OmpBeginDirective and OmpEndDirective are needed for semantic analysis,
5051// where some checks are done specifically for either the begin or the end
5052// directive. The structure of both is identical, but the diffent types
5053// allow to distinguish them in the type-based parse-tree visitor.
5055 INHERITED_TUPLE_CLASS_BOILERPLATE(
5057};
5058
5060 INHERITED_TUPLE_CLASS_BOILERPLATE(OmpEndDirective, OmpDirectiveSpecification);
5061};
5062
5063// Common base class for block-associated constructs.
5065 TUPLE_CLASS_BOILERPLATE(OmpBlockConstruct);
5066 const OmpBeginDirective &BeginDir() const {
5067 return std::get<OmpBeginDirective>(t);
5068 }
5069 const std::optional<OmpEndDirective> &EndDir() const {
5070 return std::get<std::optional<OmpEndDirective>>(t);
5071 }
5072
5073 CharBlock source;
5074 std::tuple<OmpBeginDirective, Block, std::optional<OmpEndDirective>> t;
5075};
5076
5078 WRAPPER_CLASS_BOILERPLATE(
5080};
5081
5082// Ref: [5.1:89-90], [5.2:216]
5083//
5084// nothing-directive ->
5085// NOTHING // since 5.1
5087 WRAPPER_CLASS_BOILERPLATE(OmpNothingDirective, OmpDirectiveSpecification);
5088};
5089
5090// Ref: OpenMP [5.2:216-218]
5091// ERROR AT(compilation|execution) SEVERITY(fatal|warning) MESSAGE("msg-str)
5093 WRAPPER_CLASS_BOILERPLATE(OmpErrorDirective, OmpDirectiveSpecification);
5094};
5095
5097 UNION_CLASS_BOILERPLATE(OpenMPUtilityConstruct);
5098 CharBlock source;
5099 std::variant<OmpErrorDirective, OmpNothingDirective> u;
5100};
5101
5102// Ref: [5.2: 213-216]
5103//
5104// assumes-construct ->
5105// ASSUMES absent-clause | contains-clause | holds-clause | no-openmp-clause |
5106// no-openmp-routines-clause | no-parallelism-clause
5108 WRAPPER_CLASS_BOILERPLATE(
5110 CharBlock source;
5111};
5112
5113// Ref: [5.1:86-89], [5.2:215], [6.0:369]
5114//
5115// assume-directive -> // since 5.1
5116// ASSUME assumption-clause...
5117// block
5118// [END ASSUME]
5120 INHERITED_TUPLE_CLASS_BOILERPLATE(OpenMPAssumeConstruct, OmpBlockConstruct);
5121};
5122
5123// 2.7.2 SECTIONS
5124// 2.11.2 PARALLEL SECTIONS
5126 INHERITED_TUPLE_CLASS_BOILERPLATE(
5128};
5129
5131 INHERITED_TUPLE_CLASS_BOILERPLATE(OmpEndSectionsDirective, OmpEndDirective);
5132};
5133
5134// [!$omp section]
5135// structured-block
5136// [!$omp section
5137// structured-block]
5138// ...
5140 TUPLE_CLASS_BOILERPLATE(OpenMPSectionConstruct);
5141 std::tuple<std::optional<OmpDirectiveSpecification>, Block> t;
5142 CharBlock source;
5143};
5144
5146 TUPLE_CLASS_BOILERPLATE(OpenMPSectionsConstruct);
5147 CharBlock source;
5148 const OmpBeginSectionsDirective &BeginDir() const {
5149 return std::get<OmpBeginSectionsDirective>(t);
5150 }
5151 const std::optional<OmpEndSectionsDirective> &EndDir() const {
5152 return std::get<std::optional<OmpEndSectionsDirective>>(t);
5153 }
5154 // Each of the OpenMPConstructs in the list below contains an
5155 // OpenMPSectionConstruct. This is guaranteed by the parser.
5156 // The end sections directive is optional here because it is difficult to
5157 // generate helpful error messages for a missing end directive within the
5158 // parser. Semantics will generate an error if this is absent.
5159 std::tuple<OmpBeginSectionsDirective, std::list<OpenMPConstruct>,
5160 std::optional<OmpEndSectionsDirective>>
5161 t;
5162};
5163
5164// Ref: [4.5:58-60], [5.0:58-60], [5.1:63-68], [5.2:197-198], [6.0:334-336]
5165//
5166// declare-variant-directive ->
5167// DECLARE_VARIANT([base-name:]variant-name) // since 4.5
5169 WRAPPER_CLASS_BOILERPLATE(
5171 CharBlock source;
5172};
5173
5174// Ref: [4.5:110-113], [5.0:180-185], [5.1:210-216], [5.2:206-207],
5175// [6.0:346-348]
5176//
5177// declare-target-directive -> // since 4.5
5178// DECLARE_TARGET[(extended-list)] |
5179// DECLARE_TARGET clause-list
5181 WRAPPER_CLASS_BOILERPLATE(
5183 CharBlock source;
5184};
5185
5186// OMP v5.2: 5.8.8
5187// declare-mapper -> DECLARE MAPPER ([mapper-name :] type :: var) map-clauses
5189 WRAPPER_CLASS_BOILERPLATE(
5191 CharBlock source;
5192};
5193
5194// ref: 5.2: Section 5.5.11 139-141
5195// 2.16 declare-reduction -> DECLARE REDUCTION (reduction-identifier : type-list
5196// : combiner) [initializer-clause]
5198 WRAPPER_CLASS_BOILERPLATE(
5200 CharBlock source;
5201};
5202
5203// 2.8.2 declare-simd -> DECLARE SIMD [(proc-name)] [declare-simd-clause[ [,]
5204// declare-simd-clause]...]
5206 WRAPPER_CLASS_BOILERPLATE(
5208 CharBlock source;
5209};
5210
5211// ref: [6.0:301-303]
5212//
5213// groupprivate-directive ->
5214// GROUPPRIVATE (variable-list-item...) // since 6.0
5216 WRAPPER_CLASS_BOILERPLATE(OpenMPGroupprivate, OmpDirectiveSpecification);
5217 CharBlock source;
5218};
5219
5220// 2.4 requires -> REQUIRES requires-clause[ [ [,] requires-clause]...]
5222 WRAPPER_CLASS_BOILERPLATE(OpenMPRequiresConstruct, OmpDirectiveSpecification);
5223 CharBlock source;
5224};
5225
5226// 2.15.2 threadprivate -> THREADPRIVATE (variable-name-list)
5228 WRAPPER_CLASS_BOILERPLATE(OpenMPThreadprivate, OmpDirectiveSpecification);
5229 CharBlock source;
5230};
5231
5232// Ref: [4.5:310-312], [5.0:156-158], [5.1:181-184], [5.2:176-177],
5233// [6.0:310-312]
5234//
5235// allocate-directive ->
5236// ALLOCATE (variable-list-item...) | // since 4.5
5237// ALLOCATE (variable-list-item...) // since 5.0, until 5.1
5238// ...
5239// allocate-stmt
5240//
5241// The first form is the "declarative-allocate", and is a declarative
5242// directive. The second is the "executable-allocate" and is an executable
5243// directive. The executable form was deprecated in 5.2.
5244//
5245// The executable-allocate consists of several ALLOCATE directives. Since
5246// in the parse tree every type corresponding to a directive only corresponds
5247// to a single directive, the executable form is represented by a sequence
5248// of nested OmpAlocateDirectives, e.g.
5249// !$OMP ALLOCATE(x)
5250// !$OMP ALLOCATE(y)
5251// ALLOCATE(x, y)
5252// will become
5253// OmpAllocateDirective
5254// |- ALLOCATE(x) // begin directive
5255// `- OmpAllocateDirective // block
5256// |- ALLOCATE(y) // begin directive
5257// `- ALLOCATE(x, y) // block
5258//
5259// The block in the declarative-allocate will be empty.
5261 INHERITED_TUPLE_CLASS_BOILERPLATE(OmpAllocateDirective, OmpBlockConstruct);
5262};
5263
5275
5277 INHERITED_TUPLE_CLASS_BOILERPLATE(OpenMPCriticalConstruct, OmpBlockConstruct);
5278};
5279
5280// Ref: [5.2:180-181], [6.0:315]
5281//
5282// allocators-construct ->
5283// ALLOCATORS [allocate-clause...]
5284// block
5285// [END ALLOCATORS]
5287 INHERITED_TUPLE_CLASS_BOILERPLATE(
5289};
5290
5292 llvm::omp::Clause GetKind() const;
5293 bool IsCapture() const;
5294 bool IsCompare() const;
5295 INHERITED_TUPLE_CLASS_BOILERPLATE(OpenMPAtomicConstruct, OmpBlockConstruct);
5296
5297 // Information filled out during semantic checks to avoid duplication
5298 // of analyses.
5299 struct Analysis {
5300 static constexpr int None = 0;
5301 static constexpr int Read = 1;
5302 static constexpr int Write = 2;
5303 static constexpr int Update = Read | Write;
5304 static constexpr int Action = 3; // Bitmask for None, Read, Write, Update
5305 static constexpr int IfTrue = 4;
5306 static constexpr int IfFalse = 8;
5307 static constexpr int Condition = 12; // Bitmask for IfTrue, IfFalse
5308
5309 struct Op {
5310 int what;
5311 TypedAssignment assign;
5312 };
5313 TypedExpr atom, cond;
5314 Op op0, op1;
5315 };
5316
5317 mutable Analysis analysis;
5318};
5319
5320// 2.14.2 cancellation-point -> CANCELLATION POINT construct-type-clause
5322 WRAPPER_CLASS_BOILERPLATE(
5324 CharBlock source;
5325};
5326
5327// 2.14.1 cancel -> CANCEL construct-type-clause [ [,] if-clause]
5329 WRAPPER_CLASS_BOILERPLATE(OpenMPCancelConstruct, OmpDirectiveSpecification);
5330 CharBlock source;
5331};
5332
5333// Ref: [5.0:254-255], [5.1:287-288], [5.2:322-323]
5334//
5335// depobj-construct -> DEPOBJ(depend-object) depobj-clause // since 5.0
5336// depobj-clause -> depend-clause | // until 5.2
5337// destroy-clause |
5338// update-clause
5340 WRAPPER_CLASS_BOILERPLATE(OpenMPDepobjConstruct, OmpDirectiveSpecification);
5341 CharBlock source;
5342};
5343
5344// Ref: [5.2: 200-201]
5345//
5346// dispatch-construct -> DISPATCH dispatch-clause
5347// dispatch-clause -> depend-clause |
5348// device-clause |
5349// is_device_ptr-clause |
5350// nocontext-clause |
5351// novariants-clause |
5352// nowait-clause
5354 INHERITED_TUPLE_CLASS_BOILERPLATE(OpenMPDispatchConstruct, OmpBlockConstruct);
5355};
5356
5357// [4.5:162-165], [5.0:242-246], [5.1:275-279], [5.2:315-316], [6.0:498-500]
5358//
5359// flush-construct ->
5360// FLUSH [(list)] // since 4.5, until 4.5
5361// flush-construct ->
5362// FLUSH [memory-order-clause] [(list)] // since 5.0, until 5.1
5363// flush-construct ->
5364// FLUSH [(list)] [clause-list] // since 5.2
5365//
5366// memory-order-clause -> // since 5.0, until 5.1
5367// ACQ_REL | RELEASE | ACQUIRE | // since 5.0
5368// SEQ_CST // since 5.1
5370 WRAPPER_CLASS_BOILERPLATE(OpenMPFlushConstruct, OmpDirectiveSpecification);
5371 CharBlock source;
5372};
5373
5374// Ref: [5.1:217-220], [5.2:291-292]
5375//
5376// interop -> INTEROP clause[ [ [,] clause]...]
5378 WRAPPER_CLASS_BOILERPLATE(OpenMPInteropConstruct, OmpDirectiveSpecification);
5379 CharBlock source;
5380};
5381
5383 WRAPPER_CLASS_BOILERPLATE(
5385 CharBlock source;
5386};
5387
5396
5398 INHERITED_TUPLE_CLASS_BOILERPLATE(OmpBeginLoopDirective, OmpBeginDirective);
5399};
5400
5402 INHERITED_TUPLE_CLASS_BOILERPLATE(OmpEndLoopDirective, OmpEndDirective);
5403};
5404
5405// OpenMP directives enclosing do loop
5406struct OpenMPLoopConstruct {
5407 TUPLE_CLASS_BOILERPLATE(OpenMPLoopConstruct);
5408 OpenMPLoopConstruct(OmpBeginLoopDirective &&a)
5409 : t({std::move(a), Block{}, std::nullopt}) {}
5410
5411 const OmpBeginLoopDirective &BeginDir() const {
5412 return std::get<OmpBeginLoopDirective>(t);
5413 }
5414 const std::optional<OmpEndLoopDirective> &EndDir() const {
5415 return std::get<std::optional<OmpEndLoopDirective>>(t);
5416 }
5417 const DoConstruct *GetNestedLoop() const;
5418 const OpenMPLoopConstruct *GetNestedConstruct() const;
5419
5420 CharBlock source;
5421 std::tuple<OmpBeginLoopDirective, Block, std::optional<OmpEndLoopDirective>>
5422 t;
5423};
5424
5425// Lookahead class to identify execution-part OpenMP constructs without
5426// parsing the entire OpenMP construct.
5428 WRAPPER_CLASS_BOILERPLATE(OpenMPExecDirective, OmpDirectiveName);
5429 CharBlock source;
5430};
5431
5441
5442// Orphaned !$OMP END <directive>, i.e. not being a part of a valid OpenMP
5443// construct.
5445 INHERITED_TUPLE_CLASS_BOILERPLATE(
5447};
5448
5449// Unrecognized string after the !$OMP sentinel.
5451 using EmptyTrait = std::true_type;
5452 CharBlock source;
5453};
5454
5455// Parse tree nodes for OpenACC 3.3 directives and clauses
5456
5458 UNION_CLASS_BOILERPLATE(AccObject);
5459 std::variant<Designator, /*common block*/ Name> u;
5460};
5461
5462WRAPPER_CLASS(AccObjectList, std::list<AccObject>);
5463
5464// OpenACC directive beginning or ending a block
5466 WRAPPER_CLASS_BOILERPLATE(AccBlockDirective, llvm::acc::Directive);
5467 CharBlock source;
5468};
5469
5471 WRAPPER_CLASS_BOILERPLATE(AccLoopDirective, llvm::acc::Directive);
5472 CharBlock source;
5473};
5474
5476 WRAPPER_CLASS_BOILERPLATE(AccStandaloneDirective, llvm::acc::Directive);
5477 CharBlock source;
5478};
5479
5480// 2.11 Combined constructs
5482 WRAPPER_CLASS_BOILERPLATE(AccCombinedDirective, llvm::acc::Directive);
5483 CharBlock source;
5484};
5485
5487 WRAPPER_CLASS_BOILERPLATE(AccDeclarativeDirective, llvm::acc::Directive);
5488 CharBlock source;
5489};
5490
5491// OpenACC Clauses
5493 UNION_CLASS_BOILERPLATE(AccBindClause);
5494 std::variant<Name, ScalarDefaultCharExpr> u;
5495 CharBlock source;
5496};
5497
5499 WRAPPER_CLASS_BOILERPLATE(AccDefaultClause, llvm::acc::DefaultValue);
5500 CharBlock source;
5501};
5502
5504 ENUM_CLASS(Modifier, ReadOnly, Zero)
5505 WRAPPER_CLASS_BOILERPLATE(AccDataModifier, Modifier);
5506 CharBlock source;
5507};
5508
5510 TUPLE_CLASS_BOILERPLATE(AccObjectListWithModifier);
5511 std::tuple<std::optional<AccDataModifier>, AccObjectList> t;
5512};
5513
5515 TUPLE_CLASS_BOILERPLATE(AccObjectListWithReduction);
5516 std::tuple<ReductionOperator, AccObjectList> t;
5517};
5518
5520 TUPLE_CLASS_BOILERPLATE(AccWaitArgument);
5521 std::tuple<std::optional<ScalarIntExpr>, std::list<ScalarIntExpr>> t;
5522};
5523
5525 WRAPPER_CLASS_BOILERPLATE(
5526 AccDeviceTypeExpr, Fortran::common::OpenACCDeviceType);
5527 CharBlock source;
5528};
5529
5531 WRAPPER_CLASS_BOILERPLATE(
5532 AccDeviceTypeExprList, std::list<AccDeviceTypeExpr>);
5533};
5534
5536 TUPLE_CLASS_BOILERPLATE(AccTileExpr);
5537 CharBlock source;
5538 std::tuple<std::optional<ScalarIntConstantExpr>> t; // if null then *
5539};
5540
5542 WRAPPER_CLASS_BOILERPLATE(AccTileExprList, std::list<AccTileExpr>);
5543};
5544
5546 WRAPPER_CLASS_BOILERPLATE(AccSizeExpr, std::optional<ScalarIntExpr>);
5547};
5548
5550 WRAPPER_CLASS_BOILERPLATE(AccSizeExprList, std::list<AccSizeExpr>);
5551};
5552
5554 UNION_CLASS_BOILERPLATE(AccSelfClause);
5555 std::variant<std::optional<ScalarLogicalExpr>, AccObjectList> u;
5556 CharBlock source;
5557};
5558
5559// num, dim, static
5561 UNION_CLASS_BOILERPLATE(AccGangArg);
5562 WRAPPER_CLASS(Num, ScalarIntExpr);
5563 WRAPPER_CLASS(Dim, ScalarIntExpr);
5564 WRAPPER_CLASS(Static, AccSizeExpr);
5565 std::variant<Num, Dim, Static> u;
5566 CharBlock source;
5567};
5568
5570 WRAPPER_CLASS_BOILERPLATE(AccGangArgList, std::list<AccGangArg>);
5571};
5572
5574 TUPLE_CLASS_BOILERPLATE(AccCollapseArg);
5575 std::tuple<bool, ScalarIntConstantExpr> t;
5576};
5577
5579 UNION_CLASS_BOILERPLATE(AccClause);
5580
5581#define GEN_FLANG_CLAUSE_PARSER_CLASSES
5582#include "llvm/Frontend/OpenACC/ACC.inc"
5583
5584 CharBlock source;
5585
5586 std::variant<
5587#define GEN_FLANG_CLAUSE_PARSER_CLASSES_LIST
5588#include "llvm/Frontend/OpenACC/ACC.inc"
5589 >
5590 u;
5591};
5592
5594 WRAPPER_CLASS_BOILERPLATE(AccClauseList, std::list<AccClause>);
5595 CharBlock source;
5596};
5597
5599 TUPLE_CLASS_BOILERPLATE(OpenACCRoutineConstruct);
5600 CharBlock source;
5601 std::tuple<Verbatim, std::optional<Name>, AccClauseList> t;
5602};
5603
5605 TUPLE_CLASS_BOILERPLATE(OpenACCCacheConstruct);
5606 CharBlock source;
5607 std::tuple<Verbatim, AccObjectListWithModifier> t;
5608};
5609
5611 TUPLE_CLASS_BOILERPLATE(OpenACCWaitConstruct);
5612 CharBlock source;
5613 std::tuple<Verbatim, std::optional<AccWaitArgument>, AccClauseList> t;
5614};
5615
5617 TUPLE_CLASS_BOILERPLATE(AccBeginLoopDirective);
5618 std::tuple<AccLoopDirective, AccClauseList> t;
5619 CharBlock source;
5620};
5621
5623 TUPLE_CLASS_BOILERPLATE(AccBeginBlockDirective);
5624 CharBlock source;
5625 std::tuple<AccBlockDirective, AccClauseList> t;
5626};
5627
5629 CharBlock source;
5630 WRAPPER_CLASS_BOILERPLATE(AccEndBlockDirective, AccBlockDirective);
5631};
5632
5633// ACC END ATOMIC
5634EMPTY_CLASS(AccEndAtomic);
5635
5636// ACC ATOMIC READ
5638 TUPLE_CLASS_BOILERPLATE(AccAtomicRead);
5639 std::tuple<Verbatim, AccClauseList, Statement<AssignmentStmt>,
5640 std::optional<AccEndAtomic>>
5641 t;
5642};
5643
5644// ACC ATOMIC WRITE
5646 TUPLE_CLASS_BOILERPLATE(AccAtomicWrite);
5647 std::tuple<Verbatim, AccClauseList, Statement<AssignmentStmt>,
5648 std::optional<AccEndAtomic>>
5649 t;
5650};
5651
5652// ACC ATOMIC UPDATE
5654 TUPLE_CLASS_BOILERPLATE(AccAtomicUpdate);
5655 std::tuple<std::optional<Verbatim>, AccClauseList, Statement<AssignmentStmt>,
5656 std::optional<AccEndAtomic>>
5657 t;
5658};
5659
5660// ACC ATOMIC CAPTURE
5662 TUPLE_CLASS_BOILERPLATE(AccAtomicCapture);
5663 WRAPPER_CLASS(Stmt1, Statement<AssignmentStmt>);
5664 WRAPPER_CLASS(Stmt2, Statement<AssignmentStmt>);
5665 std::tuple<Verbatim, AccClauseList, Stmt1, Stmt2, AccEndAtomic> t;
5666};
5667
5669 UNION_CLASS_BOILERPLATE(OpenACCAtomicConstruct);
5670 std::variant<AccAtomicRead, AccAtomicWrite, AccAtomicCapture, AccAtomicUpdate>
5671 u;
5672 CharBlock source;
5673};
5674
5676 TUPLE_CLASS_BOILERPLATE(OpenACCBlockConstruct);
5677 std::tuple<AccBeginBlockDirective, Block, AccEndBlockDirective> t;
5678};
5679
5681 TUPLE_CLASS_BOILERPLATE(OpenACCStandaloneDeclarativeConstruct);
5682 CharBlock source;
5683 std::tuple<AccDeclarativeDirective, AccClauseList> t;
5684};
5685
5687 TUPLE_CLASS_BOILERPLATE(AccBeginCombinedDirective);
5688 CharBlock source;
5689 std::tuple<AccCombinedDirective, AccClauseList> t;
5690};
5691
5693 WRAPPER_CLASS_BOILERPLATE(AccEndCombinedDirective, AccCombinedDirective);
5694 CharBlock source;
5695};
5696
5697struct OpenACCCombinedConstruct {
5698 TUPLE_CLASS_BOILERPLATE(OpenACCCombinedConstruct);
5699 CharBlock source;
5700 OpenACCCombinedConstruct(AccBeginCombinedDirective &&a)
5701 : t({std::move(a), std::nullopt, std::nullopt}) {}
5702 std::tuple<AccBeginCombinedDirective, std::optional<DoConstruct>,
5703 std::optional<AccEndCombinedDirective>>
5704 t;
5705};
5706
5708 UNION_CLASS_BOILERPLATE(OpenACCDeclarativeConstruct);
5709 CharBlock source;
5710 std::variant<OpenACCStandaloneDeclarativeConstruct, OpenACCRoutineConstruct>
5711 u;
5712};
5713
5714// OpenACC directives enclosing do loop
5715EMPTY_CLASS(AccEndLoop);
5716struct OpenACCLoopConstruct {
5717 TUPLE_CLASS_BOILERPLATE(OpenACCLoopConstruct);
5718 OpenACCLoopConstruct(AccBeginLoopDirective &&a)
5719 : t({std::move(a), std::nullopt, std::nullopt}) {}
5720 std::tuple<AccBeginLoopDirective, std::optional<DoConstruct>,
5721 std::optional<AccEndLoop>>
5722 t;
5723};
5724
5726 WRAPPER_CLASS_BOILERPLATE(OpenACCEndConstruct, llvm::acc::Directive);
5727 CharBlock source;
5728};
5729
5731 TUPLE_CLASS_BOILERPLATE(OpenACCStandaloneConstruct);
5732 CharBlock source;
5733 std::tuple<AccStandaloneDirective, AccClauseList> t;
5734};
5735
5743
5744// CUF-kernel-do-construct ->
5745// !$CUF KERNEL DO [ (scalar-int-constant-expr) ]
5746// <<< grid, block [, stream] >>>
5747// [ cuf-reduction... ]
5748// do-construct
5749// star-or-expr -> * | scalar-int-expr
5750// grid -> * | scalar-int-expr | ( star-or-expr-list )
5751// block -> * | scalar-int-expr | ( star-or-expr-list )
5752// stream -> 0, scalar-int-expr | STREAM = scalar-int-expr
5753// cuf-reduction -> [ REDUCE | REDUCTION ] (
5754// reduction-op : scalar-variable-list )
5755
5757 TUPLE_CLASS_BOILERPLATE(CUFReduction);
5758 using Operator = ReductionOperator;
5759 std::tuple<Operator, std::list<Scalar<Variable>>> t;
5760};
5761
5763 TUPLE_CLASS_BOILERPLATE(CUFKernelDoConstruct);
5764 WRAPPER_CLASS(StarOrExpr, std::optional<ScalarIntExpr>);
5766 TUPLE_CLASS_BOILERPLATE(LaunchConfiguration);
5767 std::tuple<std::list<StarOrExpr>, std::list<StarOrExpr>,
5768 std::optional<ScalarIntExpr>>
5769 t;
5770 };
5771 struct Directive {
5772 TUPLE_CLASS_BOILERPLATE(Directive);
5773 CharBlock source;
5774 std::tuple<std::optional<ScalarIntConstantExpr>,
5775 std::optional<LaunchConfiguration>, std::list<CUFReduction>>
5776 t;
5777 };
5778 std::tuple<Directive, std::optional<DoConstruct>> t;
5779};
5780
5781} // namespace Fortran::parser
5782#endif // FORTRAN_PARSER_PARSE_TREE_H_
Definition enum-set.h:28
Definition indirection.h:127
Definition indirection.h:31
Definition reference.h:18
Definition call.h:233
Definition char-block.h:28
Definition parse-state.h:35
Definition symbol.h:809
Definition FIRType.h:92
Definition call.h:34
Definition check-expression.h:19
Definition expression.h:896
Definition format-specification.h:135
Definition parse-tree.h:1275
Definition parse-tree.h:1282
Definition parse-tree.h:1246
Definition parse-tree.h:1235
Definition parse-tree.h:1234
Definition parse-tree.h:5661
Definition parse-tree.h:5637
Definition parse-tree.h:5653
Definition parse-tree.h:5645
Definition parse-tree.h:5622
Definition parse-tree.h:5686
Definition parse-tree.h:5616
Definition parse-tree.h:5492
Definition parse-tree.h:5465
Definition parse-tree.h:5593
Definition parse-tree.h:5578
Definition parse-tree.h:5573
Definition parse-tree.h:5481
Definition parse-tree.h:5503
Definition parse-tree.h:5486
Definition parse-tree.h:5498
Definition parse-tree.h:5530
Definition parse-tree.h:5524
Definition parse-tree.h:5628
Definition parse-tree.h:5692
Definition parse-tree.h:5569
Definition parse-tree.h:5560
Definition parse-tree.h:5470
Definition parse-tree.h:5509
Definition parse-tree.h:5457
Definition parse-tree.h:5553
Definition parse-tree.h:5549
Definition parse-tree.h:5545
Definition parse-tree.h:5475
Definition parse-tree.h:5541
Definition parse-tree.h:5535
Definition parse-tree.h:5519
Definition parse-tree.h:895
Definition parse-tree.h:1404
Definition parse-tree.h:496
Definition parse-tree.h:3222
Definition parse-tree.h:3212
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:3438
Definition parse-tree.h:1884
Definition parse-tree.h:1330
Definition parse-tree.h:3443
Definition parse-tree.h:3448
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:3388
Definition parse-tree.h:1113
Definition parse-tree.h:1426
Definition parse-tree.h:1433
Definition parse-tree.h:2168
Definition parse-tree.h:3000
Definition parse-tree.h:2001
Definition parse-tree.h:3382
Definition parse-tree.h:5762
Definition parse-tree.h:5756
Definition parse-tree.h:3249
Definition parse-tree.h:3246
Definition parse-tree.h:3229
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:2668
Definition parse-tree.h:2667
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:3355
Definition parse-tree.h:3331
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:2645
Definition parse-tree.h:2643
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:3130
Definition parse-tree.h:2331
Definition parse-tree.h:2193
Definition parse-tree.h:1380
Definition parse-tree.h:3300
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:2679
Definition parse-tree.h:3234
Definition parse-tree.h:3119
Definition parse-tree.h:3266
Definition parse-tree.h:3013
Definition parse-tree.h:3028
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:2775
Definition parse-tree.h:2719
Definition parse-tree.h:2862
Definition parse-tree.h:2870
Definition parse-tree.h:2875
Definition parse-tree.h:2860
Definition parse-tree.h:2890
Definition parse-tree.h:2888
Definition parse-tree.h:790
Definition parse-tree.h:311
Definition parse-tree.h:1338
Definition parse-tree.h:1542
Definition parse-tree.h:3186
Definition parse-tree.h:3153
Definition parse-tree.h:3159
Definition parse-tree.h:3151
Definition parse-tree.h:3176
Definition parse-tree.h:475
Definition parse-tree.h:463
Definition parse-tree.h:706
Definition parse-tree.h:704
Definition parse-tree.h:2703
Definition parse-tree.h:2701
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:2909
Definition parse-tree.h:3404
Definition parse-tree.h:2048
Definition parse-tree.h:2933
Definition parse-tree.h:2923
Definition parse-tree.h:2944
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:4269
Definition parse-tree.h:4273
Definition parse-tree.h:4288
Definition parse-tree.h:4295
Definition parse-tree.h:4303
Definition parse-tree.h:4318
Definition parse-tree.h:5260
Definition parse-tree.h:4325
Definition parse-tree.h:4334
Definition parse-tree.h:5054
Definition parse-tree.h:5397
Definition parse-tree.h:5125
Definition parse-tree.h:4357
Definition parse-tree.h:5064
Definition parse-tree.h:5023
Definition parse-tree.h:5007
Definition parse-tree.h:4372
Definition parse-tree.h:3573
Definition parse-tree.h:4380
Definition parse-tree.h:4397
Definition parse-tree.h:4415
Definition parse-tree.h:4474
Definition parse-tree.h:4472
Definition parse-tree.h:4496
Definition parse-tree.h:4504
Definition parse-tree.h:4514
Definition parse-tree.h:4524
Definition parse-tree.h:4532
Definition parse-tree.h:3474
Definition parse-tree.h:5030
Definition parse-tree.h:4487
Definition parse-tree.h:4454
Definition parse-tree.h:4547
Definition parse-tree.h:5059
Definition parse-tree.h:5401
Definition parse-tree.h:5130
Definition parse-tree.h:4558
Definition parse-tree.h:5092
Definition parse-tree.h:4566
Definition parse-tree.h:4579
Definition parse-tree.h:4590
Definition parse-tree.h:4600
Definition parse-tree.h:4608
Definition parse-tree.h:4613
Definition parse-tree.h:4621
Definition parse-tree.h:4637
Definition parse-tree.h:4660
Definition parse-tree.h:4626
Definition parse-tree.h:4650
Definition parse-tree.h:4667
Definition parse-tree.h:3585
Definition parse-tree.h:4427
Definition parse-tree.h:4445
Definition parse-tree.h:4436
Definition parse-tree.h:4676
Definition parse-tree.h:4691
Definition parse-tree.h:4702
Definition parse-tree.h:4727
Definition parse-tree.h:4739
Definition parse-tree.h:4748
Definition parse-tree.h:5077
Definition parse-tree.h:5086
Definition parse-tree.h:4772
Definition parse-tree.h:4784
Definition parse-tree.h:4796
Definition parse-tree.h:3519
Definition parse-tree.h:3510
Definition parse-tree.h:3507
Definition parse-tree.h:4807
Definition parse-tree.h:4820
Definition parse-tree.h:4832
Definition parse-tree.h:4843
Definition parse-tree.h:3563
Definition parse-tree.h:4853
Definition parse-tree.h:4862
Definition parse-tree.h:4874
Definition parse-tree.h:4885
Definition parse-tree.h:4892
Definition parse-tree.h:3523
Definition parse-tree.h:3545
Definition parse-tree.h:3532
Definition parse-tree.h:4901
Definition parse-tree.h:4912
Definition parse-tree.h:4921
Definition parse-tree.h:4936
Definition parse-tree.h:4946
Definition parse-tree.h:3499
Definition parse-tree.h:3492
Definition parse-tree.h:4955
Definition parse-tree.h:4980
Definition parse-tree.h:5002
Definition parse-tree.h:4991
Definition parse-tree.h:3044
Definition parse-tree.h:5668
Definition parse-tree.h:5675
Definition parse-tree.h:5604
Definition parse-tree.h:5697
Definition parse-tree.h:5736
Definition parse-tree.h:5725
Definition parse-tree.h:5716
Definition parse-tree.h:5598
Definition parse-tree.h:5610
Definition parse-tree.h:5286
Definition parse-tree.h:5119
Definition parse-tree.h:5291
Definition parse-tree.h:5328
Definition parse-tree.h:5432
Definition parse-tree.h:5276
Definition parse-tree.h:5107
Definition parse-tree.h:5339
Definition parse-tree.h:5353
Definition parse-tree.h:5427
Definition parse-tree.h:5369
Definition parse-tree.h:5215
Definition parse-tree.h:5377
Definition parse-tree.h:5450
Definition parse-tree.h:5406
Definition parse-tree.h:5221
Definition parse-tree.h:5139
Definition parse-tree.h:5145
Definition parse-tree.h:5388
Definition parse-tree.h:5227
Definition parse-tree.h:5096
Definition parse-tree.h:376
Definition parse-tree.h:2780
Definition parse-tree.h:2743
Definition parse-tree.h:2969
Definition parse-tree.h:1788
Definition parse-tree.h:2013
Definition parse-tree.h:1552
Definition parse-tree.h:1974
Definition parse-tree.h:2806
Definition parse-tree.h:3089
Definition parse-tree.h:2764
Definition parse-tree.h:925
Definition parse-tree.h:3067
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:3077
Definition parse-tree.h:3201
Definition parse-tree.h:3169
Definition parse-tree.h:571
Definition parse-tree.h:2727
Definition parse-tree.h:809
Definition parse-tree.h:2245
Definition parse-tree.h:2957
Definition parse-tree.h:2961
Definition parse-tree.h:2955
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:3292
Definition parse-tree.h:398
Definition parse-tree.h:451
Definition parse-tree.h:1943
Definition parse-tree.h:359
Definition parse-tree.h:3310
Definition parse-tree.h:2510
Definition parse-tree.h:1863
Definition parse-tree.h:1203
Definition parse-tree.h:3425
Definition parse-tree.h:3397
Definition parse-tree.h:3420
Definition parse-tree.h:2975
Definition parse-tree.h:2986
Definition parse-tree.h:3138
Definition parse-tree.h:3276
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:3413
Definition parse-tree.h:354
Definition parse-tree.h:2600
Definition parse-tree.h:796
Definition parse-tree.h:3053
Definition parse-tree.h:1841
Definition parse-tree.h:726
Definition parse-tree.h:731
Definition parse-tree.h:282
Definition parse-tree.h:2790
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:2749
Definition parse-tree.h:3638
Definition parse-tree.h:3597
Definition parse-tree.h:3592
Definition parse-tree.h:3802
Definition parse-tree.h:3811
Definition parse-tree.h:3956
Definition parse-tree.h:3988
Definition parse-tree.h:4010
Definition parse-tree.h:4032
Definition parse-tree.h:4058
Definition parse-tree.h:4079
Definition parse-tree.h:4066
Definition parse-tree.h:4150
Definition parse-tree.h:4191
Definition parse-tree.h:4201
Definition parse-tree.h:3685
Definition parse-tree.h:3668
Definition parse-tree.h:3709
Definition parse-tree.h:3675
Definition parse-tree.h:3736
Definition parse-tree.h:3748
Definition parse-tree.h:3761
Definition parse-tree.h:3770