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