1 | // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -emit-llvm -o - %s |
2 | // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -emit-llvm -o - %s |
3 | |
4 | // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -fnoopenmp-use-tls -ferror-limit 100 -emit-llvm -o - %s |
5 | // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -ferror-limit 100 -emit-llvm -o - %s |
6 | |
7 | #pragma omp threadprivate // expected-error {{expected '(' after 'threadprivate'}} |
8 | #pragma omp threadprivate( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
9 | #pragma omp threadprivate() // expected-error {{expected identifier}} |
10 | #pragma omp threadprivate(1) // expected-error {{expected unqualified-id}} |
11 | struct CompleteSt{ |
12 | int a; |
13 | }; |
14 | |
15 | struct CompleteSt1{ |
16 | #pragma omp threadprivate(1) // expected-error {{expected unqualified-id}} |
17 | int a; |
18 | } d; // expected-note {{'d' defined here}} |
19 | |
20 | int a; // expected-note {{'a' defined here}} |
21 | |
22 | #pragma omp threadprivate(a) allocate(a) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
23 | #pragma omp threadprivate(u) // expected-error {{use of undeclared identifier 'u'}} |
24 | #pragma omp threadprivate(d, a) |
25 | int foo() { // expected-note {{declared here}} |
26 | static int l; |
27 | #pragma omp threadprivate(l)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
28 | return (a); |
29 | } |
30 | |
31 | #pragma omp threadprivate (a) ( |
32 | // expected-warning@-1 {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
33 | #pragma omp threadprivate (a) [ // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
34 | #pragma omp threadprivate (a) { // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
35 | #pragma omp threadprivate (a) ) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
36 | #pragma omp threadprivate (a) ] // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
37 | #pragma omp threadprivate (a) } // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
38 | #pragma omp threadprivate a // expected-error {{expected '(' after 'threadprivate'}} |
39 | #pragma omp threadprivate(d // expected-error {{expected ')'}} expected-note {{to match this '('}} |
40 | #pragma omp threadprivate(d)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
41 | int x, y; |
42 | #pragma omp threadprivate(x)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
43 | #pragma omp threadprivate(y)), |
44 | // expected-warning@-1 {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
45 | #pragma omp threadprivate(a,d) |
46 | #pragma omp threadprivate(d.a) // expected-error {{expected identifier}} |
47 | #pragma omp threadprivate((float)a) // expected-error {{expected unqualified-id}} |
48 | int foa; // expected-note {{'foa' declared here}} |
49 | #pragma omp threadprivate(faa) // expected-error {{use of undeclared identifier 'faa'; did you mean 'foa'?}} |
50 | #pragma omp threadprivate(foo) // expected-error {{'foo' is not a global variable, static local variable or static data member}} |
51 | #pragma omp threadprivate (int a=2) // expected-error {{expected unqualified-id}} |
52 | |
53 | struct IncompleteSt; // expected-note {{forward declaration of 'IncompleteSt'}} |
54 | |
55 | extern IncompleteSt e; |
56 | #pragma omp threadprivate (e) // expected-error {{threadprivate variable with incomplete type 'IncompleteSt'}} |
57 | |
58 | int &f = a; // expected-note {{'f' defined here}} |
59 | #pragma omp threadprivate (f) // expected-error {{arguments of '#pragma omp threadprivate' cannot be of reference type 'int &'}} |
60 | |
61 | class TestClass { |
62 | private: |
63 | int a; // expected-note {{declared here}} |
64 | static int b; // expected-note {{'b' declared here}} |
65 | TestClass() : a(0){} |
66 | public: |
67 | TestClass (int aaa) : a(aaa) {} |
68 | #pragma omp threadprivate (b, a) // expected-error {{'a' is not a global variable, static local variable or static data member}} |
69 | } g(10); |
70 | #pragma omp threadprivate (b) // expected-error {{use of undeclared identifier 'b'}} |
71 | #pragma omp threadprivate (TestClass::b) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'TestClass::b' variable declaration}} |
72 | #pragma omp threadprivate (g) |
73 | |
74 | namespace ns { |
75 | int m; |
76 | #pragma omp threadprivate (m, m) |
77 | } |
78 | #pragma omp threadprivate (m) // expected-error {{use of undeclared identifier 'm'}} |
79 | #pragma omp threadprivate (ns::m) |
80 | #pragma omp threadprivate (ns:m) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}} |
81 | |
82 | const int h = 12; |
83 | const volatile int i = 10; |
84 | #pragma omp threadprivate (h, i) |
85 | |
86 | |
87 | template <class T> |
88 | class TempClass { |
89 | private: |
90 | T a; |
91 | TempClass() : a(){} |
92 | public: |
93 | TempClass (T aaa) : a(aaa) {} |
94 | static T s; |
95 | #pragma omp threadprivate (s) |
96 | }; |
97 | #pragma omp threadprivate (s) // expected-error {{use of undeclared identifier 's'}} |
98 | |
99 | static __thread int t; // expected-note {{'t' defined here}} |
100 | #pragma omp threadprivate (t) // expected-error {{variable 't' cannot be threadprivate because it is thread-local}} |
101 | |
102 | // Register "0" is currently an invalid register for global register variables. |
103 | // Use "esp" instead of "0". |
104 | // register int reg0 __asm__("0"); |
105 | register int reg0 __asm__("esp"); // expected-note {{'reg0' defined here}} |
106 | #pragma omp threadprivate (reg0) // expected-error {{variable 'reg0' cannot be threadprivate because it is a global named register variable}} |
107 | |
108 | int o; // expected-note {{candidate found by name lookup is 'o'}} |
109 | #pragma omp threadprivate (o) |
110 | namespace { |
111 | int o; // expected-note {{candidate found by name lookup is '(anonymous namespace)::o'}} |
112 | #pragma omp threadprivate (o) |
113 | #pragma omp threadprivate (o) |
114 | } |
115 | #pragma omp threadprivate (o) // expected-error {{reference to 'o' is ambiguous}} |
116 | #pragma omp threadprivate (::o) |
117 | |
118 | int main(int argc, char **argv) { // expected-note {{'argc' defined here}} |
119 | |
120 | int x, y = argc; // expected-note 2 {{'y' defined here}} |
121 | static double d1; |
122 | static double d2; |
123 | static double d3; // expected-note {{'d3' defined here}} |
124 | static double d4; |
125 | static TestClass LocalClass(y); // expected-error {{variable with local storage in initial value of threadprivate variable}} |
126 | #pragma omp threadprivate(LocalClass) |
127 | |
128 | d.a = a; |
129 | d2++; |
130 | ; |
131 | #pragma omp threadprivate(argc+y) // expected-error {{expected identifier}} |
132 | #pragma omp threadprivate(argc,y) // expected-error 2 {{arguments of '#pragma omp threadprivate' must have static storage duration}} |
133 | #pragma omp threadprivate(d2) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd2'}} |
134 | #pragma omp threadprivate(d1) |
135 | { |
136 | ++a;d2=0; |
137 | #pragma omp threadprivate(d3) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'd3' variable declaration}} |
138 | } |
139 | #pragma omp threadprivate(d3) |
140 | label: |
141 | #pragma omp threadprivate(d4) // expected-error {{'#pragma omp threadprivate' cannot be an immediate substatement}} |
142 | |
143 | #pragma omp threadprivate(a) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'a' variable declaration}} |
144 | return (y); |
145 | #pragma omp threadprivate(d) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'd' variable declaration}} |
146 | } |
147 | |