[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / target_parallel_if_messages.cpp
blob0c86ee3ee3bd284e976cc902ce0a5fc6f93aa645
1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 %s -Wuninitialized
5 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
6 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
8 void foo() {
11 bool foobool(int argc) {
12 return argc;
15 void xxx(int argc) {
16 int cond; // expected-note {{initialize the variable 'cond' to silence this warning}}
17 #pragma omp target parallel if(cond) // expected-warning {{variable 'cond' is uninitialized when used here}}
18 for (int i = 0; i < 10; ++i)
22 struct S1; // expected-note {{declared here}}
24 template <class T, class S> // expected-note {{declared here}}
25 int tmain(T argc, S **argv) {
26 T z;
27 #pragma omp target parallel if // expected-error {{expected '(' after 'if'}}
28 foo();
29 #pragma omp target parallel if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
30 foo();
31 #pragma omp target parallel if () // expected-error {{expected expression}}
32 foo();
33 #pragma omp target parallel if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
34 foo();
35 #pragma omp target parallel if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}}
36 foo();
37 #pragma omp target parallel if (argc > 0 ? argv[1] : argv[2] + z)
38 foo();
39 #pragma omp target parallel if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause}}
40 foo();
41 #pragma omp target parallel if (S) // expected-error {{'S' does not refer to a value}}
42 foo();
43 #pragma omp target parallel if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
44 foo();
45 #pragma omp target parallel if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
46 foo();
47 #pragma omp target parallel if(argc)
48 foo();
49 #pragma omp target parallel if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
50 foo();
51 #pragma omp target parallel if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
52 foo();
53 #pragma omp target parallel if(target : argc)
54 foo();
55 #pragma omp target parallel if(parallel : argc)
56 foo();
57 #pragma omp target parallel if(target : argc) if(parallel : argc)
58 foo();
59 #pragma omp target parallel if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target parallel'}}
60 foo();
61 #pragma omp target parallel if(target : argc) if (target :argc) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause with 'target' name modifier}}
62 foo();
63 #pragma omp target parallel if(parallel : argc) if (parallel :argc) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause with 'parallel' name modifier}}
64 foo();
65 #pragma omp target parallel if(target : argc) if (argc) // expected-error {{expected 'parallel' directive name modifier}} expected-note {{previous clause with directive name modifier specified here}}
66 foo();
67 #pragma omp target parallel if(target : argc) if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}} expected-note {{previous clause with directive name modifier specified here}}
68 foo();
70 return 0;
73 int main(int argc, char **argv) {
74 int z;
75 #pragma omp target parallel if // expected-error {{expected '(' after 'if'}}
76 foo();
77 #pragma omp target parallel if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
78 foo();
79 #pragma omp target parallel if () // expected-error {{expected expression}}
80 foo();
81 #pragma omp target parallel if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
82 foo();
83 #pragma omp target parallel if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}}
84 foo();
85 #pragma omp target parallel if (argc > 0 ? argv[1] : argv[2])
86 foo();
87 #pragma omp target parallel if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause}}
88 foo();
89 #pragma omp target parallel if (S1) // expected-error {{'S1' does not refer to a value}}
90 foo();
91 #pragma omp target parallel if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
92 foo();
93 #pragma omp target parallel if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
94 foo();
95 #pragma omp target parallel if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
96 foo();
97 #pragma omp target parallel if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
98 foo();
99 #pragma omp target parallel if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
100 foo();
101 #pragma omp target parallel if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
102 foo();
103 #pragma omp target parallel if(parallel : argc * z)
104 foo();
105 #pragma omp target parallel if(target : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target parallel'}}
106 foo();
107 #pragma omp target parallel if(target : argc) if (target :argc) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause with 'target' name modifier}}
108 foo();
109 #pragma omp target parallel if(parallel : argc) if (parallel :argc) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause with 'parallel' name modifier}}
110 foo();
111 #pragma omp target parallel if(target : argc) if (argc) // expected-error {{expected 'parallel' directive name modifier}} expected-note {{previous clause with directive name modifier specified here}}
112 foo();
113 #pragma omp target parallel if(target : argc) if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}} expected-note {{previous clause with directive name modifier specified here}}
114 foo();
116 return tmain(argc, argv);