Eli Friedman | c149412 | 2009-06-11 01:11:20 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
| 2 | |
| 3 | template<int i> struct x { |
| 4 | static const int j = i; |
| 5 | x<j>* y; |
| 6 | }; |
| 7 | |
Douglas Gregor | cf3293e | 2009-11-01 20:32:48 +0000 | [diff] [blame^] | 8 | template<int i> |
| 9 | const int x<i>::j; |
| 10 | |
| 11 | int array0[x<2>::j]; |
| 12 | |
| 13 | |
| 14 | template<typename T> |
| 15 | struct X0 { |
| 16 | static const unsigned value = sizeof(T); |
| 17 | }; |
| 18 | |
| 19 | template<typename T> |
| 20 | const unsigned X0<T>::value; |
| 21 | |
| 22 | int array1[X0<int>::value == sizeof(int)? 1 : -1]; |
| 23 | |
| 24 | const unsigned& testX0() { return X0<int>::value; } |
| 25 | |
| 26 | int array2[X0<int>::value == sizeof(int)? 1 : -1]; |
| 27 | |
| 28 | template<typename T> |
| 29 | struct X1 { |
| 30 | static const unsigned value; |
| 31 | }; |
| 32 | |
| 33 | template<typename T> |
| 34 | const unsigned X1<T>::value = sizeof(T); |
| 35 | |
| 36 | int array3[X1<int>::value == sizeof(int)? 1 : -1]; // expected-error{{variable length arrays are not permitted in C++}} \ |
| 37 | // expected-error{{variable length array declaration not allowed at file scope}} |