[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / target_parallel_for_if_messages.cpp
blob857490be4d54c2128d1a5a62d9aa6b13ac8ddf62
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 for 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 int i;
27 T z;
28 #pragma omp target parallel for if // expected-error {{expected '(' after 'if'}}
29 for (i = 0; i < argc; ++i) foo();
30 #pragma omp target parallel for if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
31 for (i = 0; i < argc; ++i) foo();
32 #pragma omp target parallel for if () // expected-error {{expected expression}}
33 for (i = 0; i < argc; ++i) foo();
34 #pragma omp target parallel for if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
35 for (i = 0; i < argc; ++i) foo();
36 #pragma omp target parallel for if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}}
37 for (i = 0; i < argc; ++i) foo();
38 #pragma omp target parallel for if (argc > 0 ? argv[1] : argv[2])
39 for (i = 0; i < argc; ++i) foo();
40 #pragma omp target parallel for if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'if' clause}}
41 for (i = 0; i < argc; ++i) foo();
42 #pragma omp target parallel for if (S) // expected-error {{'S' does not refer to a value}}
43 for (i = 0; i < argc; ++i) foo();
44 #pragma omp target parallel for if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
45 for (i = 0; i < argc; ++i) foo();
46 #pragma omp target parallel for if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
47 for (i = 0; i < argc; ++i) foo();
48 #pragma omp target parallel for if(argc + z)
49 for (i = 0; i < argc; ++i) foo();
50 #pragma omp target parallel for if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
51 for (i = 0; i < argc; ++i) foo();
52 #pragma omp target parallel for if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
53 for (i = 0; i < argc; ++i) foo();
54 #pragma omp target parallel for if(target : argc)
55 for (i = 0; i < argc; ++i) foo();
56 #pragma omp target parallel for if(parallel : argc)
57 for (i = 0; i < argc; ++i) foo();
58 #pragma omp target parallel for if(target : argc) if(parallel : argc)
59 for (i = 0; i < argc; ++i) foo();
60 #pragma omp target parallel for if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target parallel for'}}
61 for (i = 0; i < argc; ++i) foo();
62 #pragma omp target parallel for if(target : argc) if (target :argc) // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'if' clause with 'target' name modifier}}
63 for (i = 0; i < argc; ++i) foo();
64 #pragma omp target parallel for if(parallel : argc) if (parallel :argc) // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}}
65 for (i = 0; i < argc; ++i) foo();
66 #pragma omp target parallel for if(target : argc) if (argc) // expected-error {{expected 'parallel' directive name modifier}} expected-note {{previous clause with directive name modifier specified here}}
67 for (i = 0; i < argc; ++i) foo();
68 #pragma omp target parallel for 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}}
69 for (i = 0; i < argc; ++i) foo();
71 return 0;
74 int main(int argc, char **argv) {
75 int i, z;
76 #pragma omp target parallel for if // expected-error {{expected '(' after 'if'}}
77 for (i = 0; i < argc; ++i) foo();
78 #pragma omp target parallel for if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
79 for (i = 0; i < argc; ++i) foo();
80 #pragma omp target parallel for if () // expected-error {{expected expression}}
81 for (i = 0; i < argc; ++i) foo();
82 #pragma omp target parallel for if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
83 for (i = 0; i < argc; ++i) foo();
84 #pragma omp target parallel for if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}}
85 for (i = 0; i < argc; ++i) foo();
86 #pragma omp target parallel for if (argc > 0 ? argv[1] : argv[2] - z)
87 for (i = 0; i < argc; ++i) foo();
88 #pragma omp target parallel for if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'if' clause}}
89 for (i = 0; i < argc; ++i) foo();
90 #pragma omp target parallel for if (S1) // expected-error {{'S1' does not refer to a value}}
91 for (i = 0; i < argc; ++i) foo();
92 #pragma omp target parallel for if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
93 for (i = 0; i < argc; ++i) foo();
94 #pragma omp target parallel for if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
95 for (i = 0; i < argc; ++i) foo();
96 #pragma omp target parallel for if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
97 for (i = 0; i < argc; ++i) foo();
98 #pragma omp target parallel for if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
99 for (i = 0; i < argc; ++i) foo();
100 #pragma omp target parallel for if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
101 for (i = 0; i < argc; ++i) foo();
102 #pragma omp target parallel for if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
103 for (i = 0; i < argc; ++i) foo();
104 #pragma omp target parallel for if(parallel : argc)
105 for (i = 0; i < argc; ++i) foo();
106 #pragma omp target parallel for if(target : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target parallel for'}}
107 for (i = 0; i < argc; ++i) foo();
108 #pragma omp target parallel for if(target : argc) if (target :argc) // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'if' clause with 'target' name modifier}}
109 for (i = 0; i < argc; ++i) foo();
110 #pragma omp target parallel for if(parallel : argc) if (parallel :argc) // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}}
111 for (i = 0; i < argc; ++i) foo();
112 #pragma omp target parallel for if(target : argc) if (argc) // expected-error {{expected 'parallel' directive name modifier}} expected-note {{previous clause with directive name modifier specified here}}
113 for (i = 0; i < argc; ++i) foo();
114 #pragma omp target parallel for 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}}
115 for (i = 0; i < argc; ++i) foo();
117 return tmain(argc, argv);