[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / single_misc_messages.c
blobf4c6834714545805ecf26cf9d893904038f77ca8
1 // RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s -Wuninitialized
3 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify %s -Wuninitialized
5 void xxx(int argc) {
6 int x; // expected-note {{initialize the variable 'x' to silence this warning}}
7 #pragma omp single
8 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
11 void foo(void);
13 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp single'}}
14 #pragma omp single
16 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp single'}}
17 #pragma omp single foo
19 void test_no_clause(void) {
20 int i;
21 #pragma omp single
22 foo();
24 #pragma omp single
25 ++i;
28 void test_branch_protected_scope(void) {
29 int i = 0;
30 L1:
31 ++i;
33 int x[24];
35 #pragma omp parallel
36 #pragma omp single
38 if (i == 5)
39 goto L1; // expected-error {{use of undeclared label 'L1'}}
40 else if (i == 6)
41 return; // expected-error {{cannot return from OpenMP region}}
42 else if (i == 7)
43 goto L2;
44 else if (i == 8) {
45 L2:
46 x[i]++;
50 if (x[0] == 0)
51 goto L2; // expected-error {{use of undeclared label 'L2'}}
52 else if (x[1] == 1)
53 goto L1;
56 void test_invalid_clause(void) {
57 int i;
58 #pragma omp parallel
59 // expected-warning@+1 {{extra tokens at the end of '#pragma omp single' are ignored}}
60 #pragma omp single foo bar
61 foo();
64 void test_non_identifiers(void) {
65 int i, x;
67 #pragma omp parallel
68 // expected-warning@+1 {{extra tokens at the end of '#pragma omp single' are ignored}}
69 #pragma omp single;
70 foo();
71 #pragma omp parallel
72 // expected-error@+2 {{unexpected OpenMP clause 'linear' in directive '#pragma omp single'}}
73 // expected-warning@+1 {{extra tokens at the end of '#pragma omp single' are ignored}}
74 #pragma omp single linear(x);
75 foo();
77 #pragma omp parallel
78 // expected-warning@+1 {{extra tokens at the end of '#pragma omp single' are ignored}}
79 #pragma omp single private(x);
80 foo();
82 #pragma omp parallel
83 // expected-warning@+1 {{extra tokens at the end of '#pragma omp single' are ignored}}
84 #pragma omp single, private(x);
85 foo();
88 void test_private(void) {
89 int i;
90 #pragma omp parallel
91 // expected-error@+2 {{expected expression}}
92 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
93 #pragma omp single private(
94 foo();
95 #pragma omp parallel
96 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
97 // expected-error@+1 2 {{expected expression}}
98 #pragma omp single private(,
99 foo();
100 #pragma omp parallel
101 // expected-error@+1 2 {{expected expression}}
102 #pragma omp single private(, )
103 foo();
104 #pragma omp parallel
105 // expected-error@+1 {{expected expression}}
106 #pragma omp single private()
107 foo();
108 #pragma omp parallel
109 // expected-error@+1 {{expected expression}}
110 #pragma omp single private(int)
111 foo();
112 #pragma omp parallel
113 // expected-error@+1 {{expected variable name}}
114 #pragma omp single private(0)
115 foo();
117 int x, y, z;
118 #pragma omp parallel
119 #pragma omp single private(x)
120 foo();
121 #pragma omp parallel
122 #pragma omp single private(x, y)
123 foo();
124 #pragma omp parallel
125 #pragma omp single private(x, y, z)
126 foo();
129 void test_firstprivate(void) {
130 int i;
131 #pragma omp parallel
132 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
133 // expected-error@+1 {{expected expression}}
134 #pragma omp single firstprivate(
135 foo();
137 #pragma omp parallel
138 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
139 // expected-error@+1 2 {{expected expression}}
140 #pragma omp single firstprivate(,
141 foo();
142 #pragma omp parallel
143 // expected-error@+1 2 {{expected expression}}
144 #pragma omp single firstprivate(, )
145 foo();
146 #pragma omp parallel
147 // expected-error@+1 {{expected expression}}
148 #pragma omp single firstprivate()
149 foo();
150 #pragma omp parallel
151 // expected-error@+1 {{expected expression}}
152 #pragma omp single firstprivate(int)
153 foo();
154 #pragma omp parallel
155 // expected-error@+1 {{expected variable name}}
156 #pragma omp single firstprivate(0)
157 foo();
160 void test_nowait(void) {
161 #pragma omp single nowait nowait // expected-error {{directive '#pragma omp single' cannot contain more than one 'nowait' clause}}
162 for (int i = 0; i < 16; ++i)