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