Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / parallel_sections_misc_messages.c
blob1091f7c672460654041e62d236917e52fcdf462a
1 // RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s -Wuninitialized
3 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify %s -Wuninitialized
5 void foo(void);
7 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp parallel sections'}}
8 #pragma omp parallel sections
10 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp parallel sections'}}
11 #pragma omp parallel sections foo
13 void test_no_clause(void) {
14 int i;
15 #pragma omp parallel sections
17 foo();
20 // expected-error@+2 {{the statement for '#pragma omp parallel sections' must be a compound statement}}
21 #pragma omp parallel sections
22 ++i;
24 #pragma omp parallel sections
26 foo();
27 foo(); // expected-error {{statement in 'omp parallel sections' directive must be enclosed into a section region}}
32 void test_branch_protected_scope(void) {
33 int i = 0;
34 L1:
35 ++i;
37 int x[24];
39 #pragma omp parallel sections
41 if (i == 5)
42 goto L1; // expected-error {{use of undeclared label 'L1'}}
43 else if (i == 6)
44 return; // expected-error {{cannot return from OpenMP region}}
45 else if (i == 7)
46 goto L2;
47 else if (i == 8) {
48 L2:
49 x[i]++;
51 #pragma omp section
52 if (i == 5)
53 goto L1;
54 else if (i == 6)
55 return; // expected-error {{cannot return from OpenMP region}}
56 else if (i == 7)
57 goto L3;
58 else if (i == 8) {
59 L3:
60 x[i]++;
64 if (x[0] == 0)
65 goto L2; // expected-error {{use of undeclared label 'L2'}}
66 else if (x[1] == 1)
67 goto L1;
68 goto L3; // expected-error {{use of undeclared label 'L3'}}
71 void test_invalid_clause(void) {
72 int i;
73 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
74 #pragma omp parallel sections foo bar
76 foo();
77 // expected-error@+1 {{unexpected OpenMP clause 'nowait' in directive '#pragma omp section'}}
78 #pragma omp section nowait
83 void test_non_identifiers(void) {
84 int i, x;
86 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
87 #pragma omp parallel sections;
89 foo();
91 // expected-error@+2 {{unexpected OpenMP clause 'linear' in directive '#pragma omp parallel sections'}}
92 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
93 #pragma omp parallel sections linear(x);
95 foo();
98 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
99 #pragma omp parallel sections private(x);
101 foo();
104 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
105 #pragma omp parallel sections, private(x);
107 foo();
111 void test_private(void) {
112 int i;
113 // expected-error@+2 {{expected expression}}
114 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
115 #pragma omp parallel sections private(
117 foo();
119 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
120 // expected-error@+1 2 {{expected expression}}
121 #pragma omp parallel sections private(,
123 foo();
125 // expected-error@+1 2 {{expected expression}}
126 #pragma omp parallel sections private(, )
128 foo();
130 // expected-error@+1 {{expected expression}}
131 #pragma omp parallel sections private()
133 foo();
135 // expected-error@+1 {{expected expression}}
136 #pragma omp parallel sections private(int)
138 foo();
140 // expected-error@+1 {{expected variable name}}
141 #pragma omp parallel sections private(0)
143 foo();
146 int x, y, z;
147 #pragma omp parallel sections private(x)
149 foo();
151 #pragma omp parallel sections private(x, y)
153 foo();
155 #pragma omp parallel sections private(x, y, z)
157 foo();
161 void test_lastprivate(void) {
162 int i;
163 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
164 // expected-error@+1 {{expected expression}}
165 #pragma omp parallel sections lastprivate(
167 foo();
170 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
171 // expected-error@+1 2 {{expected expression}}
172 #pragma omp parallel sections lastprivate(,
174 foo();
176 // expected-error@+1 2 {{expected expression}}
177 #pragma omp parallel sections lastprivate(, )
179 foo();
181 // expected-error@+1 {{expected expression}}
182 #pragma omp parallel sections lastprivate()
184 foo();
186 // expected-error@+1 {{expected expression}}
187 #pragma omp parallel sections lastprivate(int)
189 foo();
191 // expected-error@+1 {{expected variable name}}
192 #pragma omp parallel sections lastprivate(0)
194 foo();
197 int x, y, z;
198 #pragma omp parallel sections lastprivate(x)
200 foo();
202 #pragma omp parallel sections lastprivate(x, y)
204 foo();
206 #pragma omp parallel sections lastprivate(x, y, z)
208 foo();
212 void test_firstprivate(void) {
213 int i;
214 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
215 // expected-error@+1 {{expected expression}}
216 #pragma omp parallel sections firstprivate(
218 foo();
221 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
222 // expected-error@+1 2 {{expected expression}}
223 #pragma omp parallel sections firstprivate(,
225 foo();
227 // expected-error@+1 2 {{expected expression}}
228 #pragma omp parallel sections firstprivate(, )
230 foo();
232 // expected-error@+1 {{expected expression}}
233 #pragma omp parallel sections firstprivate()
235 foo();
237 // expected-error@+1 {{expected expression}}
238 #pragma omp parallel sections firstprivate(int)
240 foo();
242 // expected-error@+1 {{expected variable name}}
243 #pragma omp parallel sections firstprivate(0)
245 foo();
248 int x, y, z;
249 #pragma omp parallel sections lastprivate(x) firstprivate(x)
251 foo();
253 #pragma omp parallel sections lastprivate(x, y) firstprivate(x, y)
255 foo();
257 #pragma omp parallel sections lastprivate(x, y, z) firstprivate(x, y, z)
259 foo();