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