1 // RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp %s 2 3 struct B { 4 static int ib[20]; // expected-note 0 {{'B::ib' declared here}} 5 static constexpr int bfoo() { return 8; } 6 }; 7 namespace X { 8 B x; // expected-note {{'x' defined here}} 9 }; 10 constexpr int bfoo() { return 4; } 11 12 int **z; 13 const int C1 = 1; 14 const int C2 = 2; 15 void test_aligned_colons(int *&rp) 16 { 17 int *B = 0; 18 #pragma omp taskloop simd aligned(B:bfoo()) 19 for (int i = 0; i < 10; ++i) ; 20 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}} 21 #pragma omp taskloop simd aligned(B::ib:B:bfoo()) 22 for (int i = 0; i < 10; ++i) ; 23 #pragma omp taskloop simd aligned(B:B::bfoo()) 24 for (int i = 0; i < 10; ++i) ; 25 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}} 26 #pragma omp taskloop simd aligned(z:B:bfoo()) 27 for (int i = 0; i < 10; ++i) ; 28 #pragma omp taskloop simd aligned(B:B::bfoo()) 29 for (int i = 0; i < 10; ++i) ; 30 // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'int **'}} 31 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'B'}} 32 #pragma omp taskloop simd aligned(X::x : ::z) 33 for (int i = 0; i < 10; ++i) ; 34 // expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'B'}} 35 #pragma omp taskloop simd aligned(B,rp,::z: X::x) 36 for (int i = 0; i < 10; ++i) ; 37 #pragma omp taskloop simd aligned(::z) 38 for (int i = 0; i < 10; ++i) ; 39 // expected-error@+1 {{expected variable name}} 40 #pragma omp taskloop simd aligned(B::bfoo()) 41 for (int i = 0; i < 10; ++i) ; 42 // expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}} 43 #pragma omp taskloop simd aligned(B::ib,B:C1+C2) 44 for (int i = 0; i < 10; ++i) ; 45 } 46 47 // expected-note@+1 {{'num' defined here}} 48 template<int L, class T, class N> T test_template(T* arr, N num) { 49 N i; 50 T sum = (T)0; 51 T ind2 = - num * L; 52 // Negative number is passed as L. 53 // expected-error@+1 {{argument to 'aligned' clause must be a strictly positive integer value}} 54 #pragma omp taskloop simd aligned(arr:L) 55 for (i = 0; i < num; ++i) { 56 T cur = arr[(int)ind2]; 57 ind2 += L; 58 sum += cur; 59 } 60 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}} 61 #pragma omp taskloop simd aligned(num:4) 62 for (i = 0; i < num; ++i); 63 return T(); 64 } 65 66 template<int LEN> int test_warn() { 67 int *ind2 = 0; 68 // expected-error@+1 {{argument to 'aligned' clause must be a strictly positive integer value}} 69 #pragma omp taskloop simd aligned(ind2:LEN) 70 for (int i = 0; i < 100; i++) { 71 ind2 += LEN; 72 } 73 return 0; 74 } 75 76 struct S1; // expected-note 2 {{declared here}} 77 extern S1 a; // expected-note {{'a' declared here}} 78 class S2 { 79 mutable int a; 80 public: 81 S2():a(0) { } 82 }; 83 const S2 b; // expected-note 1 {{'b' defined here}} 84 const S2 ba[5]; 85 class S3 { 86 int a; 87 public: 88 S3():a(0) { } 89 }; 90 const S3 ca[5]; 91 class S4 { 92 int a; 93 S4(); 94 public: 95 S4(int v):a(v) { } 96 }; 97 class S5 { 98 int a; 99 S5():a(0) {} 100 public: 101 S5(int v):a(v) { } 102 }; 103 104 S3 h; // expected-note 2 {{'h' defined here}} 105 #pragma omp threadprivate(h) 106 107 template<class I, class C> int foomain(I argc, C **argv) { 108 I e(argc); 109 I g(argc); 110 int i; // expected-note {{declared here}} expected-note {{'i' defined here}} 111 // expected-note@+2 {{declared here}} 112 // expected-note@+1 {{reference to 'i' is not a constant expression}} 113 int &j = i; 114 #pragma omp taskloop simd aligned // expected-error {{expected '(' after 'aligned'}} 115 for (I k = 0; k < argc; ++k) ++k; 116 #pragma omp taskloop simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 117 for (I k = 0; k < argc; ++k) ++k; 118 #pragma omp taskloop simd aligned () // expected-error {{expected expression}} 119 for (I k = 0; k < argc; ++k) ++k; 120 #pragma omp taskloop simd aligned (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 121 for (I k = 0; k < argc; ++k) ++k; 122 #pragma omp taskloop simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 123 for (I k = 0; k < argc; ++k) ++k; 124 // FIXME: Should argc really be a pointer? 125 #pragma omp taskloop simd aligned (*argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 126 for (I k = 0; k < argc; ++k) ++k; 127 #pragma omp taskloop simd aligned (argc : 5) // expected-warning {{aligned clause will be ignored because the requested alignment is not a power of 2}} 128 for (I k = 0; k < argc; ++k) ++k; 129 #pragma omp taskloop simd aligned (S1) // expected-error {{'S1' does not refer to a value}} 130 for (I k = 0; k < argc; ++k) ++k; 131 #pragma omp taskloop simd aligned (argv[1]) // expected-error {{expected variable name}} 132 for (I k = 0; k < argc; ++k) ++k; 133 #pragma omp taskloop simd aligned(e, g) 134 for (I k = 0; k < argc; ++k) ++k; 135 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}} 136 #pragma omp taskloop simd aligned(h) 137 for (I k = 0; k < argc; ++k) ++k; 138 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}} 139 #pragma omp taskloop simd aligned(i) 140 for (I k = 0; k < argc; ++k) ++k; 141 #pragma omp parallel 142 { 143 int *v = 0; 144 I i; 145 #pragma omp taskloop simd aligned(v:16) 146 for (I k = 0; k < argc; ++k) { i = k; v += 2; } 147 } 148 float *f; 149 #pragma omp taskloop simd aligned(f) 150 for (I k = 0; k < argc; ++k) ++k; 151 int v = 0; 152 // expected-note@+2 {{initializer of 'j' is not a constant expression}} 153 // expected-error@+1 {{expression is not an integral constant expression}} 154 #pragma omp taskloop simd aligned(f:j) 155 for (I k = 0; k < argc; ++k) { ++k; v += j; } 156 #pragma omp taskloop simd aligned(f) 157 for (I k = 0; k < argc; ++k) ++k; 158 return 0; 159 } 160 161 // expected-note@+1 2 {{'argc' defined here}} 162 int main(int argc, char **argv) { 163 double darr[100]; 164 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}} 165 test_template<-4>(darr, 4); 166 test_warn<4>(); // ok 167 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}} 168 test_warn<0>(); 169 170 int i; 171 int &j = i; 172 #pragma omp taskloop simd aligned // expected-error {{expected '(' after 'aligned'}} 173 for (int k = 0; k < argc; ++k) ++k; 174 #pragma omp taskloop simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 175 for (int k = 0; k < argc; ++k) ++k; 176 #pragma omp taskloop simd aligned () // expected-error {{expected expression}} 177 for (int k = 0; k < argc; ++k) ++k; 178 #pragma omp taskloop simd aligned (argv // expected-error {{expected ')'}} expected-note {{to match this '('}} 179 for (int k = 0; k < argc; ++k) ++k; 180 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}} 181 #pragma omp taskloop simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 182 for (int k = 0; k < argc; ++k) ++k; 183 #pragma omp taskloop simd aligned (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 184 for (int k = 0; k < argc; ++k) ++k; 185 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}} 186 #pragma omp taskloop simd aligned (argc) 187 for (int k = 0; k < argc; ++k) ++k; 188 #pragma omp taskloop simd aligned (S1) // expected-error {{'S1' does not refer to a value}} 189 for (int k = 0; k < argc; ++k) ++k; 190 // expected-error@+2 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S1'}} 191 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S2'}} 192 #pragma omp taskloop simd aligned (a, b) 193 for (int k = 0; k < argc; ++k) ++k; 194 #pragma omp taskloop simd aligned (argv[1]) // expected-error {{expected variable name}} 195 for (int k = 0; k < argc; ++k) ++k; 196 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}} 197 #pragma omp taskloop simd aligned(h) 198 for (int k = 0; k < argc; ++k) ++k; 199 int *pargc = &argc; 200 // expected-note@+1 {{in instantiation of function template specialization 'foomain<int *, char>' requested here}} 201 foomain<int*,char>(pargc,argv); 202 return 0; 203 } 204 205