1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _ 2 // RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp %s -Wuninitialized 3 4 // RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp-simd %s -Wuninitialized 5 6 struct B { 7 static int ib[20]; // expected-note 0 {{'B::ib' declared here}} 8 static constexpr int bfoo() { return 8; } 9 }; 10 namespace X { 11 B x; // expected-note {{'x' defined here}} 12 }; 13 constexpr int bfoo() { return 4; } 14 15 int **z; 16 const int C1 = 1; 17 const int C2 = 2; 18 void test_aligned_colons(int *&rp) 19 { 20 int *B = 0; 21 22 #pragma omp target 23 #pragma omp teams distribute simd aligned(B:bfoo()) 24 for (int i = 0; i < 10; ++i) ; 25 26 #pragma omp target 27 #pragma omp teams distribute simd aligned(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}} 28 for (int i = 0; i < 10; ++i) ; 29 30 #pragma omp target 31 #pragma omp teams distribute simd aligned(B:B::bfoo()) 32 for (int i = 0; i < 10; ++i) ; 33 34 #pragma omp target 35 #pragma omp teams distribute simd aligned(z:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}} 36 for (int i = 0; i < 10; ++i) ; 37 38 #pragma omp target 39 #pragma omp teams distribute simd aligned(B:B::bfoo()) 40 for (int i = 0; i < 10; ++i) ; 41 42 #pragma omp target 43 #pragma omp teams distribute simd aligned(X::x : ::z) // expected-error {{integral constant expression must have integral or unscoped enumeration type, not 'int **'}} expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'B'}} 44 for (int i = 0; i < 10; ++i) ; 45 46 #pragma omp target 47 #pragma omp teams distribute simd aligned(B,rp,::z: X::x) // expected-error {{integral constant expression must have integral or unscoped enumeration type, not 'B'}} 48 for (int i = 0; i < 10; ++i) ; 49 50 #pragma omp target 51 #pragma omp teams distribute simd aligned(::z) 52 for (int i = 0; i < 10; ++i) ; 53 54 #pragma omp target 55 #pragma omp teams distribute simd aligned(B::bfoo()) // expected-error {{expected variable name}} 56 for (int i = 0; i < 10; ++i) ; 57 58 #pragma omp target 59 #pragma omp teams distribute simd aligned(B::ib,B:C1+C2) // expected-warning {{aligned clause will be ignored because the requested alignment is not a power of 2}} 60 for (int i = 0; i < 10; ++i) ; 61 } 62 63 // expected-note@+1 {{'num' defined here}} 64 template<int L, class T, class N> T test_template(T* arr, N num) { 65 N i; 66 T sum = (T)0; 67 T ind2 = - num * L; 68 // Negative number is passed as L. 69 70 #pragma omp target 71 #pragma omp teams distribute simd aligned(arr:L) // expected-error {{argument to 'aligned' clause must be a strictly positive integer value}} 72 for (i = 0; i < num; ++i) { 73 T cur = arr[(int)ind2]; 74 ind2 += L; 75 sum += cur; 76 } 77 78 #pragma omp target 79 #pragma omp teams distribute simd aligned(num:4) // expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}} 80 for (i = 0; i < num; ++i); 81 82 return T(); 83 } 84 85 template<int LEN> int test_warn() { 86 int *ind2 = 0; 87 #pragma omp target 88 #pragma omp teams distribute simd aligned(ind2:LEN) // expected-error {{argument to 'aligned' clause must be a strictly positive integer value}} 89 for (int i = 0; i < 100; i++) { 90 ind2 += LEN; 91 } 92 return 0; 93 } 94 95 struct S1; // expected-note 2 {{declared here}} // expected-note {{forward declaration of 'S1'}} 96 extern S1 a; // expected-note {{'a' declared here}} 97 class S2 { 98 mutable int a; 99 public: 100 S2():a(0) { } 101 }; 102 const S2 b; // expected-note 1 {{'b' defined here}} 103 const S2 ba[5]; 104 class S3 { 105 int a; 106 public: 107 S3():a(0) { } 108 }; 109 const S3 ca[5]; 110 class S4 { 111 int a; 112 S4(); 113 public: 114 S4(int v):a(v) { } 115 }; 116 class S5 { 117 int a; 118 S5():a(0) {} 119 public: 120 S5(int v):a(v) { } 121 }; 122 123 S3 h; // expected-note 2 {{'h' defined here}} 124 #pragma omp threadprivate(h) 125 126 template<class I, class C> int foomain(I argc, C **argv) { 127 I e(argc); 128 I g(argc); 129 int i; // expected-note {{'i' defined here}} 130 // expected-note@+1 {{declared here}} 131 int &j = i; 132 133 #pragma omp target 134 #pragma omp teams distribute simd aligned // expected-error {{expected '(' after 'aligned'}} 135 for (I k = 0; k < argc; ++k) ++k; 136 137 #pragma omp target 138 #pragma omp teams distribute simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 139 for (I k = 0; k < argc; ++k) ++k; 140 141 #pragma omp target 142 #pragma omp teams distribute simd aligned () // expected-error {{expected expression}} 143 for (I k = 0; k < argc; ++k) ++k; 144 145 #pragma omp target 146 #pragma omp teams distribute simd aligned (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 147 for (I k = 0; k < argc; ++k) ++k; 148 149 #pragma omp target 150 #pragma omp teams distribute simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 151 for (I k = 0; k < argc; ++k) ++k; 152 153 // FIXME: Should argc really be a pointer? 154 #pragma omp target 155 #pragma omp teams distribute simd aligned (*argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 156 for (I k = 0; k < argc; ++k) ++k; 157 158 #pragma omp target 159 #pragma omp teams distribute simd aligned (argc : 5) // expected-warning {{aligned clause will be ignored because the requested alignment is not a power of 2}} 160 for (I k = 0; k < argc; ++k) ++k; 161 162 #pragma omp target 163 #pragma omp teams distribute simd aligned (S1) // expected-error {{'S1' does not refer to a value}} 164 for (I k = 0; k < argc; ++k) ++k; 165 166 #pragma omp target 167 #pragma omp teams distribute simd aligned (argv[1]) // expected-error {{expected variable name}} 168 for (I k = 0; k < argc; ++k) ++k; 169 170 #pragma omp target 171 #pragma omp teams distribute simd aligned(e, g) 172 for (I k = 0; k < argc; ++k) ++k; 173 174 #pragma omp target 175 #pragma omp teams distribute simd aligned(h) // expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}} 176 for (I k = 0; k < argc; ++k) ++k; 177 178 #pragma omp target 179 #pragma omp teams distribute simd aligned(i) // expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}} 180 for (I k = 0; k < argc; ++k) ++k; 181 182 #pragma omp parallel 183 { 184 int *v = 0; 185 I i; 186 #pragma omp target 187 #pragma omp teams distribute simd aligned(v:16) 188 for (I k = 0; k < argc; ++k) { i = k; v += 2; } 189 } 190 float *f; 191 192 #pragma omp target 193 #pragma omp teams distribute simd aligned(f) 194 for (I k = 0; k < argc; ++k) ++k; 195 196 int v = 0; 197 198 #pragma omp target 199 #pragma omp teams distribute simd aligned(f:j) // expected-note {{initializer of 'j' is not a constant expression}} expected-error {{integral constant expression}} 200 201 for (I k = 0; k < argc; ++k) { ++k; v += j; } 202 203 #pragma omp target 204 #pragma omp teams distribute simd aligned(f) 205 for (I k = 0; k < argc; ++k) ++k; 206 207 return 0; 208 } 209 210 // expected-note@+1 2 {{'argc' defined here}} 211 int main(int argc, char **argv) { 212 double darr[100]; 213 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}} 214 test_template<-4>(darr, 4); 215 test_warn<4>(); // ok 216 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}} 217 test_warn<0>(); 218 219 int i; 220 int &j = i; 221 222 #pragma omp target 223 #pragma omp teams distribute simd aligned // expected-error {{expected '(' after 'aligned'}} 224 for (int k = 0; k < argc; ++k) ++k; 225 226 #pragma omp target 227 #pragma omp teams distribute simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 228 for (int k = 0; k < argc; ++k) ++k; 229 230 #pragma omp target 231 #pragma omp teams distribute simd aligned () // expected-error {{expected expression}} 232 for (int k = 0; k < argc; ++k) ++k; 233 234 #pragma omp target 235 #pragma omp teams distribute simd aligned (argv // expected-error {{expected ')'}} expected-note {{to match this '('}} 236 for (int k = 0; k < argc; ++k) ++k; 237 238 #pragma omp target 239 #pragma omp teams distribute simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}} 240 for (int k = 0; k < argc; ++k) ++k; 241 242 #pragma omp target 243 #pragma omp teams 244 #pragma omp distribute simd aligned (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 245 for (int k = 0; k < argc; ++k) ++k; 246 247 #pragma omp target 248 #pragma omp teams 249 #pragma omp distribute simd aligned (argc) // expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}} 250 for (int k = 0; k < argc; ++k) ++k; 251 252 #pragma omp target 253 #pragma omp teams distribute simd aligned (S1) // expected-error {{'S1' does not refer to a value}} 254 for (int k = 0; k < argc; ++k) ++k; 255 256 #pragma omp target 257 #pragma omp teams distribute simd aligned (a, b) // expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S1'}} expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S2'}} expected-error {{incomplete type 'S1' where a complete type is required}} 258 for (int k = 0; k < argc; ++k) ++k; 259 260 #pragma omp target 261 #pragma omp teams distribute simd aligned (argv[1]) // expected-error {{expected variable name}} 262 for (int k = 0; k < argc; ++k) ++k; 263 264 #pragma omp target 265 #pragma omp teams distribute simd aligned(h) // expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}} 266 for (int k = 0; k < argc; ++k) ++k; 267 268 int *pargc = &argc; 269 // expected-note@+1 {{in instantiation of function template specialization 'foomain<int *, char>' requested here}} 270 foomain<int*,char>(pargc,argv); 271 return 0; 272 } 273 274