blob: ab12b90f6c98ce231383f763852dfbaa6f74ecc4 [file] [log] [blame]
Eli Friedmanc1494122009-06-11 01:11:20 +00001// RUN: clang-cc -fsyntax-only -verify %s
2
3template<int i> struct x {
4 static const int j = i;
5 x<j>* y;
6};
7
Douglas Gregorcf3293e2009-11-01 20:32:48 +00008template<int i>
9const int x<i>::j;
10
11int array0[x<2>::j];
12
13
14template<typename T>
15struct X0 {
16 static const unsigned value = sizeof(T);
17};
18
19template<typename T>
20const unsigned X0<T>::value;
21
22int array1[X0<int>::value == sizeof(int)? 1 : -1];
23
24const unsigned& testX0() { return X0<int>::value; }
25
26int array2[X0<int>::value == sizeof(int)? 1 : -1];
27
28template<typename T>
29struct X1 {
30 static const unsigned value;
31};
32
33template<typename T>
34const unsigned X1<T>::value = sizeof(T);
35
36int 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}}