Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / error_message.cpp
blob40f1db40fb63af2dbd12e1e4b4117b5424533a9a
1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -ferror-limit 100 %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -ferror-limit 100 %s -Wuninitialized
5 template <class T>
6 T tmain(T argc) {
7 if (argc)
8 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
9 if (argc) {
10 #pragma omp error // expected-error {{ERROR}}
12 while (argc)
13 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
14 while (argc) {
15 #pragma omp error // expected-error {{ERROR}}
18 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
19 while (argc)
21 do {
22 #pragma omp error // expected-error {{ERROR}}
23 } while (argc);
24 switch (argc)
25 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
26 switch (argc)
27 case 1:
28 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
29 switch (argc)
30 case 1: {
31 #pragma omp error // expected-error {{ERROR}}
33 switch (argc) {
34 #pragma omp error // expected-error {{ERROR}}
35 case 1:
36 #pragma omp error // expected-error {{ERROR}}
37 break;
38 default: {
39 #pragma omp error // expected-error {{ERROR}}
40 } break;
42 for (;;)
43 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
44 for (;;) {
45 #pragma omp error // expected-error {{ERROR}}
47 label:
48 #pragma omp error // expected-error {{ERROR}}
49 label1 : {
50 #pragma omp error // expected-error {{ERROR}}
52 if (1)
53 label2:
54 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
56 // expected-error@+1 {{ERROR}}
57 #pragma omp error at() // expected-error {{expected 'compilation' or 'execution' in OpenMP clause 'at'}}
59 // expected-error@+1 {{ERROR}}
60 #pragma omp error at(up) // expected-error {{expected 'compilation' or 'execution' in OpenMP clause 'at'}}
62 // expected-error@+3 {{ERROR}}
63 // expected-error@+2 {{expected ')'}}
64 // expected-note@+1 {{to match this '('}}
65 #pragma omp error at(up(a)) // expected-error {{expected 'compilation' or 'execution' in OpenMP clause 'at'}}
67 #pragma omp error at(execution) // no error
69 #pragma omp error at(compilation) // expected-error {{ERROR}}
71 // expected-error@+1 {{ERROR}}
72 #pragma omp error at(compilation) at(execution) //expected-error {{directive '#pragma omp error' cannot contain more than one 'at' clause}}
74 // expected-error@+1 {{ERROR}}
75 #pragma omp error severity() // expected-error {{expected 'fatal' or 'warning' in OpenMP clause 'severity'}}
76 // expected-error@+1 {{ERROR}}
77 #pragma omp error severity(xyz) // expected-error {{expected 'fatal' or 'warning' in OpenMP clause 'severity'}}
78 // expected-error@+1 {{ERROR}}
79 #pragma omp error severity(fatal) severity(warning) // expected-error {{directive '#pragma omp error' cannot contain more than one 'severity' clause}}
81 // expected-error@+1 {{ERROR}}
82 #pragma omp error severity(fatal) severity(fatal) // expected-error {{directive '#pragma omp error' cannot contain more than one 'severity' clause}}
84 // expected-warning@+2 {{WARNING}}
85 // expected-warning@+1 {{WARNING}}
86 #pragma omp error severity(warning) severity(warning) // expected-error {{directive '#pragma omp error' cannot contain more than one 'severity' clause}}
88 // expected-warning@+1 {{WARNING}}
89 #pragma omp error severity(warning) // expected-warning {{WARNING}}
90 #pragma omp error severity(fatal) // expected-error {{ERROR}}
92 // expected-warning@+1 {{WARNING}}
93 #pragma omp error at(compilation) severity(warning) // expected-warning {{WARNING}}
94 #pragma omp error at(execution) severity(warning) // no error, diagnosic at runtime
95 #pragma omp error at(compilation) severity(fatal) // expected-error {{ERROR}}
96 #pragma omp error at(execution) severity(fatal) // no error, error at runtime
98 #pragma omp error message("GPU compiler is needed.") // expected-error {{GPU compiler is needed}}
99 #pragma omp error at(compilation) message("GPU compiler is needed.") // expected-error {{GPU compiler is needed}}
100 #pragma omp error at(execution) message("GPU compiler is needed.") // no error
101 // expected-warning@+1 {{GPU compiler is needed.}}
102 #pragma omp error severity(warning) message("GPU compiler is needed.") // expected-warning {{GPU compiler is needed.}}
103 #pragma omp error severity(fatal) message("GPU compiler is needed.") // expected-error {{GPU compiler is needed}}
104 // expected-warning@+1 {{GPU compiler is needed.}}
105 #pragma omp error at(compilation) severity(warning) message("GPU compiler is needed.") // expected-warning {{GPU compiler is needed.}}
106 #pragma omp error at(compilation) severity(fatal) message("GPU compiler is needed.") // expected-error {{GPU compiler is needed.}}
107 #pragma omp error at(execution) severity(warning) message("GPU compiler is needed.") // no warning warning will emit at runtime.
108 #pragma omp error at(execution) severity(fatal) message("GPU compiler is needed.") // no warning warning will emit at runtime.
110 // expected-error@+1 {{GPU compiler is needed.}}
111 #pragma omp error message("GPU compiler is needed.") message("GPU compiler is needed.") // expected-error {{directive '#pragma omp error' cannot contain more than one 'message' clause}}
112 int a;
113 // expected-warning@+1 {{expected string literal in 'clause message' - ignoring}}
114 #pragma omp error message(a) // expected-error {{ERROR}}
115 // expected-error@+1 {{ERROR}}
116 #pragma omp error message() // expected-error {{expected expression}}
117 return T();
120 #pragma omp error at(execution) // expected-error {{unexpected 'execution' modifier in non-executable context}}
122 #pragma omp error at(compilation) // expected-error {{ERROR}}
123 class A {
125 #pragma omp error at(compilation) // expected-error {{ERROR}}
127 #pragma omp error at(execution) // expected-error {{unexpected 'execution' modifier in non-executable context}}
128 int A;
131 int main(int argc, char **argv) {
132 // expected-error@+1 {{ERROR}}
133 #pragma omp error
135 // expected-error@+1 {{ERROR}}
136 #pragma omp error untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp error'}}
137 if (argc)
138 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
139 if (argc) {
140 // expected-error@+1 {{ERROR}}
141 #pragma omp error
143 while (argc)
144 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
145 while (argc) {
146 // expected-error@+1 {{ERROR}}
147 #pragma omp error
150 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
151 while (argc)
153 do {
154 // expected-error@+1 {{ERROR}}
155 #pragma omp error
156 } while (argc);
157 switch (argc)
158 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
159 switch (argc)
160 case 1:
161 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
162 switch (argc)
163 case 1: {
164 // expected-error@+1 {{ERROR}}
165 #pragma omp error
167 switch (argc) {
168 // expected-error@+1 {{ERROR}}
169 #pragma omp error
170 case 1:
171 // expected-error@+1 {{ERROR}}
172 #pragma omp error
173 break;
174 default: {
175 // expected-error@+1 {{ERROR}}
176 #pragma omp error
177 } break;
179 for (;;)
180 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
181 for (;;) {
182 // expected-error@+1 {{ERROR}}
183 #pragma omp error
185 label:
186 // expected-error@+1 {{ERROR}}
187 #pragma omp error
188 label1 : {
189 // expected-error@+1 {{ERROR}}
190 #pragma omp error
192 if (1)
193 label2:
194 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
196 return tmain(argc);// expected-note {{in instantiation of function template specialization 'tmain<int>' requested here}}