| 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 |
| 4 |
|
| 5 |
#ifdef WITHDEF |
| 6 |
typedef void *omp_interop_t; |
| 7 |
|
| 8 |
void foo(int *Ap) { |
| 9 |
omp_interop_t InteropVar; |
| 10 |
omp_interop_t Another; |
| 11 |
|
| 12 |
//expected-error@+1 {{expected interop type: 'target' and/or 'targetsync'}} |
| 13 |
#pragma omp interop init(target,foo:InteropVar) init(target:Another) |
| 14 |
|
| 15 |
//expected-error@+1 {{use of undeclared identifier 'NoDeclVar'}} |
| 16 |
#pragma omp interop init(target:NoDeclVar) init(target:Another) |
| 17 |
|
| 18 |
//expected-error@+1 {{use of undeclared identifier 'NoDeclVar'}} |
| 19 |
#pragma omp interop use(NoDeclVar) use(Another) |
| 20 |
|
| 21 |
//expected-error@+1 {{use of undeclared identifier 'NoDeclVar'}} |
| 22 |
#pragma omp interop destroy(NoDeclVar) destroy(Another) |
| 23 |
|
| 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) |
| 27 |
|
| 28 |
//expected-warning@+1 {{missing ':' after interop types}} |
| 29 |
#pragma omp interop init(target InteropVar) |
| 30 |
|
| 31 |
//expected-error@+1 {{expected expression}} |
| 32 |
#pragma omp interop init(prefer_type(1,+,3),target:InteropVar) \ |
| 33 |
init(target:Another) |
| 34 |
|
| 35 |
int IntVar; |
| 36 |
struct S { int I; } SVar; |
| 37 |
|
| 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) |
| 41 |
|
| 42 |
//expected-error@+1 {{interop variable must be of type 'omp_interop_t'}} |
| 43 |
#pragma omp interop use(IntVar) use(Another) |
| 44 |
|
| 45 |
//expected-error@+1 {{interop variable must be of type 'omp_interop_t'}} |
| 46 |
#pragma omp interop destroy(IntVar) destroy(Another) |
| 47 |
|
| 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) |
| 51 |
|
| 52 |
//expected-error@+1 {{interop variable must be of type 'omp_interop_t'}} |
| 53 |
#pragma omp interop use(SVar) use(Another) |
| 54 |
|
| 55 |
//expected-error@+1 {{interop variable must be of type 'omp_interop_t'}} |
| 56 |
#pragma omp interop destroy(SVar) destroy(Another) |
| 57 |
|
| 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) |
| 61 |
|
| 62 |
//expected-error@+1 {{expected variable or static data member of type 'omp_interop_t'}} |
| 63 |
#pragma omp interop use(a+b) use(Another) |
| 64 |
|
| 65 |
//expected-error@+1 {{expected variable or static data member of type 'omp_interop_t'}} |
| 66 |
#pragma omp interop destroy(a+b) destroy(Another) |
| 67 |
|
| 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) |
| 71 |
|
| 72 |
//expected-error@+1 {{expected non-const variable of type 'omp_interop_t'}} |
| 73 |
#pragma omp interop destroy(C) destroy(Another) |
| 74 |
|
| 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) |
| 78 |
|
| 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) |
| 82 |
|
| 83 |
//expected-error@+1 {{expected at least one 'init', 'use', 'destroy', or 'nowait' clause for '#pragma omp interop'}} |
| 84 |
#pragma omp interop device(0) |
| 85 |
|
| 86 |
//expected-warning@+1 {{interop type 'target' cannot be specified more than once}} |
| 87 |
#pragma omp interop init(target,targetsync,target:InteropVar) |
| 88 |
|
| 89 |
//expected-error@+1 {{'depend' clause requires the 'targetsync' interop type}} |
| 90 |
#pragma omp interop init(target:InteropVar) depend(inout:Ap) |
| 91 |
|
| 92 |
//expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}} |
| 93 |
#pragma omp interop init(target:InteropVar) init(target:InteropVar) |
| 94 |
|
| 95 |
//expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}} |
| 96 |
#pragma omp interop use(InteropVar) use(InteropVar) |
| 97 |
|
| 98 |
//expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}} |
| 99 |
#pragma omp interop destroy(InteropVar) destroy(InteropVar) |
| 100 |
|
| 101 |
//expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}} |
| 102 |
#pragma omp interop init(target:InteropVar) use(InteropVar) |
| 103 |
|
| 104 |
//expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}} |
| 105 |
#pragma omp interop init(target:InteropVar) destroy(InteropVar) |
| 106 |
|
| 107 |
//expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}} |
| 108 |
#pragma omp interop use(InteropVar) destroy(InteropVar) |
| 109 |
|
| 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) |
| 112 |
|
| 113 |
//expected-error@+1 {{argument to 'device' clause must be a non-negative integer value}} |
| 114 |
#pragma omp interop init(target:InteropVar) device(-4) |
| 115 |
|
| 116 |
//expected-error@+1 {{directive '#pragma omp interop' cannot contain more than one 'nowait' clause}} |
| 117 |
#pragma omp interop nowait init(target:InteropVar) nowait |
| 118 |
} |
| 119 |
|
| 120 |
struct S { |
| 121 |
void foo(); |
| 122 |
omp_interop_t InteropVar; |
| 123 |
omp_interop_t func(); |
| 124 |
static omp_interop_t sfunc(); |
| 125 |
}; |
| 126 |
|
| 127 |
struct T { |
| 128 |
static void static_member_func(); |
| 129 |
}; |
| 130 |
|
| 131 |
void T::static_member_func() { |
| 132 |
S s; |
| 133 |
omp_interop_t o; |
| 134 |
|
| 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) |
| 137 |
} |
| 138 |
|
| 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) |
| 142 |
|
| 143 |
//expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}} |
| 144 |
#pragma omp interop use(InteropVar) use(InteropVar) |
| 145 |
|
| 146 |
//expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}} |
| 147 |
#pragma omp interop destroy(InteropVar) destroy(InteropVar) |
| 148 |
|
| 149 |
//expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}} |
| 150 |
#pragma omp interop init(target:InteropVar) use(InteropVar) |
| 151 |
|
| 152 |
//expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}} |
| 153 |
#pragma omp interop init(target:InteropVar) destroy(InteropVar) |
| 154 |
|
| 155 |
//expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}} |
| 156 |
#pragma omp interop use(InteropVar) destroy(InteropVar) |
| 157 |
|
| 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()) |
| 160 |
|
| 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()) |
| 163 |
} |
| 164 |
|
| 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) |
| 170 |
|
| 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) |
| 173 |
} |
| 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 |
| 184 |
} |
| 185 |
#endif |
| 186 |
#ifdef CTEST |
| 187 |
typedef void *omp_interop_t; |
| 188 |
omp_interop_t bar(); |
| 189 |
struct S { |
| 190 |
omp_interop_t o; |
| 191 |
}; |
| 192 |
void foo() { |
| 193 |
omp_interop_t o; |
| 194 |
struct S s; |
| 195 |
|
| 196 |
//expected-error@+1 {{expected variable of type 'omp_interop_t'}} |
| 197 |
#pragma omp interop init(target:o) init(target:bar()) |
| 198 |
|
| 199 |
//expected-error@+1 {{expected variable of type 'omp_interop_t'}} |
| 200 |
#pragma omp interop init(target:o) init(target:s.o) |
| 201 |
} |
| 202 |
#endif |