1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1y %s -DCXX1Y 3 4// An aggregate is an array or a class... 5struct Aggr { 6private: 7 static const int n; 8 void f(); 9protected: 10 struct Inner { int m; }; 11public: 12 bool &br; // expected-note {{default constructor of 'Aggr' is implicitly deleted because field 'br' of reference type 'bool &' would not be initialized}} 13}; 14bool b; 15Aggr ag = { b }; 16 17// with no user-provided constructors, ... 18struct NonAggr1a { // expected-note 2 {{candidate constructor}} 19 NonAggr1a(int, int); // expected-note {{candidate constructor}} 20 int k; 21}; 22NonAggr1a na1a = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr1a'}} 23 24struct NonAggr1b { 25 NonAggr1b(const NonAggr1b &); // expected-note {{candidate constructor}} 26 int k; 27}; 28NonAggr1b na1b = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr1b'}} 29 30// no brace-or-equal-initializers for non-static data members, ... 31// Note, this bullet was removed in C++1y. 32struct NonAggr2 { 33 int m = { 123 }; 34}; 35NonAggr2 na2 = { 42 }; 36#ifndef CXX1Y 37// expected-error@-2 {{no matching constructor for initialization of 'NonAggr2'}} 38// expected-note@-6 3 {{candidate constructor}} 39#endif 40 41// no private... 42struct NonAggr3 { // expected-note 3 {{candidate constructor}} 43private: 44 int n; 45}; 46NonAggr3 na3 = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr3'}} 47 48// or protected non-static data members, ... 49struct NonAggr4 { // expected-note 3 {{candidate constructor}} 50protected: 51 int n; 52}; 53NonAggr4 na4 = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr4'}} 54 55// no base classes, ... 56struct NonAggr5 : Aggr { // expected-note 3 {{candidate constructor}} 57}; 58NonAggr5 na5 = { b }; // expected-error {{no matching constructor for initialization of 'NonAggr5'}} 59template<typename...BaseList> 60struct MaybeAggr5a : BaseList... {}; // expected-note {{default constructor of 'MaybeAggr5a<Aggr>' is implicitly deleted because base class 'Aggr' has a deleted default constructor}} 61MaybeAggr5a<> ma5a0 = {}; // ok 62MaybeAggr5a<Aggr> ma5a1 = {}; // expected-error {{call to implicitly-deleted default constructor of 'MaybeAggr5a<Aggr>'}} 63 64// and no virtual functions. 65struct NonAggr6 { // expected-note 3 {{candidate constructor}} 66 virtual void f(); 67 int n; 68}; 69NonAggr6 na6 = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr6'}} 70 71struct DefaultedAggr { 72 int n; 73 74 DefaultedAggr() = default; 75 DefaultedAggr(const DefaultedAggr &) = default; 76 DefaultedAggr(DefaultedAggr &&) = default; 77 DefaultedAggr &operator=(const DefaultedAggr &) = default; 78 DefaultedAggr &operator=(DefaultedAggr &&) = default; 79 ~DefaultedAggr() = default; 80}; 81DefaultedAggr da = { 42 } ; 82