1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc struct X1 { // has no implicit default constructor 4*f4a2713aSLionel Sambuc X1(int); 5*f4a2713aSLionel Sambuc }; 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc struct X2 : X1 { // expected-note 2 {{'X2' declared here}} 8*f4a2713aSLionel Sambuc X2(int); 9*f4a2713aSLionel Sambuc }; 10*f4a2713aSLionel Sambuc 11*f4a2713aSLionel Sambuc struct X3 : public X2 { // expected-error {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}} 12*f4a2713aSLionel Sambuc }; 13*f4a2713aSLionel Sambuc X3 x3; // expected-note {{first required here}} 14*f4a2713aSLionel Sambuc 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc struct X4 { // expected-error {{must explicitly initialize the member 'x2'}} \ 17*f4a2713aSLionel Sambuc // expected-error {{must explicitly initialize the reference member 'rx2'}} 18*f4a2713aSLionel Sambuc X2 x2; // expected-note {{member is declared here}} 19*f4a2713aSLionel Sambuc X2 & rx2; // expected-note {{declared here}} 20*f4a2713aSLionel Sambuc }; 21*f4a2713aSLionel Sambuc 22*f4a2713aSLionel Sambuc X4 x4; // expected-note {{first required here}} 23*f4a2713aSLionel Sambuc 24*f4a2713aSLionel Sambuc 25*f4a2713aSLionel Sambuc struct Y1 { // has no implicit default constructor 26*f4a2713aSLionel Sambuc Y1(int); 27*f4a2713aSLionel Sambuc }; 28*f4a2713aSLionel Sambuc 29*f4a2713aSLionel Sambuc struct Y2 : Y1 { 30*f4a2713aSLionel Sambuc Y2(int); 31*f4a2713aSLionel Sambuc Y2(); 32*f4a2713aSLionel Sambuc }; 33*f4a2713aSLionel Sambuc 34*f4a2713aSLionel Sambuc struct Y3 : public Y2 { 35*f4a2713aSLionel Sambuc }; 36*f4a2713aSLionel Sambuc Y3 y3; 37*f4a2713aSLionel Sambuc 38*f4a2713aSLionel Sambuc struct Y4 { 39*f4a2713aSLionel Sambuc Y2 y2; 40*f4a2713aSLionel Sambuc }; 41*f4a2713aSLionel Sambuc 42*f4a2713aSLionel Sambuc Y4 y4; 43*f4a2713aSLionel Sambuc 44*f4a2713aSLionel Sambuc // More tests 45*f4a2713aSLionel Sambuc 46*f4a2713aSLionel Sambuc struct Z1 { // expected-error {{must explicitly initialize the reference member 'z'}} \ 47*f4a2713aSLionel Sambuc // expected-error {{must explicitly initialize the const member 'c1'}} 48*f4a2713aSLionel Sambuc int& z; // expected-note {{declared here}} 49*f4a2713aSLionel Sambuc const int c1; // expected-note {{declared here}} 50*f4a2713aSLionel Sambuc volatile int v1; 51*f4a2713aSLionel Sambuc }; 52*f4a2713aSLionel Sambuc 53*f4a2713aSLionel Sambuc // Test default initialization which *requires* a constructor call for non-POD. 54*f4a2713aSLionel Sambuc Z1 z1; // expected-note {{first required here}} 55*f4a2713aSLionel Sambuc 56*f4a2713aSLionel Sambuc // Ensure that value initialization doesn't use trivial implicit constructors. 57*f4a2713aSLionel Sambuc namespace PR7948 { 58*f4a2713aSLionel Sambuc // Note that this is also non-POD to ensure we don't just special case PODs. 59*f4a2713aSLionel Sambuc struct S { const int x; ~S(); }; 60*f4a2713aSLionel Sambuc const S arr[2] = { { 42 } }; 61*f4a2713aSLionel Sambuc } 62*f4a2713aSLionel Sambuc 63*f4a2713aSLionel Sambuc // This is valid 64*f4a2713aSLionel Sambuc union U { 65*f4a2713aSLionel Sambuc const int i; 66*f4a2713aSLionel Sambuc float f; 67*f4a2713aSLionel Sambuc }; 68*f4a2713aSLionel Sambuc U u; 69