22! RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=52 %s | FileCheck --check-prefix="PARSE-TREE" %s
33
44subroutine f00
5+ continue
56 ! $omp metadirective when(construct={target, parallel}: nothing)
67end
78
89! UNPARSE: SUBROUTINE f00
10+ ! UNPARSE: CONTINUE
911! UNPARSE: !$OMP METADIRECTIVE WHEN(CONSTRUCT={TARGET, PARALLEL}: NOTHING)
1012! UNPARSE: END SUBROUTINE
1113
@@ -22,10 +24,12 @@ subroutine f00
2224! PARSE-TREE: | | | OmpClauseList ->
2325
2426subroutine f01
27+ continue
2528 ! $omp metadirective when(target_device={kind(host), device_num(1)}: nothing)
2629end
2730
2831! UNPARSE: SUBROUTINE f01
32+ ! UNPARSE: CONTINUE
2933! UNPARSE: !$OMP METADIRECTIVE WHEN(TARGET_DEVICE={KIND(host), DEVICE_NUM(1_4)}: NOTHING)
3034! UNPARSE: END SUBROUTINE
3135
@@ -47,10 +51,12 @@ subroutine f01
4751! PARSE-TREE: | | | OmpClauseList ->
4852
4953subroutine f02
54+ continue
5055 ! $omp metadirective when(target_device={kind(any), device_num(7)}: nothing)
5156end
5257
5358! UNPARSE: SUBROUTINE f02
59+ ! UNPARSE: CONTINUE
5460! UNPARSE: !$OMP METADIRECTIVE WHEN(TARGET_DEVICE={KIND(any), DEVICE_NUM(7_4)}: NOTHING)
5561! UNPARSE: END SUBROUTINE
5662
@@ -72,11 +78,13 @@ subroutine f02
7278! PARSE-TREE: | | | OmpClauseList ->
7379
7480subroutine f03
81+ continue
7582 ! $omp metadirective &
7683 ! $omp & when(implementation={atomic_default_mem_order(acq_rel)}: nothing)
7784end
7885
7986! UNPARSE: SUBROUTINE f03
87+ ! UNPARSE: CONTINUE
8088! UNPARSE: !$OMP METADIRECTIVE WHEN(IMPLEMENTATION={ATOMIC_DEFAULT_MEM_ORDER(ACQ_REL)}: &
8189! UNPARSE: !$OMP&NOTHING)
8290! UNPARSE: END SUBROUTINE
@@ -94,11 +102,13 @@ subroutine f03
94102! PARSE-TREE: | | | OmpClauseList ->
95103
96104subroutine f04
105+ continue
97106 ! $omp metadirective &
98107 ! $omp when(implementation={extension_trait(haha(1), foo(baz, "bar"(1)))}: nothing)
99108end
100109
101110! UNPARSE: SUBROUTINE f04
111+ ! UNPARSE: CONTINUE
102112! UNPARSE: !$OMP METADIRECTIVE WHEN(IMPLEMENTATION={extension_trait(haha(1_4), foo(baz,bar(1_4&
103113! UNPARSE: !$OMP&)))}: NOTHING)
104114! UNPARSE: END SUBROUTINE
@@ -127,6 +137,7 @@ subroutine f04
127137
128138subroutine f05 (x )
129139 integer :: x
140+ continue
130141 ! $omp metadirective &
131142 ! $omp & when(user={condition(score(100): .true.)}: &
132143 ! $omp & parallel do reduction(+: x)) &
@@ -137,6 +148,7 @@ subroutine f05(x)
137148
138149! UNPARSE: SUBROUTINE f05 (x)
139150! UNPARSE: INTEGER x
151+ ! UNPARSE: CONTINUE
140152! UNPARSE: !$OMP METADIRECTIVE WHEN(USER={CONDITION(SCORE(100_4): .true._4)}: PARALLEL DO REDUCTION(+&
141153! UNPARSE: !$OMP&: x)) OTHERWISE(NOTHING)
142154! UNPARSE: DO i=1_4,10_4
@@ -165,13 +177,15 @@ subroutine f05(x)
165177! PARSE-TREE: | | OmpClauseList ->
166178
167179subroutine f06
180+ continue
168181 ! Two trait set selectors
169182 ! $omp metadirective &
170183 ! $omp & when(implementation={vendor("amd")}, &
171184 ! $omp & user={condition(.true.)}: nothing)
172185end
173186
174187! UNPARSE: SUBROUTINE f06
188+ ! UNPARSE: CONTINUE
175189! UNPARSE: !$OMP METADIRECTIVE WHEN(IMPLEMENTATION={VENDOR(amd)}, USER={CONDITION(.true._4)}: NO&
176190! UNPARSE: !$OMP&THING)
177191! UNPARSE: END SUBROUTINE
@@ -196,3 +210,42 @@ subroutine f06
196210! PARSE-TREE: | | | llvm::omp::Directive = nothing
197211! PARSE-TREE: | | | OmpClauseList ->
198212
213+ subroutine f07
214+ ! Declarative metadirective
215+ ! $omp metadirective &
216+ ! $omp & when(implementation={vendor("amd")}: declare simd) &
217+ ! $omp & when(user={condition(.true.)}: declare target) &
218+ ! $omp & otherwise(nothing)
219+ end
220+
221+ ! UNPARSE: SUBROUTINE f07
222+ ! UNPARSE: !$OMP METADIRECTIVE WHEN(IMPLEMENTATION={VENDOR(amd)}: DECLARE SIMD) WHEN(USE&
223+ ! UNPARSE: !$OMP&R={CONDITION(.true._4)}: DECLARE TARGET) OTHERWISE(NOTHING)
224+ ! UNPARSE: END SUBROUTINE
225+
226+ ! PARSE-TREE: OpenMPDeclarativeConstruct -> OmpMetadirectiveDirective
227+ ! PARSE-TREE: | OmpClauseList -> OmpClause -> When -> OmpWhenClause
228+ ! PARSE-TREE: | | Modifier -> OmpContextSelectorSpecification -> OmpTraitSetSelector
229+ ! PARSE-TREE: | | | OmpTraitSetSelectorName -> Value = Implementation
230+ ! PARSE-TREE: | | | OmpTraitSelector
231+ ! PARSE-TREE: | | | | OmpTraitSelectorName -> Value = Vendor
232+ ! PARSE-TREE: | | | | Properties
233+ ! PARSE-TREE: | | | | | OmpTraitProperty -> OmpTraitPropertyName -> string = 'amd'
234+ ! PARSE-TREE: | | OmpDirectiveSpecification
235+ ! PARSE-TREE: | | | llvm::omp::Directive = declare simd
236+ ! PARSE-TREE: | | | OmpClauseList ->
237+ ! PARSE-TREE: | OmpClause -> When -> OmpWhenClause
238+ ! PARSE-TREE: | | Modifier -> OmpContextSelectorSpecification -> OmpTraitSetSelector
239+ ! PARSE-TREE: | | | OmpTraitSetSelectorName -> Value = User
240+ ! PARSE-TREE: | | | OmpTraitSelector
241+ ! PARSE-TREE: | | | | OmpTraitSelectorName -> Value = Condition
242+ ! PARSE-TREE: | | | | Properties
243+ ! PARSE-TREE: | | | | | OmpTraitProperty -> Scalar -> Expr = '.true._4'
244+ ! PARSE-TREE: | | | | | | LiteralConstant -> LogicalLiteralConstant
245+ ! PARSE-TREE: | | | | | | | bool = 'true'
246+ ! PARSE-TREE: | | OmpDirectiveSpecification
247+ ! PARSE-TREE: | | | llvm::omp::Directive = declare target
248+ ! PARSE-TREE: | | | OmpClauseList ->
249+ ! PARSE-TREE: | OmpClause -> Otherwise -> OmpOtherwiseClause -> OmpDirectiveSpecification
250+ ! PARSE-TREE: | | llvm::omp::Directive = nothing
251+ ! PARSE-TREE: | | OmpClauseList ->
0 commit comments