1 // RUN: %clang_cc1 -triple=x86_64-pc-win32 -fopenmp \
2 // RUN: -fsyntax-only -verify %s
4 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
5 // RUN: -fsyntax-only -verify %s
7 // expected-no-diagnostics
9 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
10 // RUN: -ast-print %s | FileCheck %s --check-prefix=PRINT
12 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
13 // RUN: -ast-dump %s | FileCheck %s --check-prefix=DUMP
15 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
16 // RUN: -emit-pch -o %t %s
18 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
19 // RUN: -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP
21 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
22 // RUN: -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT
27 int foo_gpu(int A
, int *B
) { return 0;}
28 //PRINT: #pragma omp declare variant(foo_gpu)
29 //DUMP: FunctionDecl{{.*}} foo
30 //DUMP: OMPDeclareVariantAttr {{.*}}Implicit construct{{.*}}
31 #pragma omp declare variant(foo_gpu) \
32 match(construct={dispatch}, device={arch(arm)})
35 template <typename T
, typename TP
>
39 //PRINT: #pragma omp dispatch nowait
40 //DUMP: OMPDispatchDirective
41 //DUMP: OMPNowaitClause
42 #pragma omp dispatch nowait
46 int *get_device_ptr();
50 //DUMP: FunctionDecl{{.*}} test_one
54 //PRINT: #pragma omp dispatch depend(in : var) nowait novariants(aaa > 5) nocontext(bbb > 5)
55 //DUMP: OMPDispatchDirective
56 //DUMP: OMPDependClause
57 //DUMP: OMPNowaitClause
58 //DUMP: OMPNovariantsClause
59 //DUMP: DeclRefExpr {{.*}} 'bool' lvalue OMPCapturedExpr
60 //DUMP: OMPNocontextClause
61 //DUMP: DeclRefExpr {{.*}} 'bool' lvalue OMPCapturedExpr
62 #pragma omp dispatch depend(in:var) nowait novariants(aaa > 5) nocontext(bbb > 5)
65 int *dp
= get_device_ptr();
66 int dev
= get_device();
67 //PRINT: #pragma omp dispatch device(dev) is_device_ptr(dp) novariants(dev > 10) nocontext(dev > 5)
68 //DUMP: OMPDispatchDirective
69 //DUMP: OMPDeviceClause
70 //DUMP: OMPIs_device_ptrClause
71 //DUMP: OMPNovariantsClause
72 //DUMP: DeclRefExpr {{.*}} 'bool' lvalue OMPCapturedExpr
73 //DUMP: OMPNocontextClause
74 //DUMP: DeclRefExpr {{.*}} 'bool' lvalue OMPCapturedExpr
75 #pragma omp dispatch device(dev) is_device_ptr(dp) novariants(dev > 10) nocontext(dev > 5)
78 //PRINT: #pragma omp dispatch
79 //PRINT: foo(other(), &bbb);
80 //DUMP: OMPDispatchDirective
90 int disp_method_variant1();
91 #pragma omp declare variant(disp_method_variant1) \
92 match(construct={dispatch}, device={arch(arm)})
95 static int disp_method_variant2() { return 1; }
96 #pragma omp declare variant(disp_method_variant2) \
97 match(construct={dispatch}, device={arch(arm)})
98 static int disp_method2() { return 2; }
102 #pragma omp declare variant(foo_vari) \
103 match(construct={dispatch}, device={arch(arm)})
106 //DUMP: FunctionDecl{{.*}} test_two
107 void test_two(Obj o1
, Obj
&o2
, Obj
*o3
)
109 //PRINT: #pragma omp dispatch
110 //PRINT: o1.disp_method1();
111 //DUMP: OMPDispatchDirective
115 //PRINT: #pragma omp dispatch
116 //PRINT: o2.disp_method1();
117 //DUMP: OMPDispatchDirective
121 //PRINT: #pragma omp dispatch
122 //PRINT: o3->disp_method1();
123 //DUMP: OMPDispatchDirective
127 //PRINT: #pragma omp dispatch
128 //PRINT: Obj::disp_method2();
129 //DUMP: OMPDispatchDirective
134 //PRINT: #pragma omp dispatch
135 //PRINT: ret = o1.disp_method1();
136 //DUMP: OMPDispatchDirective
138 ret
= o1
.disp_method1();
140 //PRINT: #pragma omp dispatch
141 //PRINT: ret = o2.disp_method1();
142 //DUMP: OMPDispatchDirective
144 ret
= o2
.disp_method1();
146 //PRINT: #pragma omp dispatch
147 //PRINT: ret = o3->disp_method1();
148 //DUMP: OMPDispatchDirective
150 ret
= o3
->disp_method1();
152 //PRINT: #pragma omp dispatch
153 //PRINT: ret = Obj::disp_method2();
154 //DUMP: OMPDispatchDirective
156 ret
= Obj::disp_method2();
158 //PRINT: #pragma omp dispatch
159 //PRINT: (void)Obj::disp_method2();
160 //DUMP: OMPDispatchDirective
162 (void)Obj::disp_method2();
164 // Full C++ operator= case with temps and EH.
166 //PRINT: #pragma omp dispatch
167 //PRINT: o = foo_obj();
168 //DUMP: OMPDispatchDirective
174 A
& disp_operator(A other
);
175 #pragma omp declare variant(disp_operator) \
176 match(construct={dispatch}, device={arch(arm)})
177 A
& operator=(A other
);
182 Obj2
& disp_operator(Obj2 other
);
183 #pragma omp declare variant(disp_operator) \
184 match(construct={dispatch}, device={arch(arm)})
185 Obj2
& operator=(Obj2 other
);
189 //PRINT: #pragma omp dispatch
191 //DUMP: OMPDispatchDirective
194 //PRINT: #pragma omp dispatch
195 //PRINT: z.operator=(z);
196 //DUMP: OMPDispatchDirective
202 //PRINT: #pragma omp dispatch
203 //PRINT: j = {this->xx};
204 //DUMP: OMPDispatchDirective
207 //PRINT: #pragma omp dispatch
208 //PRINT: j.operator=({this->xx});
209 //DUMP: OMPDispatchDirective
211 j
.operator=({this->xx
});