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