1 // RUN: %clang_cc1 -verify -std=c++11 %s
3 // Unlike in C++98, C++11 allows unions to have static data members.
6 static constexpr int k1
= 0;
7 static const int k2
= k1
;
8 static int k3
= k2
; // expected-error {{non-const static data member must be initialized out of line}}
9 static constexpr double k4
= k2
;
10 static const double k5
= k4
; // expected-error {{requires 'constexpr' specifier}} expected-note {{add 'constexpr'}}
27 template<typename T
> constexpr int U2
<T
>::k1
= sizeof(U2
<T
>);
28 template<typename T
> double U2
<T
>::k2
= 5.3;
30 static_assert(U2
<int>::k1
== sizeof(int), "");
31 static_assert(U2
<char>::k1
== sizeof(char), "");
35 U3() : k(0) {} // expected-error {{does not name a non-static data member}}
40 static const int n
; // expected-error {{static data member 'n' not allowed in anonymous union}}
46 static const int k
; // expected-error {{static data member 'k' not allowed in anonymous union}}