[RISCV][FMV] Support target_clones (#85786)
[llvm-project.git] / clang / test / SemaOpenACC / compute-construct-ast.cpp
blob7a33aeb80570c7b7a1cd44cfaf59d94b7b512da4
1 // RUN: %clang_cc1 %s -fopenacc -ast-dump | FileCheck %s
3 // Test this with PCH.
4 // RUN: %clang_cc1 %s -fopenacc -emit-pch -o %t %s
5 // RUN: %clang_cc1 %s -fopenacc -include-pch %t -ast-dump-all | FileCheck %s
7 #ifndef PCH_HELPER
8 #define PCH_HELPER
10 void NormalFunc() {
11 // FIXME: Add a test once we have clauses for this.
12 // CHECK-LABEL: NormalFunc
13 // CHECK-NEXT: CompoundStmt
14 // CHECK-NEXT: OpenACCComputeConstruct {{.*}}parallel
15 // CHECK-NEXT: default(none)
16 // CHECK-NEXT: CompoundStmt
17 #pragma acc parallel default(none)
19 #pragma acc parallel
20 // CHECK-NEXT: OpenACCComputeConstruct {{.*}}parallel
21 // CHECK-NEXT: OpenACCComputeConstruct {{.*}}parallel
22 // CHECK-NEXT: default(present)
23 // CHECK-NEXT: CompoundStmt
24 #pragma acc parallel default(present)
27 // FIXME: Add a test once we have clauses for this.
28 // CHECK-NEXT: OpenACCComputeConstruct {{.*}}serial
29 // CHECK-NEXT: CompoundStmt
30 #pragma acc serial
32 #pragma acc serial
33 // CHECK-NEXT: OpenACCComputeConstruct {{.*}}serial
34 // CHECK-NEXT: OpenACCComputeConstruct {{.*}}serial
35 // CHECK-NEXT: CompoundStmt
36 #pragma acc serial
39 // FIXME: Add a test once we have clauses for this.
40 // CHECK-NEXT: OpenACCComputeConstruct {{.*}}kernels
41 // CHECK-NEXT: CompoundStmt
42 #pragma acc kernels
44 #pragma acc kernels
45 // CHECK-NEXT: OpenACCComputeConstruct {{.*}}kernels
46 // CHECK-NEXT: OpenACCComputeConstruct {{.*}}kernels
47 // CHECK-NEXT: CompoundStmt
48 #pragma acc kernels
53 template<typename T>
54 void TemplFunc() {
55 #pragma acc parallel default(none)
57 typename T::type I;
60 #pragma acc serial default(present)
62 typename T::type I;
65 #pragma acc kernels
67 typename T::type I;
70 // CHECK-LABEL: FunctionTemplateDecl {{.*}}TemplFunc
71 // CHECK-NEXT: TemplateTypeParmDecl
73 // Template Pattern:
74 // CHECK-NEXT: FunctionDecl
75 // CHECK-NEXT: CompoundStmt
76 // CHECK-NEXT: OpenACCComputeConstruct {{.*}}parallel
77 // CHECK-NEXT: default(none)
78 // CHECK-NEXT: CompoundStmt
79 // CHECK-NEXT: DeclStmt
80 // CHECK-NEXT: VarDecl{{.*}} I 'typename T::type'
81 // CHECK-NEXT: OpenACCComputeConstruct {{.*}}serial
82 // CHECK-NEXT: default(present)
83 // CHECK-NEXT: CompoundStmt
84 // CHECK-NEXT: DeclStmt
85 // CHECK-NEXT: VarDecl{{.*}} I 'typename T::type'
86 // CHECK-NEXT: OpenACCComputeConstruct {{.*}}kernels
87 // CHECK-NEXT: CompoundStmt
88 // CHECK-NEXT: DeclStmt
89 // CHECK-NEXT: VarDecl{{.*}} I 'typename T::type'
91 // Check instantiation.
92 // CHECK-LABEL: FunctionDecl{{.*}} used TemplFunc 'void ()' implicit_instantiation
93 // CHECK-NEXT: TemplateArgument type 'S'
94 // CHECK-NEXT: RecordType
95 // CHECK-NEXT: CXXRecord
96 // CHECK-NEXT: CompoundStmt
97 // CHECK-NEXT: OpenACCComputeConstruct {{.*}}parallel
98 // CHECK-NEXT: default(none)
99 // CHECK-NEXT: CompoundStmt
100 // CHECK-NEXT: DeclStmt
101 // CHECK-NEXT: VarDecl{{.*}} I 'typename S::type':'int'
102 // CHECK-NEXT: OpenACCComputeConstruct {{.*}}serial
103 // CHECK-NEXT: default(present)
104 // CHECK-NEXT: CompoundStmt
105 // CHECK-NEXT: DeclStmt
106 // CHECK-NEXT: VarDecl{{.*}} I 'typename S::type':'int'
107 // CHECK-NEXT: OpenACCComputeConstruct {{.*}}kernels
108 // CHECK-NEXT: CompoundStmt
109 // CHECK-NEXT: DeclStmt
110 // CHECK-NEXT: VarDecl{{.*}} I 'typename S::type':'int'
113 struct S {
114 using type = int;
117 void use() {
118 TemplFunc<S>();
121 struct HasCtor { HasCtor(); operator int(); ~HasCtor();};
123 void useCtorType() {
124 // CHECK-LABEL: useCtorType
125 // CHECK-NEXT: CompoundStmt
127 #pragma acc kernels num_workers(HasCtor{})
128 // CHECK-NEXT: OpenACCComputeConstruct{{.*}} kernels
129 // CHECK-NEXT: num_workers clause
130 // CHECK-NEXT: ImplicitCastExpr{{.*}}'int' <UserDefinedConversion>
131 // CHECK-NEXT: CXXMemberCallExpr{{.*}}'int'
132 // CHECK-NEXT: MemberExpr{{.*}}.operator int
133 // CHECK-NEXT: MaterializeTemporaryExpr{{.*}}'HasCtor'
134 // CHECK-NEXT: CXXBindTemporaryExpr{{.*}}'HasCtor'
135 // CHECK-NEXT: CXXTemporaryObjectExpr{{.*}}'HasCtor'
137 while(true);
138 // CHECK-NEXT: WhileStmt
139 // CHECK-NEXT: CXXBoolLiteralExpr
140 // CHECK-NEXT: NullStmt
142 #endif