1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
2 
3 void foo() {
4 }
5 
6 bool foobool(int argc) {
7   return argc;
8 }
9 
10 struct S1; // expected-note {{declared here}}
11 
12 template <class T, class S> // expected-note {{declared here}}
13 int tmain(T argc, S **argv) {
14   #pragma omp parallel
15   {
16     #pragma omp cancel parallel if // expected-error {{expected '(' after 'if'}}
17     #pragma omp cancel parallel if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
18     #pragma omp cancel parallel if () // expected-error {{expected expression}}
19     #pragma omp cancel parallel if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
20     #pragma omp cancel parallel if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp cancel' are ignored}}
21     #pragma omp cancel parallel if (argc > 0 ? argv[1] : argv[2])
22     #pragma omp cancel parallel if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp cancel' cannot contain more than one 'if' clause}}
23     #pragma omp cancel parallel if (S) // expected-error {{'S' does not refer to a value}}
24     #pragma omp cancel parallel if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
25     #pragma omp cancel parallel if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
26     #pragma omp cancel parallel if(argc)
27     #pragma omp cancel parallel if(cancel // expected-warning {{missing ':' after directive name modifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
28     #pragma omp cancel parallel if(cancel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
29     #pragma omp cancel parallel if(cancel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
30     #pragma omp cancel parallel if(cancel : argc)
31     #pragma omp cancel parallel if(cancel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp cancel'}}
32     #pragma omp cancel parallel if(cancel : argc) if (cancel:argc) // expected-error {{directive '#pragma omp cancel' cannot contain more than one 'if' clause with 'cancel' name modifier}}
33     #pragma omp cancel parallel if(cancel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
34     foo();
35   }
36 
37   return 0;
38 }
39 
40 int main(int argc, char **argv) {
41   #pragma omp parallel
42   {
43     #pragma omp cancel parallel if // expected-error {{expected '(' after 'if'}}
44     #pragma omp cancel parallel if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
45     #pragma omp cancel parallel if () // expected-error {{expected expression}}
46     #pragma omp cancel parallel if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
47     #pragma omp cancel parallel if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp cancel' are ignored}}
48     #pragma omp cancel parallel if (argc > 0 ? argv[1] : argv[2])
49     #pragma omp cancel parallel if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp cancel' cannot contain more than one 'if' clause}}
50     #pragma omp cancel parallel if (S1) // expected-error {{'S1' does not refer to a value}}
51     #pragma omp cancel parallel if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
52     #pragma omp cancel parallel if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
53     #pragma omp cancel parallel if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
54     #pragma omp cancel parallel if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
55     #pragma omp cancel parallel if(cancel // expected-warning {{missing ':' after directive name modifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
56     #pragma omp cancel parallel if(cancel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
57     #pragma omp cancel parallel if(cancel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
58     #pragma omp cancel parallel if(cancel : argc)
59     #pragma omp cancel parallel if(cancel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp cancel'}}
60     #pragma omp cancel parallel if(cancel : argc) if (cancel:argc)  // expected-error {{directive '#pragma omp cancel' cannot contain more than one 'if' clause with 'cancel' name modifier}}
61     #pragma omp cancel parallel if(cancel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
62     foo();
63   }
64 
65   return tmain(argc, argv);
66 }
67