[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / teams_distribute_parallel_for_simd_if_messages.cpp
blobbe013408dbb0b00147f89a94a387b5724fd1efe8
1 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,omp51 -fopenmp -ferror-limit 100 %s -Wuninitialized
4 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
5 // RUN: %clang_cc1 -verify=expected,omp51 -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
7 void foo() {
10 bool foobool(int argc) {
11 return argc;
14 void xxx(int argc) {
15 int cond; // expected-note {{initialize the variable 'cond' to silence this warning}}
16 #pragma omp target
17 #pragma omp teams distribute parallel for simd 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 i, z;
27 #pragma omp target
28 #pragma omp teams distribute parallel for simd if // expected-error {{expected '(' after 'if'}}
29 for (i = 0; i < argc; ++i) foo();
30 #pragma omp target
31 #pragma omp teams distribute parallel for simd if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
32 for (i = 0; i < argc; ++i) foo();
33 #pragma omp target
34 #pragma omp teams distribute parallel for simd if () // expected-error {{expected expression}}
35 for (i = 0; i < argc; ++i) foo();
36 #pragma omp target
37 #pragma omp teams distribute parallel for simd if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
38 for (i = 0; i < argc; ++i) foo();
39 #pragma omp target
40 #pragma omp teams distribute parallel for simd if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for simd' are ignored}}
41 for (i = 0; i < argc; ++i) foo();
42 #pragma omp target
43 #pragma omp teams distribute parallel for simd if (argc > 0 ? argv[1] : argv[2])
44 for (i = 0; i < argc; ++i) foo();
45 #pragma omp target
46 #pragma omp teams distribute parallel for simd if (foobool(argc)*z), if (true) // expected-error {{directive '#pragma omp teams distribute parallel for simd' cannot contain more than one 'if' clause}}
47 for (i = 0; i < argc; ++i) foo();
48 #pragma omp target
49 #pragma omp teams distribute parallel for simd if (S) // expected-error {{'S' does not refer to a value}}
50 for (i = 0; i < argc; ++i) foo();
51 #pragma omp target
52 #pragma omp teams distribute parallel for simd if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
53 for (i = 0; i < argc; ++i) foo();
54 #pragma omp target
55 #pragma omp teams distribute parallel for simd if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
56 for (i = 0; i < argc; ++i) foo();
57 #pragma omp target
58 #pragma omp teams distribute parallel for simd if(argc)
59 for (i = 0; i < argc; ++i) foo();
60 #pragma omp target
61 #pragma omp teams distribute parallel for simd if(parallel // expected-error {{use of undeclared identifier 'parallel'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
62 for (i = 0; i < argc; ++i) foo();
63 #pragma omp target
64 #pragma omp teams distribute parallel for simd if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
65 for (i = 0; i < argc; ++i) foo();
66 #pragma omp target
67 #pragma omp teams distribute parallel for simd if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
68 for (i = 0; i < argc; ++i) foo();
69 #pragma omp target
70 #pragma omp teams distribute parallel for simd if(parallel : argc)
71 for (i = 0; i < argc; ++i) foo();
72 #pragma omp target
73 #pragma omp teams distribute parallel for simd if(parallel : argc) if (simd:argc) // omp45-error {{directive name modifier 'simd' is not allowed for '#pragma omp teams distribute parallel for simd'}}
74 for (i = 0; i < argc; ++i) foo();
75 #pragma omp target
76 #pragma omp teams distribute parallel for simd if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp teams distribute parallel for simd' cannot contain more than one 'if' clause with 'parallel' name modifier}}
77 for (i = 0; i < argc; ++i) foo();
78 #pragma omp target
79 #pragma omp teams distribute parallel for simd if(parallel : argc) if (argc) // omp45-error {{no more 'if' clause is allowed}} omp51-error {{expected 'simd' directive name modifier}} expected-note {{previous clause with directive name modifier specified here}}
80 for (i = 0; i < argc; ++i) foo();
81 #pragma omp target
82 #pragma omp teams distribute parallel for simd if(distribute : argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp teams distribute parallel for simd'}}
83 for (i = 0; i < argc; ++i) foo();
85 return 0;
88 int main(int argc, char **argv) {
89 int i, z;
90 #pragma omp target
91 #pragma omp teams distribute parallel for simd if // expected-error {{expected '(' after 'if'}}
92 for (i = 0; i < argc; ++i) foo();
93 #pragma omp target
94 #pragma omp teams distribute parallel for simd if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
95 for (i = 0; i < argc; ++i) foo();
96 #pragma omp target
97 #pragma omp teams distribute parallel for simd if () // expected-error {{expected expression}}
98 for (i = 0; i < argc; ++i) foo();
99 #pragma omp target
100 #pragma omp teams distribute parallel for simd if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
101 for (i = 0; i < argc; ++i) foo();
102 #pragma omp target
103 #pragma omp teams distribute parallel for simd if (argc/z)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for simd' are ignored}}
104 for (i = 0; i < argc; ++i) foo();
105 #pragma omp target
106 #pragma omp teams distribute parallel for simd if (argc > 0 ? argv[1] : argv[2])
107 for (i = 0; i < argc; ++i) foo();
108 #pragma omp target
109 #pragma omp teams distribute parallel for simd if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp teams distribute parallel for simd' cannot contain more than one 'if' clause}}
110 for (i = 0; i < argc; ++i) foo();
111 #pragma omp target
112 #pragma omp teams distribute parallel for simd if (S1) // expected-error {{'S1' does not refer to a value}}
113 for (i = 0; i < argc; ++i) foo();
114 #pragma omp target
115 #pragma omp teams distribute parallel for simd if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
116 for (i = 0; i < argc; ++i) foo();
117 #pragma omp target
118 #pragma omp teams distribute parallel for simd if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
119 for (i = 0; i < argc; ++i) foo();
120 #pragma omp target
121 #pragma omp teams distribute parallel for simd if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
122 for (i = 0; i < argc; ++i) foo();
123 #pragma omp target
124 #pragma omp teams distribute parallel for simd if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
125 for (i = 0; i < argc; ++i) foo();
126 #pragma omp target
127 #pragma omp teams distribute parallel for simd if(parallel // expected-error {{use of undeclared identifier 'parallel'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
128 for (i = 0; i < argc; ++i) foo();
129 #pragma omp target
130 #pragma omp teams distribute parallel for simd if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
131 for (i = 0; i < argc; ++i) foo();
132 #pragma omp target
133 #pragma omp teams distribute parallel for simd if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
134 for (i = 0; i < argc; ++i) foo();
135 #pragma omp target
136 #pragma omp teams distribute parallel for simd if(parallel : argc)
137 for (i = 0; i < argc; ++i) foo();
138 #pragma omp target
139 #pragma omp teams distribute parallel for simd if(parallel : argc) if (simd:argc) // omp45-error {{directive name modifier 'simd' is not allowed for '#pragma omp teams distribute parallel for simd'}}
140 for (i = 0; i < argc; ++i) foo();
141 #pragma omp target
142 #pragma omp teams distribute parallel for simd if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp teams distribute parallel for simd' cannot contain more than one 'if' clause with 'parallel' name modifier}}
143 for (i = 0; i < argc; ++i) foo();
144 #pragma omp target
145 #pragma omp teams distribute parallel for simd if(parallel : argc) if (argc) //omp45-error {{no more 'if' clause is allowed}} omp51-error {{expected 'simd' directive name modifier}} expected-note {{previous clause with directive name modifier specified here}}
146 for (i = 0; i < argc; ++i) foo();
147 #pragma omp target
148 #pragma omp teams distribute parallel for simd if(distribute : argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp teams distribute parallel for simd'}}
149 for (i = 0; i < argc; ++i) foo();
151 return tmain(argc, argv);