1 // RUN: %clang_cc1 -verify -fopenmp %s
2
foo()3 void foo() {
4 }
5
foobool(int argc)6 bool foobool(int argc) {
7 return argc;
8 }
9
10 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
11 extern S1 a;
12 class S2 {
13 mutable int a;
14
15 public:
S2()16 S2() : a(0) {}
17 };
18 const S2 b;
19 const S2 ba[5];
20 class S3 {
21 int a;
22
23 public:
S3()24 S3() : a(0) {}
25 };
26 const S3 ca[5];
27 class S4 {
28 int a;
29 S4(); // expected-note {{implicitly declared private here}}
30
31 public:
S4(int v)32 S4(int v) : a(v) {}
33 };
34 class S5 {
35 int a;
S5()36 S5() : a(0) {} // expected-note {{implicitly declared private here}}
37
38 public:
S5(int v)39 S5(int v) : a(v) {}
40 };
41
42 S3 h;
43 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
44
45 template <class I, class C>
foomain(I argc,C ** argv)46 int foomain(I argc, C **argv) {
47 I e(4);
48 I g(5);
49 int i;
50 int &j = i;
51 #pragma omp parallel sections private // expected-error {{expected '(' after 'private'}}
52 {
53 foo();
54 }
55 #pragma omp parallel sections private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
56 {
57 foo();
58 }
59 #pragma omp parallel sections private() // expected-error {{expected expression}}
60 {
61 foo();
62 }
63 #pragma omp parallel sections private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
64 {
65 foo();
66 }
67 #pragma omp parallel sections private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
68 {
69 foo();
70 }
71 #pragma omp parallel sections private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
72 {
73 foo();
74 }
75 #pragma omp parallel sections private(argc)
76 {
77 foo();
78 }
79 #pragma omp parallel sections private(S1) // expected-error {{'S1' does not refer to a value}}
80 {
81 foo();
82 }
83 #pragma omp parallel sections private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
84 {
85 foo();
86 }
87 #pragma omp parallel sections private(argv[1]) // expected-error {{expected variable name}}
88 {
89 foo();
90 }
91 #pragma omp parallel sections private(e, g)
92 {
93 foo();
94 }
95 #pragma omp parallel sections private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
96 {
97 foo();
98 }
99 #pragma omp parallel sections copyprivate(h) // expected-error {{unexpected OpenMP clause 'copyprivate' in directive '#pragma omp parallel sections'}}
100 {
101 foo();
102 }
103 #pragma omp parallel
104 {
105 int v = 0;
106 int i;
107 #pragma omp parallel sections private(i)
108 {
109 foo();
110 }
111 v += i;
112 }
113 #pragma omp parallel shared(i)
114 #pragma omp parallel private(i)
115 #pragma omp parallel sections private(j)
116 {
117 foo();
118 }
119 #pragma omp parallel sections private(i)
120 {
121 foo();
122 }
123 return 0;
124 }
125
126 namespace A {
127 double x;
128 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
129 }
130 namespace B {
131 using A::x;
132 }
133
main(int argc,char ** argv)134 int main(int argc, char **argv) {
135 S4 e(4);
136 S5 g(5);
137 int i;
138 int &j = i;
139 #pragma omp parallel sections private // expected-error {{expected '(' after 'private'}}
140 {
141 foo();
142 }
143 #pragma omp parallel sections private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
144 {
145 foo();
146 }
147 #pragma omp parallel sections private() // expected-error {{expected expression}}
148 {
149 foo();
150 }
151 #pragma omp parallel sections private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
152 {
153 foo();
154 }
155 #pragma omp parallel sections private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
156 {
157 foo();
158 }
159 #pragma omp parallel sections private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
160 {
161 foo();
162 }
163 #pragma omp parallel sections private(argc)
164 {
165 foo();
166 }
167 #pragma omp parallel sections private(S1) // expected-error {{'S1' does not refer to a value}}
168 {
169 foo();
170 }
171 #pragma omp parallel sections private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
172 {
173 foo();
174 }
175 #pragma omp parallel sections private(argv[1]) // expected-error {{expected variable name}}
176 {
177 foo();
178 }
179 #pragma omp parallel sections private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
180 {
181 foo();
182 }
183 #pragma omp parallel sections private(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}}
184 {
185 foo();
186 }
187 #pragma omp parallel sections copyprivate(h) // expected-error {{unexpected OpenMP clause 'copyprivate' in directive '#pragma omp parallel sections'}}
188 {
189 foo();
190 }
191 #pragma omp parallel
192 {
193 int i;
194 #pragma omp parallel sections private(i)
195 {
196 foo();
197 }
198 }
199 #pragma omp parallel shared(i)
200 #pragma omp parallel private(i)
201 #pragma omp parallel sections private(j)
202 {
203 foo();
204 }
205 #pragma omp parallel sections private(i)
206 {
207 foo();
208 }
209 static int m;
210 #pragma omp parallel sections private(m)
211 {
212 foo();
213 }
214
215 return 0;
216 }
217
218