Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / teams_distribute_parallel_for_if_messages.cpp
blob09ed6fa15f4a697ba7c118536bedd5d58b642311
1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
5 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
6 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
8 void foo() {
11 bool foobool(int argc) {
12 return argc;
15 void xxx(int argc) {
16 int cond; // expected-note {{initialize the variable 'cond' to silence this warning}}
17 #pragma omp target
18 #pragma omp teams distribute parallel for if(cond) // expected-warning {{variable 'cond' is uninitialized when used here}}
19 for (int i = 0; i < 10; ++i)
23 struct S1; // expected-note {{declared here}}
25 template <class T, class S> // expected-note {{declared here}}
26 int tmain(T argc, S **argv) {
27 T i, z;
28 #pragma omp target
29 #pragma omp teams distribute parallel for if // expected-error {{expected '(' after 'if'}}
30 for (i = 0; i < argc; ++i) foo();
31 #pragma omp target
32 #pragma omp teams distribute parallel for if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
33 for (i = 0; i < argc; ++i) foo();
34 #pragma omp target
35 #pragma omp teams distribute parallel for if () // expected-error {{expected expression}}
36 for (i = 0; i < argc; ++i) foo();
37 #pragma omp target
38 #pragma omp teams distribute parallel for if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
39 for (i = 0; i < argc; ++i) foo();
40 #pragma omp target
41 #pragma omp teams distribute parallel for if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
42 for (i = 0; i < argc; ++i) foo();
43 #pragma omp target
44 #pragma omp teams distribute parallel for if (argc > 0 ? argv[1] : argv[2])
45 for (i = 0; i < argc; ++i) foo();
46 #pragma omp target
47 #pragma omp teams distribute parallel for if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'if' clause}}
48 for (i = 0; i < argc; ++i) foo();
49 #pragma omp target
50 #pragma omp teams distribute parallel for if (S) // expected-error {{'S' does not refer to a value}}
51 for (i = 0; i < argc; ++i) foo();
52 #pragma omp target
53 #pragma omp teams distribute parallel for if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
54 for (i = 0; i < argc; ++i) foo();
55 #pragma omp target
56 #pragma omp teams distribute parallel for if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
57 for (i = 0; i < argc; ++i) foo();
58 #pragma omp target
59 #pragma omp teams distribute parallel for if(argc+z)
60 for (i = 0; i < argc; ++i) foo();
61 #pragma omp target
62 #pragma omp teams distribute parallel for if(parallel // expected-error {{use of undeclared identifier 'parallel'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
63 for (i = 0; i < argc; ++i) foo();
64 #pragma omp target
65 #pragma omp teams distribute parallel for if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
66 for (i = 0; i < argc; ++i) foo();
67 #pragma omp target
68 #pragma omp teams distribute parallel for if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
69 for (i = 0; i < argc; ++i) foo();
70 #pragma omp target
71 #pragma omp teams distribute parallel for if(parallel : argc)
72 for (i = 0; i < argc; ++i) foo();
73 #pragma omp target
74 #pragma omp teams distribute parallel for if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp teams distribute parallel for'}}
75 for (i = 0; i < argc; ++i) foo();
76 #pragma omp target
77 #pragma omp teams distribute parallel for if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}}
78 for (i = 0; i < argc; ++i) foo();
79 #pragma omp target
80 #pragma omp teams distribute parallel for if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
81 for (i = 0; i < argc; ++i) foo();
82 #pragma omp target
83 #pragma omp teams distribute parallel for if(distribute : argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp teams distribute parallel for'}}
84 for (i = 0; i < argc; ++i) foo();
86 return 0;
89 int main(int argc, char **argv) {
90 int i, z;
91 #pragma omp target
92 #pragma omp teams distribute parallel for if // expected-error {{expected '(' after 'if'}}
93 for (i = 0; i < argc; ++i) foo();
94 #pragma omp target
95 #pragma omp teams distribute parallel for if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
96 for (i = 0; i < argc; ++i) foo();
97 #pragma omp target
98 #pragma omp teams distribute parallel for if () // expected-error {{expected expression}}
99 for (i = 0; i < argc; ++i) foo();
100 #pragma omp target
101 #pragma omp teams distribute parallel for if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
102 for (i = 0; i < argc; ++i) foo();
103 #pragma omp target
104 #pragma omp teams distribute parallel for if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
105 for (i = 0; i < argc; ++i) foo();
106 #pragma omp target
107 #pragma omp teams distribute parallel for if (argc > 0 ? argv[1] : argv[2])
108 for (i = 0; i < argc; ++i) foo();
109 #pragma omp target
110 #pragma omp teams distribute parallel for if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'if' clause}}
111 for (i = 0; i < argc; ++i) foo();
112 #pragma omp target
113 #pragma omp teams distribute parallel for if (S1) // expected-error {{'S1' does not refer to a value}}
114 for (i = 0; i < argc; ++i) foo();
115 #pragma omp target
116 #pragma omp teams distribute parallel for if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
117 for (i = 0; i < argc; ++i) foo();
118 #pragma omp target
119 #pragma omp teams distribute parallel for if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
120 for (i = 0; i < argc; ++i) foo();
121 #pragma omp target
122 #pragma omp teams distribute parallel for if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
123 for (i = 0; i < argc; ++i) foo();
124 #pragma omp target
125 #pragma omp teams distribute parallel for if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
126 for (i = 0; i < argc; ++i) foo();
127 #pragma omp target
128 #pragma omp teams distribute parallel for if(parallel // expected-error {{use of undeclared identifier 'parallel'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
129 for (i = 0; i < argc; ++i) foo();
130 #pragma omp target
131 #pragma omp teams distribute parallel for if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
132 for (i = 0; i < argc; ++i) foo();
133 #pragma omp target
134 #pragma omp teams distribute parallel for if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
135 for (i = 0; i < argc; ++i) foo();
136 #pragma omp target
137 #pragma omp teams distribute parallel for if(parallel : argc + z)
138 for (i = 0; i < argc; ++i) foo();
139 #pragma omp target
140 #pragma omp teams distribute parallel for if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp teams distribute parallel for'}}
141 for (i = 0; i < argc; ++i) foo();
142 #pragma omp target
143 #pragma omp teams distribute parallel for if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}}
144 for (i = 0; i < argc; ++i) foo();
145 #pragma omp target
146 #pragma omp teams distribute parallel for if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
147 for (i = 0; i < argc; ++i) foo();
148 #pragma omp target
149 #pragma omp teams distribute parallel for if(distribute : argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp teams distribute parallel for'}}
150 for (i = 0; i < argc; ++i) foo();
152 return tmain(argc, argv);