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