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