When printing a qualified type, look through a substituted template
[clang.git] / test / SemaTemplate / instantiate-static-var.cpp
blob0c06075248345cad3b29983398b72936ef9a061f
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 template<typename T, T Divisor>
3 class X {
4 public:
5 static const T value = 10 / Divisor; // expected-error{{in-class initializer is not a constant expression}}
6 };
8 int array1[X<int, 2>::value == 5? 1 : -1];
9 X<int, 0> xi0; // expected-note{{in instantiation of template class 'X<int, 0>' requested here}}
12 template<typename T>
13 class Y {
14 static const T value = 0; // expected-warning{{in-class initializer for static data member of type 'const float' is a C++0x extension}}
17 Y<float> fy; // expected-note{{in instantiation of template class 'Y<float>' requested here}}
20 // out-of-line static member variables
22 template<typename T>
23 struct Z {
24 static T value;
27 template<typename T>
28 T Z<T>::value; // expected-error{{no matching constructor}}
30 struct DefCon {};
32 struct NoDefCon {
33 NoDefCon(const NoDefCon&); // expected-note{{candidate constructor}}
36 void test() {
37 DefCon &DC = Z<DefCon>::value;
38 NoDefCon &NDC = Z<NoDefCon>::value; // expected-note{{instantiation}}
41 // PR5609
42 struct X1 {
43 ~X1(); // The errors won't be triggered without this dtor.
46 template <typename T>
47 struct Y1 {
48 static char Helper(T);
49 static const int value = sizeof(Helper(T()));
52 struct X2 {
53 virtual ~X2();
56 namespace std {
57 class type_info { };
60 template <typename T>
61 struct Y2 {
62 static T &Helper();
63 static const int value = sizeof(typeid(Helper()));
66 template <int>
67 struct Z1 {};
69 void Test() {
70 Z1<Y1<X1>::value> x;
71 int y[Y1<X1>::value];
72 Z1<Y2<X2>::value> x2;
73 int y2[Y2<X2>::value];
76 // PR5672
77 template <int n>
78 struct X3 {};
80 class Y3 {
81 public:
82 ~Y3(); // The error isn't triggered without this dtor.
84 void Foo(X3<1>);
87 template <typename T>
88 struct SizeOf {
89 static const int value = sizeof(T);
92 void MyTest3() {
93 Y3().Foo(X3<SizeOf<char>::value>());
96 namespace PR6449 {
97 template<typename T>
98 struct X0 {
99 static const bool var = false;
102 template<typename T>
103 const bool X0<T>::var;
105 template<typename T>
106 struct X1 : public X0<T> {
107 static const bool var = false;
110 template<typename T>
111 const bool X1<T>::var;
113 template class X0<char>;
114 template class X1<char>;