1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
5 template<typename T
, T Divisor
>
8 static const T value
= 10 / Divisor
; // expected-error{{in-class initializer for static data member is not a constant expression}}
11 int array1
[X
<int, 2>::value
== 5? 1 : -1];
12 X
<int, 0> xi0
; // expected-note{{in instantiation of template class 'X<int, 0>' requested here}}
17 static const T value
= 0;
18 #if __cplusplus <= 199711L
19 // expected-warning@-2 {{in-class initializer for static data member of type 'const float' is a GNU extension}}
21 // expected-error@-4 {{in-class initializer for static data member of type 'const float' requires 'constexpr' specifier}}
22 // expected-note@-5 {{add 'constexpr'}}
26 Y
<float> fy
; // expected-note{{in instantiation of template class 'Y<float>' requested here}}
29 // out-of-line static member variables
37 T Z
<T
>::value
; // expected-error{{no matching constructor}}
42 NoDefCon(const NoDefCon
&); // expected-note{{candidate constructor}}
46 DefCon
&DC
= Z
<DefCon
>::value
;
47 NoDefCon
&NDC
= Z
<NoDefCon
>::value
; // expected-note{{instantiation}}
52 ~X1(); // The errors won't be triggered without this dtor.
57 static char Helper(T
);
58 static const int value
= sizeof(Helper(T()));
72 static const int value
= sizeof(typeid(Helper()));
82 int y2
[Y2
<X2
>::value
];
91 ~Y3(); // The error isn't triggered without this dtor.
98 static const int value
= sizeof(T
);
102 Y3().Foo(X3
<SizeOf
<char>::value
>());
108 static const bool var
= false;
112 const bool X0
<T
>::var
;
115 struct X1
: public X0
<T
> {
116 static const bool var
= false;
120 const bool X1
<T
>::var
;
122 template class X0
<char>;
123 template class X1
<char>;
127 typedef char MyString
[100];
128 template <typename T
>
129 struct StaticVarWithTypedefString
{
132 template <typename T
>
133 MyString StaticVarWithTypedefString
<T
>::str
= "";
135 void testStaticVarWithTypedefString() {
136 (void)StaticVarWithTypedefString
<int>::str
;