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