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