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 #pragma omp declare target to(foo1) // expected-error {{use of undeclared identifier 'foo1'}}
17 
18 #pragma omp declare target link(foo2) // expected-error {{use of undeclared identifier 'foo2'}}
19 
20 void c(); // expected-warning {{declaration is not declared in any declare target region}}
21 
22 extern int b;
23 
24 struct NonT {
25   int a;
26 };
27 
28 typedef int sint;
29 
30 #pragma omp declare target // expected-note {{to match this '#pragma omp declare target'}}
31 #pragma omp threadprivate(a) // expected-note {{defined as threadprivate or thread local}}
32 extern int b;
33 int g;
34 
35 struct T {
36   int a;
37   virtual int method();
38 };
39 
40 class VC {
41   T member;
42   NonT member1;
43   public:
44     virtual int method() { T a; return 0; }
45 };
46 
47 struct C {
48   NonT a;
49   sint b;
50   int method();
51   int method1();
52 };
53 
54 int C::method1() {
55   return 0;
56 }
57 
58 void foo() {
59   a = 0; // expected-error {{threadprivate variables cannot be used in target constructs}}
60   b = 0; // expected-note {{used here}}
61   t = 1; // expected-error {{threadprivate variables cannot be used in target constructs}}
62   C object;
63   VC object1;
64   g = object.method();
65   g += object.method1();
66   g += object1.method();
67   f();
68   c(); // expected-note {{used here}}
69 }
70 #pragma omp declare target // expected-error {{expected '#pragma omp end declare target'}}
71 void foo1() {}
72 #pragma omp end declare target
73 #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
74 
75 int C::method() {
76   return 0;
77 }
78 
79 struct S {
80 #pragma omp declare target
81   int v;
82 #pragma omp end declare target
83 };
84 
85 int main (int argc, char **argv) {
86 #pragma omp declare target // expected-error {{unexpected OpenMP directive '#pragma omp declare target'}}
87   int v;
88 #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
89   foo();
90   return (0);
91 }
92 
93 namespace {
94 #pragma omp declare target // expected-note {{to match this '#pragma omp declare target'}}
95   int x;
96 } //  expected-error {{expected '#pragma omp end declare target'}}
97 #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
98 
99 #pragma omp declare target link(S) // expected-error {{'S' used in declare target directive is not a variable or a function name}}
100 
101 #pragma omp declare target (x, x) // expected-error {{'x' appears multiple times in clauses on the same declare target directive}}
102 #pragma omp declare target to(x) to(x) // expected-error {{'x' appears multiple times in clauses on the same declare target directive}}
103 #pragma omp declare target link(x) // expected-error {{'x' must not appear in both clauses 'to' and 'link'}}
104 
105 #pragma omp declare target // expected-error {{expected '#pragma omp end declare target'}} expected-note {{to match this '#pragma omp declare target'}}
106