1 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -o - %s
2
3 #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
4
5 int a, b; // expected-warning {{declaration is not declared in any declare target region}}
6 __thread int t; // expected-note {{defined as threadprivate or thread local}}
7
8 #pragma omp declare target . // expected-error {{expected '(' after 'declare target'}}
9
10 #pragma omp declare target
11 void f();
12 #pragma omp end declare target shared(a) // expected-warning {{extra tokens at the end of '#pragma omp end declare target' are ignored}}
13
14 #pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, only 'to' or 'link' clauses expected}}
15
16 void c(); // expected-warning {{declaration is not declared in any declare target region}}
17
18 extern int b;
19
20 struct NonT {
21 int a;
22 };
23
24 typedef int sint;
25
26 #pragma omp declare target // expected-note {{to match this '#pragma omp declare target'}}
27 #pragma omp threadprivate(a) // expected-note {{defined as threadprivate or thread local}}
28 extern int b;
29 int g;
30
31 struct T { // expected-note {{mappable type cannot be polymorphic}}
32 int a;
33 virtual int method();
34 };
35
36 class VC { // expected-note {{mappable type cannot be polymorphic}}
37 T member;
38 NonT member1;
39 public:
method()40 virtual int method() { T a; return 0; } // expected-error {{type 'T' is not mappable to target}}
41 };
42
43 struct C {
44 NonT a;
45 sint b;
46 int method();
47 int method1();
48 };
49
method1()50 int C::method1() {
51 return 0;
52 }
53
foo()54 void foo() {
55 a = 0; // expected-error {{threadprivate variables cannot be used in target constructs}}
56 b = 0; // expected-note {{used here}}
57 t = 1; // expected-error {{threadprivate variables cannot be used in target constructs}}
58 C object;
59 VC object1; // expected-error {{type 'VC' is not mappable to target}}
60 g = object.method();
61 g += object.method1();
62 g += object1.method();
63 f();
64 c(); // expected-note {{used here}}
65 }
66 #pragma omp declare target // expected-error {{expected '#pragma omp end declare target'}}
foo1()67 void foo1() {}
68 #pragma omp end declare target
69 #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
70
method()71 int C::method() {
72 return 0;
73 }
74
75 struct S {
76 #pragma omp declare target // expected-error {{directive must be at file or namespace scope}}
77 int v;
78 #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
79 };
80
main(int argc,char ** argv)81 int main (int argc, char **argv) {
82 #pragma omp declare target // expected-error {{unexpected OpenMP directive '#pragma omp declare target'}}
83 int v;
84 #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
85 foo();
86 return (0);
87 }
88
89 namespace {
90 #pragma omp declare target // expected-note {{to match this '#pragma omp declare target'}}
91 int x;
92 } // expected-error {{expected '#pragma omp end declare target'}}
93 #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
94
95 #pragma omp declare target link(S) // expected-error {{'S' used in declare target directive is not a variable or a function name}}
96
97 #pragma omp declare target (x, x) // expected-error {{'x' appears multiple times in clauses on the same declare target directive}}
98 #pragma omp declare target to(x) to(x) // expected-error {{'x' appears multiple times in clauses on the same declare target directive}}
99 #pragma omp declare target link(x) // expected-error {{'x' must not appear in both clauses 'to' and 'link'}}
100
101 #pragma omp declare target // expected-error {{expected '#pragma omp end declare target'}} expected-note {{to match this '#pragma omp declare target'}}
102