1 // RUN: %clang_cc1 -std=c++1y %s -verify
3 namespace in_class_init
{
4 union U
{ char c
; double d
= 4.0; };
7 constexpr U u3
{ 'x' };
8 static_assert(u1
.d
== 4.0, "");
9 static_assert(u2
.d
== 4.0, "");
10 static_assert(u3
.c
== 'x', "");
22 constexpr A a3
{ 1, 2, { 3 } };
23 constexpr A a4
{ 1, 2, { .d
= 3.0 } };
24 static_assert(a1
.d
== 4.0, "");
25 static_assert(a2
.m
== 24, "");
26 static_assert(a2
.d
== 4.0, "");
27 static_assert(a3
.c
== 3, "");
28 static_assert(a3
.d
== 4.0, ""); // expected-error {{constant expression}} expected-note {{active member 'c'}}
29 static_assert(a4
.d
== 3.0, "");
33 constexpr int f() { return n
* 5; }
39 static_assert(b2
.m
== 10, "");
44 int l
= k
; // expected-error {{invalid use of non-static}}
49 namespace nested_aggregate_init
{
55 constexpr B(int k
) : d(1.23), k(k
) {}
56 // Within this aggregate, both this object's 'this' and the temporary's
58 constexpr int f() const { return A
{k
}.b
; }
62 static_assert(B(6).f() == 18, "");
68 FibTree
*l
= // expected-note {{declared here}}
69 n
> 1 ? new FibTree
{n
-1} : &fib0
; // expected-error {{default member initializer for 'l' needed}}
70 FibTree
*r
= // expected-note {{declared here}}
71 n
> 2 ? new FibTree
{n
-2} : &fib0
; // expected-error {{default member initializer for 'r' needed}}
76 FibTree
FibTree::fib0
{0, nullptr, nullptr, 1};
78 int fib(int n
) { return FibTree
{n
}.v
; }