| 1 |
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -fnoopenmp-use-tls -ferror-limit 100 -o - %s |
| 2 |
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp5,host5 -fopenmp -fopenmp-version=50 -fopenmp-targets=x86_64-apple-macos10.7.0 -fnoopenmp-use-tls -ferror-limit 100 -o - %s |
| 3 |
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp5,dev5 -fopenmp -fopenmp-version=50 -fopenmp-is-target-device -fopenmp-targets=x86_64-apple-macos10.7.0 -aux-triple x86_64-apple-macos10.7.0 -fnoopenmp-use-tls -ferror-limit 100 -o - %s |
| 4 |
|
| 5 |
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp5,host5 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=x86_64-apple-macos10.7.0 -fnoopenmp-use-tls -ferror-limit 100 -o - %s |
| 6 |
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp5,host5 -fopenmp-simd -fopenmp-version=50 -fopenmp-is-target-device -fopenmp-targets=x86_64-apple-macos10.7.0 -fnoopenmp-use-tls -ferror-limit 100 -o - %s |
| 7 |
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp45 -fopenmp-version=45 -fopenmp-simd -fnoopenmp-use-tls -ferror-limit 100 -o - %s |
| 8 |
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp51 -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -o - %s |
| 9 |
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp51 -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -DTESTEND=1 -o - %s |
| 10 |
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp51 -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -I%S/Inputs -DTESTENDINC=1 -o - %s |
| 11 |
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp51 -fopenmp-simd -fnoopenmp-use-tls -ferror-limit 100 -o - %s |
| 12 |
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp51 -fopenmp-simd -fnoopenmp-use-tls -ferror-limit 100 -o - %s |
| 13 |
|
| 14 |
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -DVERBOSE_MODE=1 -fnoopenmp-use-tls -ferror-limit 100 -o - %s |
| 15 |
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp5 -fopenmp -fopenmp-version=50 -fnoopenmp-use-tls -ferror-limit 100 -o - %s |
| 16 |
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp51 -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -o - %s |
| 17 |
#pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} |
| 18 |
|
| 19 |
int a, b, z; // omp5-error {{variable captured in declare target region must appear in a to clause}} // omp51-error {{variable captured in declare target region must appear in a to clause}} omp52-error {{variable captured in declare target region must appear in a to clause}} |
| 20 |
__thread int t; // expected-note {{defined as threadprivate or thread local}} |
| 21 |
|
| 22 |
#pragma omp declare target . // expected-error {{expected '(' after 'declare target'}} |
| 23 |
|
| 24 |
#pragma omp declare target |
| 25 |
void f(); |
| 26 |
#pragma omp end declare target shared(a) // expected-warning {{extra tokens at the end of '#pragma omp end declare target' are ignored}} |
| 27 |
|
| 28 |
#pragma omp declare target map(a) // omp45-error {{expected at least one 'to' or 'link' clause}} omp5-error {{expected at least one 'to' or 'link' clause}} omp51-error {{expected at least one 'to', 'link' or 'indirect' clause}} omp45-error {{unexpected 'map' clause, only 'to' or 'link' clauses expected}} omp5-error {{unexpected 'map' clause, only 'to', 'link' or 'device_type' clauses expected}} omp51-error {{unexpected 'map' clause, only 'to', 'link', 'device_type' or 'indirect' clauses expected}} omp52-error {{unexpected 'map' clause, only 'enter', 'link', 'device_type' or 'indirect' clauses expected}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} |
| 29 |
|
| 30 |
#pragma omp declare target to(foo1) // omp45-error {{use of undeclared identifier 'foo1'}} omp5-error {{use of undeclared identifier 'foo1'}} omp51-error {{use of undeclared identifier 'foo1'}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} |
| 31 |
|
| 32 |
#pragma omp declare target link(foo2) // expected-error {{use of undeclared identifier 'foo2'}} |
| 33 |
|
| 34 |
#pragma omp declare target to(f) device_type(host) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} dev5-note {{marked as 'device_type(host)' here}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} |
| 35 |
|
| 36 |
void q(); |
| 37 |
#pragma omp declare target to(q) device_type(any) device_type(any) device_type(host) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} omp5-warning {{more than one 'device_type' clause is specified}} // omp51-warning {{more than one 'device_type' clause is specified}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} |
| 38 |
|
| 39 |
#if _OPENMP == 202011 |
| 40 |
// omp51-error@+1 {{directive '#pragma omp declare target' cannot contain more than one 'indirect' clause}} |
| 41 |
#pragma omp declare target to(q) indirect(true) indirect(false) |
| 42 |
|
| 43 |
int xxx; //expected-note {{declared here}} |
| 44 |
// omp51-error@+2 {{expression is not an integral constant expression}} |
| 45 |
// omp51-note@+1 {{read of non-const variable 'xxx' is not allowed in a constant expression}} |
| 46 |
#pragma omp declare target to(q) indirect(xxx) |
| 47 |
|
| 48 |
constexpr bool fz() {return true;} |
| 49 |
// omp51-error@+1 {{unexpected 'to' clause, only 'device_type', 'indirect' clauses expected}} |
| 50 |
#pragma omp begin declare target to(q) indirect(fz()) device_type(nohost) |
| 51 |
#pragma omp end declare target |
| 52 |
|
| 53 |
// omp51-error@+1 {{unexpected 'to' clause, only 'device_type', 'indirect' clauses expected}} |
| 54 |
#pragma omp begin declare target indirect to(xxx) |
| 55 |
void bar(); |
| 56 |
#pragma omp end declare target |
| 57 |
|
| 58 |
// omp51-error@+2 {{unexpected 'tofrom' clause, only 'to', 'link', 'device_type' or 'indirect' clauses expected}} |
| 59 |
// omp51-error@+1 {{expected at least one 'to', 'link' or 'indirect' clause}} |
| 60 |
#pragma omp declare target tofrom(xxx) |
| 61 |
|
| 62 |
// omp51-error@+1 {{only 'device_type(any)' clause is allowed with indirect clause}} |
| 63 |
#pragma omp begin declare target device_type(host) indirect |
| 64 |
void bar(); |
| 65 |
#pragma omp end declare target |
| 66 |
#endif // _OPENMP |
| 67 |
|
| 68 |
void c(); |
| 69 |
|
| 70 |
void func() {} // expected-note {{'func' defined here}} |
| 71 |
|
| 72 |
#pragma omp declare target link(func) allocate(a) // expected-error {{function name is not allowed in 'link' clause}} omp45-error {{unexpected 'allocate' clause, only 'to' or 'link' clauses expected}} omp5-error {{unexpected 'allocate' clause, only 'to', 'link' or 'device_type' clauses expected}} omp51-error {{unexpected 'allocate' clause, only 'to', 'link', 'device_type' or 'indirect' clauses expected}} omp52-error {{unexpected 'allocate' clause, only 'enter', 'link', 'device_type' or 'indirect' clauses expected}} |
| 73 |
|
| 74 |
void bar(); |
| 75 |
void baz() {bar();} |
| 76 |
#pragma omp declare target(bar) // omp5-warning {{declaration marked as declare target after first use, it may lead to incorrect results}} // omp51-warning {{declaration marked as declare target after first use, it may lead to incorrect results}} omp52-warning {{declaration marked as declare target after first use, it may lead to incorrect results}} |
| 77 |
|
| 78 |
extern int b; |
| 79 |
|
| 80 |
struct NonT { |
| 81 |
int a; |
| 82 |
}; |
| 83 |
|
| 84 |
typedef int sint; |
| 85 |
|
| 86 |
template <typename T> |
| 87 |
T bla1() { return 0; } |
| 88 |
|
| 89 |
#pragma omp declare target |
| 90 |
template <typename T> |
| 91 |
T bla2() { return 0; } |
| 92 |
#pragma omp end declare target |
| 93 |
|
| 94 |
template<> |
| 95 |
float bla2() { return 1.0; } |
| 96 |
|
| 97 |
#pragma omp declare target |
| 98 |
void blub2() { |
| 99 |
bla2<float>(); |
| 100 |
bla2<int>(); |
| 101 |
} |
| 102 |
#pragma omp end declare target |
| 103 |
|
| 104 |
void t2() { |
| 105 |
#pragma omp target |
| 106 |
{ |
| 107 |
bla2<float>(); |
| 108 |
bla2<long>(); |
| 109 |
} |
| 110 |
} |
| 111 |
|
| 112 |
#pragma omp declare target |
| 113 |
void abc(); |
| 114 |
#pragma omp end declare target |
| 115 |
void cba(); |
| 116 |
#pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} |
| 117 |
|
| 118 |
#pragma omp declare target |
| 119 |
#pragma omp declare target |
| 120 |
void def(); |
| 121 |
#pragma omp end declare target |
| 122 |
void fed(); |
| 123 |
|
| 124 |
#pragma omp declare target |
| 125 |
#pragma omp threadprivate(a) // expected-note {{defined as threadprivate or thread local}} |
| 126 |
extern int b; |
| 127 |
int g; |
| 128 |
|
| 129 |
struct T { |
| 130 |
int a; |
| 131 |
virtual int method(); |
| 132 |
}; |
| 133 |
|
| 134 |
class VC { |
| 135 |
T member; |
| 136 |
NonT member1; |
| 137 |
public: |
| 138 |
virtual int method() { T a; return 0; } |
| 139 |
}; |
| 140 |
|
| 141 |
struct C { |
| 142 |
NonT a; |
| 143 |
sint b; |
| 144 |
int method(); |
| 145 |
int method1(); |
| 146 |
}; |
| 147 |
|
| 148 |
int C::method1() { |
| 149 |
return 0; |
| 150 |
} |
| 151 |
|
| 152 |
void foo(int p) { |
| 153 |
a = 0; // expected-error {{threadprivate variables cannot be used in target constructs}} |
| 154 |
b = 0; |
| 155 |
t = 1; // expected-error {{threadprivate variables cannot be used in target constructs}} |
| 156 |
C object; |
| 157 |
VC object1; |
| 158 |
g = object.method(); |
| 159 |
g += object.method1(); |
| 160 |
g += object1.method() + p; |
| 161 |
f(); // dev5-error {{function with 'device_type(host)' is not available on device}} |
| 162 |
q(); |
| 163 |
c(); |
| 164 |
} |
| 165 |
#pragma omp declare target |
| 166 |
void foo1() { |
| 167 |
[&](){ (void)(b+z);}(); // omp5-note {{variable 'z' is captured here}} //omp51-note {{variable 'z' is captured here}} omp52-note {{variable 'z' is captured here}} |
| 168 |
} |
| 169 |
#pragma omp end declare target |
| 170 |
|
| 171 |
#pragma omp end declare target |
| 172 |
#pragma omp end declare target |
| 173 |
#pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} |
| 174 |
|
| 175 |
int C::method() { |
| 176 |
return 0; |
| 177 |
} |
| 178 |
|
| 179 |
struct S { |
| 180 |
#pragma omp declare target |
| 181 |
int v; |
| 182 |
#pragma omp end declare target |
| 183 |
}; |
| 184 |
|
| 185 |
void foo3() { |
| 186 |
return; |
| 187 |
} |
| 188 |
|
| 189 |
int *y; |
| 190 |
int **w = &y; |
| 191 |
int main (int argc, char **argv) { |
| 192 |
int a = 2; |
| 193 |
#pragma omp declare target // expected-error {{unexpected OpenMP directive '#pragma omp declare target'}} |
| 194 |
int v; |
| 195 |
#pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} |
| 196 |
foo(v); |
| 197 |
#pragma omp declare target to(foo3) link(w) // omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} |
| 198 |
#pragma omp declare target to(a) //omp45-error {{local variable 'a' should not be used in 'declare target' directive}} omp5-error {{local variable 'a' should not be used in 'declare target' directive}} omp51-error {{local variable 'a' should not be used in 'declare target' directive}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} |
| 199 |
return (0); |
| 200 |
} |
| 201 |
|
| 202 |
namespace { |
| 203 |
#pragma omp declare target |
| 204 |
int x; |
| 205 |
} |
| 206 |
#pragma omp end declare target |
| 207 |
|
| 208 |
#pragma omp declare target link(S) // expected-error {{'S' used in declare target directive is not a variable or a function name}} |
| 209 |
|
| 210 |
#pragma omp declare target (x, x) // expected-error {{'x' appears multiple times in clauses on the same declare target directive}} |
| 211 |
#pragma omp declare target to(x) to(x) // omp45-error {{'x' appears multiple times in clauses on the same declare target directive}} omp5-error {{'x' appears multiple times in clauses on the same declare target directive}} omp51-error {{'x' appears multiple times in clauses on the same declare target directive}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} |
| 212 |
#pragma omp declare target link(x) // expected-error {{'x' must not appear in both clauses 'to' and 'link'}} |
| 213 |
|
| 214 |
void bazz() {} |
| 215 |
#pragma omp declare target to(bazz) device_type(nohost) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} host5-note 3{{marked as 'device_type(nohost)' here}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} |
| 216 |
void bazzz() {bazz();} |
| 217 |
#pragma omp declare target to(bazzz) device_type(nohost) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} |
| 218 |
void any() {bazz();} // host5-error {{function with 'device_type(nohost)' is not available on host}} |
| 219 |
void host1() {bazz();} // host5-error {{function with 'device_type(nohost)' is not available on host}} |
| 220 |
#pragma omp declare target to(host1) device_type(host) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} dev5-note 3 {{marked as 'device_type(host)' here}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} |
| 221 |
void host2() {bazz();} //host5-error {{function with 'device_type(nohost)' is not available on host}} |
| 222 |
#pragma omp declare target to(host2) // omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} |
| 223 |
void device() {host1();} // dev5-error {{function with 'device_type(host)' is not available on device}} |
| 224 |
#pragma omp declare target to(device) device_type(nohost) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} host5-note 2 {{marked as 'device_type(nohost)' here}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} |
| 225 |
void host3() {host1();} // dev5-error {{function with 'device_type(host)' is not available on device}} |
| 226 |
#pragma omp declare target to(host3) // omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} |
| 227 |
|
| 228 |
#pragma omp declare target |
| 229 |
void any1() {any();} |
| 230 |
void any2() {host1();} // dev5-error {{function with 'device_type(host)' is not available on device}} |
| 231 |
void any3() {device();} // host5-error {{function with 'device_type(nohost)' is not available on host}} |
| 232 |
void any4() {any2();} |
| 233 |
#pragma omp end declare target |
| 234 |
|
| 235 |
void any5() {any();} |
| 236 |
void any6() {host1();} |
| 237 |
void any7() {device();} // host5-error {{function with 'device_type(nohost)' is not available on host}} |
| 238 |
void any8() {any2();} |
| 239 |
|
| 240 |
int MultiDevTy; |
| 241 |
#pragma omp declare target to(MultiDevTy) device_type(any) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} |
| 242 |
#pragma omp declare target to(MultiDevTy) device_type(host) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} omp5-error {{'device_type(host)' does not match previously specified 'device_type(any)' for the same declaration}} omp51-error {{'device_type(host)' does not match previously specified 'device_type(any)' for the same declaration}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} |
| 243 |
#pragma omp declare target to(MultiDevTy) device_type(nohost) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} omp5-error {{'device_type(nohost)' does not match previously specified 'device_type(any)' for the same declaration}} // omp51-error {{'device_type(nohost)' does not match previously specified 'device_type(any)' for the same declaration}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} |
| 244 |
|
| 245 |
static int variable = 100; //expected-warning {{declaration is not declared in any declare target region}} |
| 246 |
static float variable1 = 200; |
| 247 |
static float variable2 = variable1; //expected-warning {{declaration is not declared in any declare target region}} |
| 248 |
|
| 249 |
static int var = 1; //expected-warning {{declaration is not declared in any declare target region}} |
| 250 |
|
| 251 |
static int var1 = 10; |
| 252 |
static int *var2 = &var1; |
| 253 |
static int **ptr1 = &var2; //expected-warning {{declaration is not declared in any declare target region}} |
| 254 |
|
| 255 |
int arr[2] = {1,2}; |
| 256 |
int (*arrptr)[2] = &arr; //expected-warning {{declaration is not declared in any declare target region}} |
| 257 |
|
| 258 |
class declare{ |
| 259 |
public: int x; |
| 260 |
void print(); |
| 261 |
}; |
| 262 |
declare obj1; |
| 263 |
declare *obj2 = &obj1; //expected-warning {{declaration is not declared in any declare target region}} |
| 264 |
|
| 265 |
struct target{ |
| 266 |
int x; |
| 267 |
void print(); |
| 268 |
}; |
| 269 |
static target S; //expected-warning {{declaration is not declared in any declare target region}} |
| 270 |
|
| 271 |
#pragma omp declare target |
| 272 |
int target_var = variable; //expected-note {{used here}} |
| 273 |
float target_var1 = variable2; //expected-note {{used here}} |
| 274 |
int *ptr = &var; //expected-note {{used here}} |
| 275 |
int ***ptr2 = &ptr1; //expected-note {{used here}} |
| 276 |
int (**ptr3)[2] = &arrptr; //expected-note {{used here}} |
| 277 |
declare **obj3 = &obj2; //expected-note {{used here}} |
| 278 |
target *S1 = &S; //expected-note {{used here}} |
| 279 |
#pragma omp end declare target |
| 280 |
|
| 281 |
#if TESTENDINC |
| 282 |
#include "unterminated_declare_target_include.h" |
| 283 |
#elif TESTEND |
| 284 |
// expected-warning@+1 {{expected '#pragma omp end declare target' at end of file to match '#pragma omp declare target'}} |
| 285 |
#pragma omp declare target |
| 286 |
#else |
| 287 |
// expected-warning@+1 {{expected '#pragma omp end declare target' at end of file to match '#pragma omp begin declare target'}} |
| 288 |
#pragma omp begin declare target |
| 289 |
#endif |