1 | // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -o - %s |
2 | |
3 | // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -fnoopenmp-use-tls -ferror-limit 100 -o - %s |
4 | |
5 | #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} |
6 | |
7 | int a, b; |
8 | __thread int t; // expected-note {{defined as threadprivate or thread local}} |
9 | |
10 | #pragma omp declare target . // expected-error {{expected '(' after 'declare target'}} |
11 | |
12 | #pragma omp declare target |
13 | void f(); |
14 | #pragma omp end declare target shared(a) // expected-warning {{extra tokens at the end of '#pragma omp end declare target' are ignored}} |
15 | |
16 | #pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, only 'to' or 'link' clauses expected}} |
17 | |
18 | #pragma omp declare target to(foo1) // expected-error {{use of undeclared identifier 'foo1'}} |
19 | |
20 | #pragma omp declare target link(foo2) // expected-error {{use of undeclared identifier 'foo2'}} |
21 | |
22 | void c(); |
23 | |
24 | void func() {} // expected-note {{'func' defined here}} |
25 | |
26 | #pragma omp declare target link(func) allocate(a) // expected-error {{function name is not allowed in 'link' clause}} expected-error {{unexpected 'allocate' clause, only 'to' or 'link' clauses expected}} |
27 | |
28 | extern int b; |
29 | |
30 | struct NonT { |
31 | int a; |
32 | }; |
33 | |
34 | typedef int sint; |
35 | |
36 | template <typename T> |
37 | T bla1() { return 0; } |
38 | |
39 | #pragma omp declare target |
40 | template <typename T> |
41 | T bla2() { return 0; } |
42 | #pragma omp end declare target |
43 | |
44 | template<> |
45 | float bla2() { return 1.0; } |
46 | |
47 | #pragma omp declare target |
48 | void blub2() { |
49 | bla2<float>(); |
50 | bla2<int>(); |
51 | } |
52 | #pragma omp end declare target |
53 | |
54 | void t2() { |
55 | #pragma omp target |
56 | { |
57 | bla2<float>(); |
58 | bla2<long>(); |
59 | } |
60 | } |
61 | |
62 | #pragma omp declare target |
63 | void abc(); |
64 | #pragma omp end declare target |
65 | void cba(); |
66 | #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} |
67 | |
68 | #pragma omp declare target |
69 | #pragma omp declare target |
70 | void def(); |
71 | #pragma omp end declare target |
72 | void fed(); |
73 | |
74 | #pragma omp declare target |
75 | #pragma omp threadprivate(a) // expected-note {{defined as threadprivate or thread local}} |
76 | extern int b; |
77 | int g; |
78 | |
79 | struct T { |
80 | int a; |
81 | virtual int method(); |
82 | }; |
83 | |
84 | class VC { |
85 | T member; |
86 | NonT member1; |
87 | public: |
88 | virtual int method() { T a; return 0; } |
89 | }; |
90 | |
91 | struct C { |
92 | NonT a; |
93 | sint b; |
94 | int method(); |
95 | int method1(); |
96 | }; |
97 | |
98 | int C::method1() { |
99 | return 0; |
100 | } |
101 | |
102 | void foo(int p) { |
103 | a = 0; // expected-error {{threadprivate variables cannot be used in target constructs}} |
104 | b = 0; |
105 | t = 1; // expected-error {{threadprivate variables cannot be used in target constructs}} |
106 | C object; |
107 | VC object1; |
108 | g = object.method(); |
109 | g += object.method1(); |
110 | g += object1.method() + p; |
111 | f(); |
112 | c(); |
113 | } |
114 | #pragma omp declare target |
115 | void foo1() {} |
116 | #pragma omp end declare target |
117 | |
118 | #pragma omp end declare target |
119 | #pragma omp end declare target |
120 | #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} |
121 | |
122 | int C::method() { |
123 | return 0; |
124 | } |
125 | |
126 | struct S { |
127 | #pragma omp declare target |
128 | int v; |
129 | #pragma omp end declare target |
130 | }; |
131 | |
132 | int main (int argc, char **argv) { |
133 | #pragma omp declare target // expected-error {{unexpected OpenMP directive '#pragma omp declare target'}} |
134 | int v; |
135 | #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} |
136 | foo(v); |
137 | return (0); |
138 | } |
139 | |
140 | namespace { |
141 | #pragma omp declare target // expected-note {{to match this '#pragma omp declare target'}} |
142 | int x; |
143 | } // expected-error {{expected '#pragma omp end declare target'}} |
144 | #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} |
145 | |
146 | #pragma omp declare target link(S) // expected-error {{'S' used in declare target directive is not a variable or a function name}} |
147 | |
148 | #pragma omp declare target (x, x) // expected-error {{'x' appears multiple times in clauses on the same declare target directive}} |
149 | #pragma omp declare target to(x) to(x) // expected-error {{'x' appears multiple times in clauses on the same declare target directive}} |
150 | #pragma omp declare target link(x) // expected-error {{'x' must not appear in both clauses 'to' and 'link'}} |
151 | |
152 | #pragma omp declare target // expected-error {{expected '#pragma omp end declare target'}} expected-note {{to match this '#pragma omp declare target'}} |
153 | |