2016-04-06 19:38:59 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -o - %s
|
|
|
|
|
2017-12-30 02:07:07 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -fnoopenmp-use-tls -ferror-limit 100 -o - %s
|
|
|
|
|
2016-04-06 19:38:59 +08:00
|
|
|
#pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
|
|
|
|
|
|
|
|
int a, b; // expected-warning {{declaration is not declared in any declare target region}}
|
|
|
|
__thread int t; // expected-note {{defined as threadprivate or thread local}}
|
2016-05-09 22:59:13 +08:00
|
|
|
|
|
|
|
#pragma omp declare target . // expected-error {{expected '(' after 'declare target'}}
|
|
|
|
|
|
|
|
#pragma omp declare target
|
2016-04-06 19:38:59 +08:00
|
|
|
void f();
|
|
|
|
#pragma omp end declare target shared(a) // expected-warning {{extra tokens at the end of '#pragma omp end declare target' are ignored}}
|
2016-05-09 22:59:13 +08:00
|
|
|
|
|
|
|
#pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, only 'to' or 'link' clauses expected}}
|
|
|
|
|
2017-12-01 02:52:06 +08:00
|
|
|
#pragma omp declare target to(foo1) // expected-error {{use of undeclared identifier 'foo1'}}
|
|
|
|
|
|
|
|
#pragma omp declare target link(foo2) // expected-error {{use of undeclared identifier 'foo2'}}
|
|
|
|
|
2018-05-03 01:39:00 +08:00
|
|
|
void c();
|
2016-04-06 19:38:59 +08:00
|
|
|
|
2017-12-13 04:08:12 +08:00
|
|
|
void func() {} // expected-note {{'func' defined here}}
|
|
|
|
|
|
|
|
#pragma omp declare target link(func) // expected-error {{function name is not allowed in 'link' clause}}
|
|
|
|
|
2016-04-06 19:38:59 +08:00
|
|
|
extern int b;
|
|
|
|
|
|
|
|
struct NonT {
|
|
|
|
int a;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef int sint;
|
|
|
|
|
2018-02-17 05:23:23 +08:00
|
|
|
template <typename T>
|
|
|
|
T bla1() { return 0; }
|
|
|
|
|
|
|
|
#pragma omp declare target
|
|
|
|
template <typename T>
|
|
|
|
T bla2() { return 0; }
|
|
|
|
#pragma omp end declare target
|
|
|
|
|
|
|
|
template<>
|
|
|
|
float bla2() { return 1.0; }
|
|
|
|
|
|
|
|
#pragma omp declare target
|
|
|
|
void blub2() {
|
|
|
|
bla2<float>();
|
|
|
|
bla2<int>();
|
|
|
|
}
|
|
|
|
#pragma omp end declare target
|
|
|
|
|
|
|
|
void t2() {
|
|
|
|
#pragma omp target
|
|
|
|
{
|
|
|
|
bla2<float>();
|
|
|
|
bla2<long>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-06 19:38:59 +08:00
|
|
|
#pragma omp declare target // expected-note {{to match this '#pragma omp declare target'}}
|
|
|
|
#pragma omp threadprivate(a) // expected-note {{defined as threadprivate or thread local}}
|
|
|
|
extern int b;
|
|
|
|
int g;
|
|
|
|
|
2017-09-13 19:12:35 +08:00
|
|
|
struct T {
|
2016-04-06 19:38:59 +08:00
|
|
|
int a;
|
|
|
|
virtual int method();
|
|
|
|
};
|
|
|
|
|
2017-09-13 19:12:35 +08:00
|
|
|
class VC {
|
2016-04-06 19:38:59 +08:00
|
|
|
T member;
|
|
|
|
NonT member1;
|
|
|
|
public:
|
2017-09-13 19:12:35 +08:00
|
|
|
virtual int method() { T a; return 0; }
|
2016-04-06 19:38:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct C {
|
|
|
|
NonT a;
|
|
|
|
sint b;
|
|
|
|
int method();
|
|
|
|
int method1();
|
|
|
|
};
|
|
|
|
|
|
|
|
int C::method1() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-05-01 02:28:08 +08:00
|
|
|
void foo(int p) {
|
2016-04-06 19:38:59 +08:00
|
|
|
a = 0; // expected-error {{threadprivate variables cannot be used in target constructs}}
|
|
|
|
b = 0; // expected-note {{used here}}
|
|
|
|
t = 1; // expected-error {{threadprivate variables cannot be used in target constructs}}
|
|
|
|
C object;
|
2017-09-13 19:12:35 +08:00
|
|
|
VC object1;
|
2016-04-06 19:38:59 +08:00
|
|
|
g = object.method();
|
|
|
|
g += object.method1();
|
2018-05-01 02:28:08 +08:00
|
|
|
g += object1.method() + p;
|
2016-04-06 19:38:59 +08:00
|
|
|
f();
|
2018-05-03 01:39:00 +08:00
|
|
|
c();
|
2016-04-06 19:38:59 +08:00
|
|
|
}
|
|
|
|
#pragma omp declare target // expected-error {{expected '#pragma omp end declare target'}}
|
|
|
|
void foo1() {}
|
|
|
|
#pragma omp end declare target
|
|
|
|
#pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
|
|
|
|
|
|
|
|
int C::method() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct S {
|
2017-10-04 04:00:00 +08:00
|
|
|
#pragma omp declare target
|
2016-04-06 19:38:59 +08:00
|
|
|
int v;
|
2017-10-04 04:00:00 +08:00
|
|
|
#pragma omp end declare target
|
2016-04-06 19:38:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
int main (int argc, char **argv) {
|
|
|
|
#pragma omp declare target // expected-error {{unexpected OpenMP directive '#pragma omp declare target'}}
|
|
|
|
int v;
|
|
|
|
#pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
|
2018-05-01 02:28:08 +08:00
|
|
|
foo(v);
|
2016-04-06 19:38:59 +08:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
#pragma omp declare target // expected-note {{to match this '#pragma omp declare target'}}
|
|
|
|
int x;
|
|
|
|
} // expected-error {{expected '#pragma omp end declare target'}}
|
|
|
|
#pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
|
|
|
|
|
2016-05-09 22:59:13 +08:00
|
|
|
#pragma omp declare target link(S) // expected-error {{'S' used in declare target directive is not a variable or a function name}}
|
|
|
|
|
|
|
|
#pragma omp declare target (x, x) // expected-error {{'x' appears multiple times in clauses on the same declare target directive}}
|
|
|
|
#pragma omp declare target to(x) to(x) // expected-error {{'x' appears multiple times in clauses on the same declare target directive}}
|
|
|
|
#pragma omp declare target link(x) // expected-error {{'x' must not appear in both clauses 'to' and 'link'}}
|
|
|
|
|
2016-04-06 19:38:59 +08:00
|
|
|
#pragma omp declare target // expected-error {{expected '#pragma omp end declare target'}} expected-note {{to match this '#pragma omp declare target'}}
|