1 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
2 //RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
3 //RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
4 //RUN: -fsyntax-only -verify -o - %s
6 //RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fopenmp \
7 //RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
8 //RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
9 //RUN: -fsyntax-only -verify -o - %s
11 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
12 //RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
13 //RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
14 //RUN: -emit-pch -o %t %s
16 // expected-no-diagnostics
18 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
19 //RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
20 //RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
21 //RUN: -ast-print %s | FileCheck %s --check-prefix=PRINT
23 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
24 //RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
25 //RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
26 //RUN: -ast-dump %s | FileCheck %s --check-prefix=DUMP
28 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
29 //RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
30 //RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
31 //RUN: -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT
33 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
34 //RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
35 //RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
36 //RUN: -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP
41 void foo_v1(float *AAA
, float *BBB
, int *I
) {return;}
42 void foo_v2(float *AAA
, float *BBB
, int *I
) {return;}
43 void foo_v3(float *AAA
, float *BBB
, int *I
) {return;}
45 //DUMP: FunctionDecl{{.*}} foo 'void (float *, float *, int *)'
46 //DUMP: OMPDeclareVariantAttr{{.*}}device={arch(x86, x86_64)}
47 //DUMP: DeclRefExpr{{.*}}Function{{.*}}foo_v3
48 //DUMP: DeclRefExpr{{.*}}ParmVar{{.*}}'I'
49 //DUMP: DeclRefExpr{{.*}}ParmVar{{.*}}'BBB'
50 //DUMP: OMPDeclareVariantAttr{{.*}}device={arch(ppc)}
51 //DUMP: DeclRefExpr{{.*}}Function{{.*}}foo_v2
52 //DUMP: DeclRefExpr{{.*}}ParmVar{{.*}}'AAA'
53 //DUMP: OMPDeclareVariantAttr{{.*}}device={arch(arm)}
54 //DUMP: DeclRefExpr{{.*}}Function{{.*}}foo_v1
55 //DUMP: DeclRefExpr{{.*}}ParmVar{{.*}}'AAA'
56 //DUMP: DeclRefExpr{{.*}}ParmVar{{.*}}'BBB'
57 //PRINT: #pragma omp declare variant(foo_v3) match(construct={dispatch}, device={arch(x86, x86_64)}) adjust_args(nothing:I) adjust_args(need_device_ptr:BBB)
59 //PRINT: #pragma omp declare variant(foo_v2) match(construct={dispatch}, device={arch(ppc)}) adjust_args(need_device_ptr:AAA)
61 //PRINT: omp declare variant(foo_v1) match(construct={dispatch}, device={arch(arm)}) adjust_args(need_device_ptr:AAA,BBB)
63 #pragma omp declare variant(foo_v1) \
64 match(construct={dispatch}, device={arch(arm)}) \
65 adjust_args(need_device_ptr:AAA,BBB)
67 #pragma omp declare variant(foo_v2) \
68 match(construct={dispatch}, device={arch(ppc)}), \
69 adjust_args(need_device_ptr:AAA)
71 #pragma omp declare variant(foo_v3) \
72 adjust_args(need_device_ptr:BBB) adjust_args(nothing:I) \
73 match(construct={dispatch}, device={arch(x86,x86_64)})
75 void foo(float *AAA
, float *BBB
, int *I
) {return;}
77 void Foo_Var(float *AAA
, float *BBB
) {return;}
79 #pragma omp declare variant(Foo_Var) \
80 match(construct={dispatch}, device={arch(x86_64)}) \
81 adjust_args(need_device_ptr:AAA) adjust_args(nothing:BBB)
83 void Foo(T
*AAA
, T
*BBB
) {return;}
85 //PRINT: #pragma omp declare variant(Foo_Var) match(construct={dispatch}, device={arch(x86_64)}) adjust_args(nothing:BBB) adjust_args(need_device_ptr:AAA)
86 //DUMP: FunctionDecl{{.*}} Foo 'void (T *, T *)'
87 //DUMP: OMPDeclareVariantAttr{{.*}}device={arch(x86_64)}
88 //DUMP: DeclRefExpr{{.*}}Function{{.*}}Foo_Var
89 //DUMP: DeclRefExpr{{.*}}ParmVar{{.*}}'BBB'
90 //DUMP: DeclRefExpr{{.*}}ParmVar{{.*}}'AAA'
92 //DUMP: FunctionDecl{{.*}} Foo 'void (float *, float *)'
93 //DUMP: OMPDeclareVariantAttr{{.*}}device={arch(x86_64)}
94 //DUMP: DeclRefExpr{{.*}}Function{{.*}}Foo_Var
95 //DUMP: DeclRefExpr{{.*}}ParmVar{{.*}}'BBB'
96 //DUMP: DeclRefExpr{{.*}}ParmVar{{.*}}'AAA'
103 //#pragma omp dispatch
107 typedef void *omp_interop_t
;
109 void bar_v1(float* F1
, float *F2
, omp_interop_t
);
110 void bar_v2(float* F1
, float *F2
, omp_interop_t
, omp_interop_t
);
112 //PRINT: #pragma omp declare variant(bar_v1) match(construct={dispatch}) append_args(interop(target,targetsync))
113 //DUMP: FunctionDecl{{.*}}bar1 'void (float *, float *)'
114 //DUMP: OMPDeclareVariantAttr{{.*}}construct={dispatch} Target_TargetSync
115 //DUMP: DeclRefExpr{{.*}}bar_v1
116 #pragma omp declare variant(bar_v1) match(construct={dispatch}) \
117 append_args(interop(target,targetsync))
118 void bar1(float *FF1
, float *FF2
) { return; }
120 //PRINT: #pragma omp declare variant(bar_v1) match(construct={dispatch}) append_args(interop(targetsync))
121 //DUMP: FunctionDecl{{.*}}bar2 'void (float *, float *)'
122 //DUMP: OMPDeclareVariantAttr{{.*}}construct={dispatch} TargetSync
123 //DUMP: DeclRefExpr{{.*}}bar_v1
124 #pragma omp declare variant(bar_v1) match(construct={dispatch}) \
125 append_args(interop(targetsync))
126 void bar2(float *FF1
, float *FF2
) { return; }
128 //PRINT: #pragma omp declare variant(bar_v1) match(construct={dispatch}) append_args(interop(target))
129 //DUMP: FunctionDecl{{.*}}bar3 'void (float *, float *)'
130 //DUMP: OMPDeclareVariantAttr{{.*}}construct={dispatch} Target
131 //DUMP: DeclRefExpr{{.*}}bar_v1
132 #pragma omp declare variant(bar_v1) match(construct={dispatch}) \
133 append_args(interop(target))
134 void bar3(float *FF1
, float *FF2
) { return; }
136 //PRINT: #pragma omp declare variant(bar_v2) match(construct={dispatch}) append_args(interop(target), interop(targetsync))
137 //DUMP: FunctionDecl{{.*}}bar4 'void (float *, float *)'
138 //DUMP: OMPDeclareVariantAttr{{.*}}construct={dispatch} Target TargetSync
139 //DUMP: DeclRefExpr{{.*}}bar_v2
140 #pragma omp declare variant(bar_v2) match(construct={dispatch}) \
141 append_args(interop(target), interop(targetsync))
142 void bar4(float *FF1
, float *FF2
) { return; }
144 //PRINT: #pragma omp declare variant(bar_v2) match(construct={dispatch}) append_args(interop(targetsync), interop(target))
145 //DUMP: FunctionDecl{{.*}}bar5 'void (float *, float *)'
146 //DUMP: OMPDeclareVariantAttr{{.*}}construct={dispatch} TargetSync Target
147 //DUMP: DeclRefExpr{{.*}}bar_v2
148 #pragma omp declare variant(bar_v2) match(construct={dispatch}) \
149 append_args(interop(targetsync), interop(target))
150 void bar5(float *FF1
, float *FF2
) { return; }
153 //DUMP: CXXRecordDecl{{.*}}class A definition
156 void memberfoo_v1(float *A
, float *B
, int *I
, omp_interop_t IOp
);
157 //PRINT: #pragma omp declare variant(memberfoo_v1) match(construct={dispatch}) append_args(interop(target))
158 //DUMP: CXXMethodDecl{{.*}}memberbar 'void (float *, float *, int *)'
159 //DUMP: OMPDeclareVariantAttr{{.*}}Implicit construct={dispatch} Target
160 //DUMP: DeclRefExpr{{.*}}'memberfoo_v1' 'void (float *, float *, int *, omp_interop_t)'
161 #pragma omp declare variant(memberfoo_v1) match(construct={dispatch}) \
162 append_args(interop(target))
163 void memberbar(float *A
, float *B
, int *I
) { return; }
165 static void smemberfoo_v1(float *A
, float *B
, int *I
, omp_interop_t IOp
);
166 //PRINT: #pragma omp declare variant(smemberfoo_v1) match(construct={dispatch}) append_args(interop(target))
167 //DUMP: CXXMethodDecl{{.*}}smemberbar 'void (float *, float *, int *)' static
168 //DUMP: OMPDeclareVariantAttr{{.*}}Implicit construct={dispatch} Target
169 //DUMP: DeclRefExpr{{.*}}'smemberfoo_v1' 'void (float *, float *, int *, omp_interop_t)'
170 #pragma omp declare variant(smemberfoo_v1) match(construct={dispatch}) \
171 append_args(interop(target))
172 static void smemberbar(float *A
, float *B
, int *I
) { return; }
175 template <typename T
> void templatefoo_v1(const T
& t
, omp_interop_t I
);
176 template <typename T
> void templatebar(const T
& t
) {}
178 //PRINT: #pragma omp declare variant(templatefoo_v1<int>) match(construct={dispatch}) append_args(interop(target))
179 //DUMP: FunctionDecl{{.*}}templatebar 'void (const int &)'
180 //DUMP: OMPDeclareVariantAttr{{.*}}Implicit construct={dispatch} Target
181 //DUMP: DeclRefExpr{{.*}}'templatefoo_v1' 'void (const int &, omp_interop_t)'
182 #pragma omp declare variant(templatefoo_v1<int>) match(construct={dispatch}) \
183 append_args(interop(target))
184 void templatebar(const int &t
) {}