xref: /aosp_15_r20/external/clang/test/OpenMP/target_if_messages.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -verify -fopenmp %s
2*67e74705SXin Li 
foo()3*67e74705SXin Li void foo() {
4*67e74705SXin Li }
5*67e74705SXin Li 
foobool(int argc)6*67e74705SXin Li bool foobool(int argc) {
7*67e74705SXin Li   return argc;
8*67e74705SXin Li }
9*67e74705SXin Li 
10*67e74705SXin Li struct S1; // expected-note {{declared here}}
11*67e74705SXin Li 
12*67e74705SXin Li template <class T, class S> // expected-note {{declared here}}
tmain(T argc,S ** argv)13*67e74705SXin Li int tmain(T argc, S **argv) {
14*67e74705SXin Li   #pragma omp target if // expected-error {{expected '(' after 'if'}}
15*67e74705SXin Li   foo();
16*67e74705SXin Li   #pragma omp target if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
17*67e74705SXin Li   foo();
18*67e74705SXin Li   #pragma omp target if () // expected-error {{expected expression}}
19*67e74705SXin Li   foo();
20*67e74705SXin Li   #pragma omp target if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
21*67e74705SXin Li   foo();
22*67e74705SXin Li   #pragma omp target if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
23*67e74705SXin Li   foo();
24*67e74705SXin Li   #pragma omp target if (argc > 0 ? argv[1] : argv[2])
25*67e74705SXin Li   foo();
26*67e74705SXin Li   #pragma omp target if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target' cannot contain more than one 'if' clause}}
27*67e74705SXin Li   foo();
28*67e74705SXin Li   #pragma omp target if (S) // expected-error {{'S' does not refer to a value}}
29*67e74705SXin Li   foo();
30*67e74705SXin Li   #pragma omp target if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
31*67e74705SXin Li   foo();
32*67e74705SXin Li   #pragma omp target if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
33*67e74705SXin Li   foo();
34*67e74705SXin Li   #pragma omp target if(argc)
35*67e74705SXin Li   foo();
36*67e74705SXin Li   #pragma omp target if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
37*67e74705SXin Li   foo();
38*67e74705SXin Li   #pragma omp target if(target : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
39*67e74705SXin Li   foo();
40*67e74705SXin Li   #pragma omp target if(target : argc)
41*67e74705SXin Li   foo();
42*67e74705SXin Li   #pragma omp target if(target : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target'}}
43*67e74705SXin Li   foo();
44*67e74705SXin Li   #pragma omp target if(target : argc) if (target:argc) // expected-error {{directive '#pragma omp target' cannot contain more than one 'if' clause with 'target' name modifier}}
45*67e74705SXin Li   foo();
46*67e74705SXin Li   #pragma omp target if(target : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
47*67e74705SXin Li   foo();
48*67e74705SXin Li 
49*67e74705SXin Li   return 0;
50*67e74705SXin Li }
51*67e74705SXin Li 
main(int argc,char ** argv)52*67e74705SXin Li int main(int argc, char **argv) {
53*67e74705SXin Li   #pragma omp target if // expected-error {{expected '(' after 'if'}}
54*67e74705SXin Li   foo();
55*67e74705SXin Li   #pragma omp target if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
56*67e74705SXin Li   foo();
57*67e74705SXin Li   #pragma omp target if () // expected-error {{expected expression}}
58*67e74705SXin Li   foo();
59*67e74705SXin Li   #pragma omp target if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
60*67e74705SXin Li   foo();
61*67e74705SXin Li   #pragma omp target if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
62*67e74705SXin Li   foo();
63*67e74705SXin Li   #pragma omp target if (argc > 0 ? argv[1] : argv[2])
64*67e74705SXin Li   foo();
65*67e74705SXin Li   #pragma omp target if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target' cannot contain more than one 'if' clause}}
66*67e74705SXin Li   foo();
67*67e74705SXin Li   #pragma omp target if (S1) // expected-error {{'S1' does not refer to a value}}
68*67e74705SXin Li   foo();
69*67e74705SXin Li   #pragma omp target if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
70*67e74705SXin Li   foo();
71*67e74705SXin Li   #pragma omp target if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
72*67e74705SXin Li   foo();
73*67e74705SXin Li   #pragma omp target if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
74*67e74705SXin Li   foo();
75*67e74705SXin Li   #pragma omp target if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
76*67e74705SXin Li   foo();
77*67e74705SXin Li   #pragma omp target if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
78*67e74705SXin Li   foo();
79*67e74705SXin Li   #pragma omp target if(target : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
80*67e74705SXin Li   foo();
81*67e74705SXin Li   #pragma omp target if(target : argc)
82*67e74705SXin Li   foo();
83*67e74705SXin Li   #pragma omp target if(target : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target'}}
84*67e74705SXin Li   foo();
85*67e74705SXin Li   #pragma omp target if(target : argc) if (target:argc) // expected-error {{directive '#pragma omp target' cannot contain more than one 'if' clause with 'target' name modifier}}
86*67e74705SXin Li   foo();
87*67e74705SXin Li   #pragma omp target if(target : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
88*67e74705SXin Li   foo();
89*67e74705SXin Li 
90*67e74705SXin Li   return tmain(argc, argv);
91*67e74705SXin Li }
92