1// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
2
3void foo() {
4}
5
6bool foobool(int argc) {
7  return argc;
8}
9
10struct S1; // expected-note {{declared here}}
11
12template <class T, class S> // expected-note {{declared here}}
13int tmain(T argc, S **argv) {
14  #pragma omp parallel sections if // expected-error {{expected '(' after 'if'}}
15  {
16    foo();
17  }
18  #pragma omp parallel sections if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
19  {
20    foo();
21  }
22  #pragma omp parallel sections if () // expected-error {{expected expression}}
23  {
24    foo();
25  }
26  #pragma omp parallel sections if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
27  {
28    foo();
29  }
30  #pragma omp parallel sections if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
31  {
32    foo();
33  }
34  #pragma omp parallel sections if (argc > 0 ? argv[1] : argv[2])
35  {
36    foo();
37  }
38  #pragma omp parallel sections if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp parallel sections' cannot contain more than one 'if' clause}}
39  {
40    foo();
41  }
42  #pragma omp parallel sections if (S) // expected-error {{'S' does not refer to a value}}
43  {
44    foo();
45  }
46  #pragma omp parallel sections if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
47  {
48    foo();
49  }
50  #pragma omp parallel sections if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
51  {
52    foo();
53  }
54  #pragma omp parallel sections if(argc)
55  {
56    foo();
57  }
58
59  return 0;
60}
61
62int main(int argc, char **argv) {
63  #pragma omp parallel sections if // expected-error {{expected '(' after 'if'}}
64  {
65    foo();
66  }
67  #pragma omp parallel sections if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
68  {
69    foo();
70  }
71  #pragma omp parallel sections if () // expected-error {{expected expression}}
72  {
73    foo();
74  }
75  #pragma omp parallel sections if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
76  {
77    foo();
78  }
79  #pragma omp parallel sections if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
80  {
81    foo();
82  }
83  #pragma omp parallel sections if (argc > 0 ? argv[1] : argv[2])
84  {
85    foo();
86  }
87  #pragma omp parallel sections if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp parallel sections' cannot contain more than one 'if' clause}}
88  {
89    foo();
90  }
91  #pragma omp parallel sections if (S1) // expected-error {{'S1' does not refer to a value}}
92  {
93    foo();
94  }
95  #pragma omp parallel sections if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
96  {
97    foo();
98  }
99  #pragma omp parallel sections if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
100  {
101    foo();
102  }
103  #pragma omp parallel sections if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
104  {
105    foo();
106  }
107  #pragma omp parallel sections if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
108  {
109    foo();
110  }
111
112  return tmain(argc, argv);
113}
114