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 
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 target teams 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 z;
27 #pragma omp target teams if // expected-error {{expected '(' after 'if'}}
28   foo();
29 #pragma omp target teams if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
30   foo();
31 #pragma omp target teams if () // expected-error {{expected expression}}
32   foo();
33 #pragma omp target teams if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
34   foo();
35 #pragma omp target teams if (z)) // expected-warning {{extra tokens at the end of '#pragma omp target teams' are ignored}}
36   foo();
37 #pragma omp target teams if (argc > 0 ? argv[1] : argv[2])
38   foo();
39 #pragma omp target teams if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target teams' cannot contain more than one 'if' clause}}
40   foo();
41 #pragma omp target teams if (S) // expected-error {{'S' does not refer to a value}}
42   foo();
43 #pragma omp target teams if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
44   foo();
45 #pragma omp target teams if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
46   foo();
47 #pragma omp target teams if(argc)
48   foo();
49 #pragma omp target teams if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
50   foo();
51 #pragma omp target teams if(target : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
52   foo();
53 #pragma omp target teams if(target : argc)
54   foo();
55 #pragma omp target teams if(target : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target teams'}}
56   foo();
57 #pragma omp target teams if(target : argc) if (target:argc) // expected-error {{directive '#pragma omp target teams' cannot contain more than one 'if' clause with 'target' name modifier}}
58   foo();
59 #pragma omp target teams if(target : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
60   foo();
61 
62   return 0;
63 }
64 
main(int argc,char ** argv)65 int main(int argc, char **argv) {
66   int z;
67 #pragma omp target teams if // expected-error {{expected '(' after 'if'}}
68   foo();
69 #pragma omp target teams if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
70   foo();
71 #pragma omp target teams if () // expected-error {{expected expression}}
72   foo();
73 #pragma omp target teams if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
74   foo();
75 #pragma omp target teams if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target teams' are ignored}}
76   foo();
77 #pragma omp target teams if (argc > 0 ? argv[1] : argv[2])
78   foo();
79 #pragma omp target teams if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target teams' cannot contain more than one 'if' clause}}
80   foo();
81 #pragma omp target teams if (S1) // expected-error {{'S1' does not refer to a value}}
82   foo();
83 #pragma omp target teams if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
84   foo();
85 #pragma omp target teams if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
86   foo();
87 #pragma omp target teams if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
88   foo();
89 #pragma omp target teams if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
90   foo();
91 #pragma omp target teams if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
92   foo();
93 #pragma omp target teams if(target : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
94   foo();
95 #pragma omp target teams if(target : z)
96   foo();
97 #pragma omp target teams if(target : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target teams'}}
98   foo();
99 #pragma omp target teams if(target : argc) if (target:argc) // expected-error {{directive '#pragma omp target teams' cannot contain more than one 'if' clause with 'target' name modifier}}
100   foo();
101 #pragma omp target teams if(target : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
102   foo();
103 
104   return tmain(argc, argv);
105 }
106