blob: 0f3c08b05620b8a9fe7a848de3ca41a299ea26f3 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Eli Friedmanc1494122009-06-11 01:11:20 +00002template<int i> struct x {
3 static const int j = i;
4 x<j>* y;
5};
6
Douglas Gregorcf3293e2009-11-01 20:32:48 +00007template<int i>
8const int x<i>::j;
9
10int array0[x<2>::j];
11
Douglas Gregorcf3293e2009-11-01 20:32:48 +000012template<typename T>
13struct X0 {
14 static const unsigned value = sizeof(T);
15};
16
17template<typename T>
18const unsigned X0<T>::value;
19
20int array1[X0<int>::value == sizeof(int)? 1 : -1];
21
22const unsigned& testX0() { return X0<int>::value; }
23
24int array2[X0<int>::value == sizeof(int)? 1 : -1];
25
26template<typename T>
27struct X1 {
28 static const unsigned value;
29};
30
31template<typename T>
32const unsigned X1<T>::value = sizeof(T);
33
Douglas Gregor0fddb972010-05-22 16:17:30 +000034int array3[X1<int>::value == sizeof(int)? 1 : -1]; // expected-error{{variable length array declaration not allowed at file scope}}