• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
2 
3 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
4 
5 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
6 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
7 
foo()8 void foo() {
9 }
10 
foobool(int argc)11 bool foobool(int argc) {
12   return argc;
13 }
14 
xxx(int argc)15 void xxx(int argc) {
16   int cond; // expected-note {{initialize the variable 'cond' to silence this warning}}
17 #pragma omp distribute parallel for if(cond) // expected-warning {{variable 'cond' is uninitialized when used here}}
18   for (int i = 0; i < 10; ++i)
19     ;
20 }
21 
22 struct S1; // expected-note {{declared here}}
23 
24 template <class T, class S> // expected-note {{declared here}}
tmain(T argc,S ** argv)25 int tmain(T argc, S **argv) {
26   T i, z;
27 #pragma omp target
28 #pragma omp teams
29 #pragma omp 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
33 #pragma omp distribute parallel for if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
34   for (i = 0; i < argc; ++i) foo();
35 #pragma omp target
36 #pragma omp teams
37 #pragma omp distribute parallel for if () // expected-error {{expected expression}}
38   for (i = 0; i < argc; ++i) foo();
39 #pragma omp target
40 #pragma omp teams
41 #pragma omp distribute parallel for if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
42   for (i = 0; i < argc; ++i) foo();
43 #pragma omp target
44 #pragma omp teams
45 #pragma omp distribute parallel for if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
46   for (i = 0; i < argc; ++i) foo();
47 #pragma omp target
48 #pragma omp teams
49 #pragma omp distribute parallel for if (argc > 0 ? argv[1] : argv[2])
50   for (i = 0; i < argc; ++i) foo();
51 #pragma omp target
52 #pragma omp teams
53 #pragma omp distribute parallel for if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'if' clause}}
54   for (i = 0; i < argc; ++i) foo();
55 #pragma omp target
56 #pragma omp teams
57 #pragma omp distribute parallel for if (S) // expected-error {{'S' does not refer to a value}}
58   for (i = 0; i < argc; ++i) foo();
59 #pragma omp target
60 #pragma omp teams
61 #pragma omp distribute parallel for if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
62   for (i = 0; i < argc; ++i) foo();
63 #pragma omp target
64 #pragma omp teams
65 #pragma omp distribute parallel for if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
66   for (i = 0; i < argc; ++i) foo();
67 #pragma omp target
68 #pragma omp teams
69 #pragma omp distribute parallel for if(argc+z)
70   for (i = 0; i < argc; ++i) foo();
71 #pragma omp target
72 #pragma omp teams
73 #pragma omp distribute parallel for if(parallel // expected-error {{use of undeclared identifier 'parallel'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
74   for (i = 0; i < argc; ++i) foo();
75 #pragma omp target
76 #pragma omp teams
77 #pragma omp distribute parallel for if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
78   for (i = 0; i < argc; ++i) foo();
79 #pragma omp target
80 #pragma omp teams
81 #pragma omp distribute parallel for if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
82   for (i = 0; i < argc; ++i) foo();
83 #pragma omp target
84 #pragma omp teams
85 #pragma omp distribute parallel for if(parallel : argc)
86   for (i = 0; i < argc; ++i) foo();
87 #pragma omp target
88 #pragma omp teams
89 #pragma omp distribute parallel for if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp distribute parallel for'}}
90   for (i = 0; i < argc; ++i) foo();
91 #pragma omp target
92 #pragma omp teams
93 #pragma omp distribute parallel for if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}}
94   for (i = 0; i < argc; ++i) foo();
95 #pragma omp target
96 #pragma omp teams
97 #pragma omp 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}}
98   for (i = 0; i < argc; ++i) foo();
99 #pragma omp target
100 #pragma omp teams
101 #pragma omp distribute parallel for if(distribute : argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp distribute parallel for'}}
102   for (i = 0; i < argc; ++i) foo();
103 
104   return 0;
105 }
106 
main(int argc,char ** argv)107 int main(int argc, char **argv) {
108   int i, z;
109 #pragma omp target
110 #pragma omp teams
111 #pragma omp distribute parallel for if // expected-error {{expected '(' after 'if'}}
112   for (i = 0; i < argc; ++i) foo();
113 #pragma omp target
114 #pragma omp teams
115 #pragma omp distribute parallel for if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
116   for (i = 0; i < argc; ++i) foo();
117 #pragma omp target
118 #pragma omp teams
119 #pragma omp distribute parallel for if () // expected-error {{expected expression}}
120   for (i = 0; i < argc; ++i) foo();
121 #pragma omp target
122 #pragma omp teams
123 #pragma omp distribute parallel for if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
124   for (i = 0; i < argc; ++i) foo();
125 #pragma omp target
126 #pragma omp teams
127 #pragma omp distribute parallel for if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
128   for (i = 0; i < argc; ++i) foo();
129 #pragma omp target
130 #pragma omp teams
131 #pragma omp distribute parallel for if (argc > 0 ? argv[1] : argv[2])
132   for (i = 0; i < argc; ++i) foo();
133 #pragma omp target
134 #pragma omp teams
135 #pragma omp distribute parallel for if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'if' clause}}
136   for (i = 0; i < argc; ++i) foo();
137 #pragma omp target
138 #pragma omp teams
139 #pragma omp distribute parallel for if (S1) // expected-error {{'S1' does not refer to a value}}
140   for (i = 0; i < argc; ++i) foo();
141 #pragma omp target
142 #pragma omp teams
143 #pragma omp distribute parallel for if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
144   for (i = 0; i < argc; ++i) foo();
145 #pragma omp target
146 #pragma omp teams
147 #pragma omp distribute parallel for if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
148   for (i = 0; i < argc; ++i) foo();
149 #pragma omp target
150 #pragma omp teams
151 #pragma omp distribute parallel for if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
152   for (i = 0; i < argc; ++i) foo();
153 #pragma omp target
154 #pragma omp teams
155 #pragma omp distribute parallel for if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
156   for (i = 0; i < argc; ++i) foo();
157 #pragma omp target
158 #pragma omp teams
159 #pragma omp distribute parallel for if(parallel // expected-error {{use of undeclared identifier 'parallel'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
160   for (i = 0; i < argc; ++i) foo();
161 #pragma omp target
162 #pragma omp teams
163 #pragma omp distribute parallel for if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
164   for (i = 0; i < argc; ++i) foo();
165 #pragma omp target
166 #pragma omp teams
167 #pragma omp distribute parallel for if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
168   for (i = 0; i < argc; ++i) foo();
169 #pragma omp target
170 #pragma omp teams
171 #pragma omp distribute parallel for if(parallel : argc-z)
172   for (i = 0; i < argc; ++i) foo();
173 #pragma omp target
174 #pragma omp teams
175 #pragma omp distribute parallel for if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp distribute parallel for'}}
176   for (i = 0; i < argc; ++i) foo();
177 #pragma omp target
178 #pragma omp teams
179 #pragma omp distribute parallel for if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}}
180   for (i = 0; i < argc; ++i) foo();
181 #pragma omp target
182 #pragma omp teams
183 #pragma omp 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}}
184   for (i = 0; i < argc; ++i) foo();
185 #pragma omp target
186 #pragma omp teams
187 #pragma omp distribute parallel for if(distribute : argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp distribute parallel for'}}
188   for (i = 0; i < argc; ++i) foo();
189 
190   return tmain(argc, argv);
191 }
192