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