1// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify 2 3struct A { 4 constexpr A() : a(b + 1), b(a + 1) {} // expected-note {{outside its lifetime}} 5 int a; 6 int b; 7}; 8struct B { 9 A a; 10}; 11 12constexpr A a; // ok, zero initialization preceeds static initialization 13void f() { 14 constexpr A a; // expected-error {{constant expression}} expected-note {{in call to 'A()'}} 15} 16 17constexpr B b1; // expected-error {{requires a user-provided default constructor}} 18constexpr B b2 = B(); // ok 19static_assert(b2.a.a == 1, ""); 20static_assert(b2.a.b == 2, ""); 21 22struct C { 23 int c; 24}; 25struct D : C { int d; }; 26constexpr C c1; // expected-error {{requires a user-provided default constructor}} 27constexpr C c2 = C(); // ok 28constexpr D d1; // expected-error {{requires a user-provided default constructor}} 29constexpr D d2 = D(); // ok with DR1452 30static_assert(D().c == 0, ""); 31static_assert(D().d == 0, ""); 32 33struct V : virtual C {}; 34template<typename T> struct Z : T { 35 constexpr Z() : V() {} 36}; 37constexpr int n = Z<V>().c; // expected-error {{constant expression}} expected-note {{virtual base class}} 38