blob: 96fa34cc2aff1982a0f9df40ea54e8b1ab078864 [file] [log] [blame]
Douglas Gregor3d7a12a2009-03-25 23:32:15 +00001// RUN: clang-cc -fsyntax-only -verify %s
2
3template<typename T, T Divisor>
4class X {
5public:
6 static const T value = 10 / Divisor; // expected-error{{in-class initializer is not an integral constant expression}}
7};
8
9int array1[X<int, 2>::value == 5? 1 : -1];
10X<int, 0> xi0; // expected-note{{in instantiation of template class 'class X<int, 0>' requested here}}
11
12
13template<typename T>
14class Y {
15 static const T value = 0; // expected-error{{'value' can only be initialized if it is a static const integral data member}}
16};
17
18Y<float> fy; // expected-note{{in instantiation of template class 'class Y<float>' requested here}}
Douglas Gregor65b90052009-07-27 17:43:39 +000019
20
21// out-of-line static member variables
22
23template<typename T>
24struct Z {
25 static T value;
26};
27
28template<typename T>
29T Z<T>::value; // expected-error{{no matching constructor}}
30
31struct DefCon {};
32
33struct NoDefCon {
34 NoDefCon(const NoDefCon&);
35};
36
37void test() {
38 DefCon &DC = Z<DefCon>::value;
39 NoDefCon &NDC = Z<NoDefCon>::value; // expected-note{{instantiation}}
Owen Anderson08e25242009-07-27 22:29:56 +000040}