Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / critical_messages.cpp
blob9a7267cf27a8a2c1caa387664e4f3ab69234f235
1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
5 int foo();
7 void xxx(int argc) {
8 int x; // expected-note {{initialize the variable 'x' to silence this warning}}
9 #pragma omp critical
10 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
13 template<typename T, int N>
14 int tmain(int argc, char **argv) { // expected-note {{declared here}}
15 #pragma omp critical
17 #pragma omp critical untied allocate(argc) // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp critical'}} expected-error {{unexpected OpenMP clause 'allocate' in directive '#pragma omp critical'}}
18 #pragma omp critical unknown // expected-warning {{extra tokens at the end of '#pragma omp critical' are ignored}}
19 #pragma omp critical ( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
20 #pragma omp critical ( + // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
21 #pragma omp critical (name2 // expected-error {{expected ')'}} expected-note {{to match this '('}}
22 #pragma omp critical (name1)
23 foo();
25 #pragma omp critical
26 } // expected-error {{expected statement}}
27 #pragma omp critical (name2) // expected-note {{previous 'critical' region starts here}}
28 #pragma omp critical
29 for (int i = 0; i < 10; ++i) {
30 foo();
31 #pragma omp parallel
32 #pragma omp for
33 for (int j = 0; j < 10; j++) {
34 foo();
35 #pragma omp critical(name2) // expected-error {{cannot nest 'critical' regions having the same name 'name2'}}
36 foo();
39 #pragma omp critical (name2)
40 #pragma omp critical
41 for (int i = 0; i < 10; ++i) {
42 foo();
43 #pragma omp parallel
44 #pragma omp for
45 for (int j = 0; j < 10; j++) {
46 #pragma omp critical
47 foo();
50 #pragma omp critical (name2)
51 #pragma omp critical
52 for (int i = 0; i < 10; ++i) {
53 foo();
54 #pragma omp parallel
55 #pragma omp for
56 for (int j = 0; j < 10; j++) {
57 #pragma omp critical (nam)
58 foo();
62 #pragma omp critical (name2) hint // expected-error {{expected '(' after 'hint'}}
63 foo();
64 #pragma omp critical (name2) hint( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
65 foo();
66 #pragma omp critical (name2) hint(+ // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
67 foo();
68 #pragma omp critical (name2) hint(argc) // expected-error {{integral constant expression}} expected-note 0+{{constant expression}}
69 foo();
70 #pragma omp critical (name) hint(N) // expected-error {{argument to 'hint' clause must be a non-negative integer value}} expected-error {{constructs with the same name must have a 'hint' clause with the same value}} expected-note {{'hint' clause with value '4'}}
71 foo();
72 #pragma omp critical hint(N) // expected-error {{the name of the construct must be specified in presence of 'hint' clause}}
73 foo();
75 const int omp_lock_hint_none = 0;
76 #pragma omp critical (name3) hint(omp_lock_hint_none)
77 foo();
78 return 0;
81 int main(int argc, char **argv) { // expected-note {{declared here}}
82 #pragma omp critical
84 #pragma omp critical untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp critical'}}
85 #pragma omp critical unknown // expected-warning {{extra tokens at the end of '#pragma omp critical' are ignored}}
86 #pragma omp critical ( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
87 #pragma omp critical ( + // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
88 #pragma omp critical (name2 // expected-error {{expected ')'}} expected-note {{to match this '('}}
89 #pragma omp critical (name1)
90 foo();
92 #pragma omp critical
93 } // expected-error {{expected statement}}
94 #pragma omp critical (name2) // expected-note {{previous 'critical' region starts here}}
95 #pragma omp critical
96 for (int i = 0; i < 10; ++i) {
97 foo();
98 #pragma omp parallel
99 #pragma omp for
100 for (int j = 0; j < 10; j++) {
101 foo();
102 #pragma omp critical(name2) // expected-error {{cannot nest 'critical' regions having the same name 'name2'}}
103 foo();
106 #pragma omp critical (name2)
107 #pragma omp critical
108 for (int i = 0; i < 10; ++i) {
109 foo();
110 #pragma omp parallel
111 #pragma omp for
112 for (int j = 0; j < 10; j++) {
113 #pragma omp critical
114 foo();
117 #pragma omp critical (name2)
118 #pragma omp critical
119 for (int i = 0; i < 10; ++i) {
120 foo();
121 #pragma omp parallel
122 #pragma omp for
123 for (int j = 0; j < 10; j++) {
124 #pragma omp critical (nam)
125 foo();
129 #pragma omp critical (name2) hint // expected-error {{expected '(' after 'hint'}}
130 foo();
131 #pragma omp critical (name2) hint( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
132 foo();
133 #pragma omp critical (name2) hint(+ // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
134 foo();
135 #pragma omp critical (name2) hint(argc) // expected-error {{integral constant expression}} expected-note 0+{{constant expression}}
136 foo();
137 #pragma omp critical (name) hint(23) // expected-note {{previous 'hint' clause with value '23'}}
138 foo();
139 #pragma omp critical hint(-5) // expected-error {{argument to 'hint' clause must be a non-negative integer value}}
140 foo();
141 #pragma omp critical hint(1) // expected-error {{the name of the construct must be specified in presence of 'hint' clause}}
142 foo();
143 return tmain<int, 4>(argc, argv) + tmain<float, -5>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<float, -5>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}}
146 int foo() {
147 L1: // expected-note {{jump exits scope of OpenMP structured block}}
148 foo();
149 #pragma omp critical
151 foo();
152 goto L1; // expected-error {{cannot jump from this goto statement to its label}}
154 goto L2; // expected-error {{cannot jump from this goto statement to its label}}
155 #pragma omp critical
156 { // expected-note {{jump bypasses OpenMP structured block}}
158 foo();
161 return 0;