[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / interop_messages.cpp
blob8707b5d89cf38fc404ca43e6a903297bc59a7ac6
1 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 -o - -DWITHDEF %s
2 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 -o - -DWITHOUTDEF %s
3 // RUN: %clang_cc1 -verify -fopenmp -std=c99 -x c -o - -DCTEST %s
5 #ifdef WITHDEF
6 typedef void *omp_interop_t;
8 void foo(int *Ap) {
9 omp_interop_t InteropVar;
10 omp_interop_t Another;
12 //expected-error@+1 {{expected interop type: 'target' and/or 'targetsync'}}
13 #pragma omp interop init(target,foo:InteropVar) init(target:Another)
15 //expected-error@+1 {{use of undeclared identifier 'NoDeclVar'}}
16 #pragma omp interop init(target:NoDeclVar) init(target:Another)
18 //expected-error@+1 {{use of undeclared identifier 'NoDeclVar'}}
19 #pragma omp interop use(NoDeclVar) use(Another)
21 //expected-error@+1 {{use of undeclared identifier 'NoDeclVar'}}
22 #pragma omp interop destroy(NoDeclVar) destroy(Another)
24 //expected-error@+2 {{expected interop type: 'target' and/or 'targetsync'}}
25 //expected-error@+1 {{expected expression}}
26 #pragma omp interop init(InteropVar) init(target:Another)
28 //expected-warning@+1 {{missing ':' after interop types}}
29 #pragma omp interop init(target InteropVar)
31 //expected-error@+1 {{expected expression}}
32 #pragma omp interop init(prefer_type(1,+,3),target:InteropVar) \
33 init(target:Another)
35 int IntVar;
36 struct S { int I; } SVar;
38 //expected-error@+1 {{interop variable must be of type 'omp_interop_t'}}
39 #pragma omp interop init(prefer_type(1,"sycl",3),target:IntVar) \
40 init(target:Another)
42 //expected-error@+1 {{interop variable must be of type 'omp_interop_t'}}
43 #pragma omp interop use(IntVar) use(Another)
45 //expected-error@+1 {{interop variable must be of type 'omp_interop_t'}}
46 #pragma omp interop destroy(IntVar) destroy(Another)
48 //expected-error@+1 {{interop variable must be of type 'omp_interop_t'}}
49 #pragma omp interop init(prefer_type(1,"sycl",3),target:SVar) \
50 init(target:Another)
52 //expected-error@+1 {{interop variable must be of type 'omp_interop_t'}}
53 #pragma omp interop use(SVar) use(Another)
55 //expected-error@+1 {{interop variable must be of type 'omp_interop_t'}}
56 #pragma omp interop destroy(SVar) destroy(Another)
58 int a, b;
59 //expected-error@+1 {{expected variable or static data member of type 'omp_interop_t'}}
60 #pragma omp interop init(target:a+b) init(target:Another)
62 //expected-error@+1 {{expected variable or static data member of type 'omp_interop_t'}}
63 #pragma omp interop use(a+b) use(Another)
65 //expected-error@+1 {{expected variable or static data member of type 'omp_interop_t'}}
66 #pragma omp interop destroy(a+b) destroy(Another)
68 const omp_interop_t C = (omp_interop_t)5;
69 //expected-error@+1 {{expected non-const variable of type 'omp_interop_t'}}
70 #pragma omp interop init(target:C) init(target:Another)
72 //expected-error@+1 {{expected non-const variable of type 'omp_interop_t'}}
73 #pragma omp interop destroy(C) destroy(Another)
75 //expected-error@+1 {{prefer_list item must be a string literal or constant integral expression}}
76 #pragma omp interop init(prefer_type(1.0),target:InteropVar) \
77 init(target:Another)
79 //expected-error@+1 {{prefer_list item must be a string literal or constant integral expression}}
80 #pragma omp interop init(prefer_type(a),target:InteropVar) \
81 init(target:Another)
83 //expected-error@+1 {{expected at least one 'init', 'use', 'destroy', or 'nowait' clause for '#pragma omp interop'}}
84 #pragma omp interop device(0)
86 //expected-warning@+1 {{interop type 'target' cannot be specified more than once}}
87 #pragma omp interop init(target,targetsync,target:InteropVar)
89 //expected-error@+1 {{'depend' clause requires the 'targetsync' interop type}}
90 #pragma omp interop init(target:InteropVar) depend(inout:Ap)
92 //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
93 #pragma omp interop init(target:InteropVar) init(target:InteropVar)
95 //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
96 #pragma omp interop use(InteropVar) use(InteropVar)
98 //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
99 #pragma omp interop destroy(InteropVar) destroy(InteropVar)
101 //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
102 #pragma omp interop init(target:InteropVar) use(InteropVar)
104 //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
105 #pragma omp interop init(target:InteropVar) destroy(InteropVar)
107 //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
108 #pragma omp interop use(InteropVar) destroy(InteropVar)
110 //expected-error@+1 {{directive '#pragma omp interop' cannot contain more than one 'device' clause}}
111 #pragma omp interop init(target:InteropVar) device(0) device(1)
113 //expected-error@+1 {{argument to 'device' clause must be a non-negative integer value}}
114 #pragma omp interop init(target:InteropVar) device(-4)
116 //expected-error@+1 {{directive '#pragma omp interop' cannot contain more than one 'nowait' clause}}
117 #pragma omp interop nowait init(target:InteropVar) nowait
120 struct S {
121 void foo();
122 omp_interop_t InteropVar;
123 omp_interop_t func();
124 static omp_interop_t sfunc();
127 struct T {
128 static void static_member_func();
131 void T::static_member_func() {
132 S s;
133 omp_interop_t o;
135 //expected-error@+1 {{expected variable or static data member of type 'omp_interop_t'}}
136 #pragma omp interop init(target:s.InteropVar) init(target:o)
139 void S::foo() {
140 //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
141 #pragma omp interop init(target:InteropVar) init(target:InteropVar)
143 //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
144 #pragma omp interop use(InteropVar) use(InteropVar)
146 //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
147 #pragma omp interop destroy(InteropVar) destroy(InteropVar)
149 //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
150 #pragma omp interop init(target:InteropVar) use(InteropVar)
152 //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
153 #pragma omp interop init(target:InteropVar) destroy(InteropVar)
155 //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
156 #pragma omp interop use(InteropVar) destroy(InteropVar)
158 //expected-error@+1 {{expected variable, static data member, or non-static data member of current class of type 'omp_interop_t'}}
159 #pragma omp interop init(target:InteropVar) init(target:func())
161 //expected-error@+1 {{expected variable, static data member, or non-static data member of current class of type 'omp_interop_t'}}
162 #pragma omp interop init(target:InteropVar) init(target:sfunc())
165 void foo2() {
166 S s;
167 omp_interop_t another;
168 //expected-error@+1 {{expected variable or static data member of type 'omp_interop_t'}}
169 #pragma omp interop init(target:s.InteropVar) init(target:another)
171 //expected-error@+1 {{expected variable or static data member of type 'omp_interop_t'}}
172 #pragma omp interop init(target: S::sfunc()) init(target:another)
174 #endif
175 #ifdef WITHOUTDEF
176 void foo() {
177 int InteropVar;
178 //expected-error@+1 {{'omp_interop_t' type not found; include <omp.h>}}
179 #pragma omp interop init(prefer_type(1,"sycl",3),target:InteropVar) nowait
180 //expected-error@+1 {{'omp_interop_t' type not found; include <omp.h>}}
181 #pragma omp interop use(InteropVar) nowait
182 //expected-error@+1 {{'omp_interop_t' type not found; include <omp.h>}}
183 #pragma omp interop destroy(InteropVar) nowait
185 #endif
186 #ifdef CTEST
187 typedef void *omp_interop_t;
188 omp_interop_t bar();
189 struct S {
190 omp_interop_t o;
192 void foo() {
193 omp_interop_t o;
194 struct S s;
196 //expected-error@+1 {{expected variable of type 'omp_interop_t'}}
197 #pragma omp interop init(target:o) init(target:bar())
199 //expected-error@+1 {{expected variable of type 'omp_interop_t'}}
200 #pragma omp interop init(target:o) init(target:s.o)
202 #endif