p1-0x.cpp revision 017ab77655b262311a3550342ca19b85380f8f20
1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s 2 3// An aggregate is an array or a class... 4struct Aggr { 5private: 6 static const int n; 7 void f(); 8protected: 9 struct Inner { int m; }; 10public: 11 bool &br; 12}; 13bool b; 14Aggr ag = { b }; 15 16// with no user-provided constructors, ... 17struct NonAggr1a { 18 NonAggr1a(int, int); 19 int k; 20}; 21// In C++0x, 'user-provided' is only defined for special member functions, so 22// this type is considered to be an aggregate. This is considered to be 23// a language defect. 24NonAggr1a na1a = { 42 }; // expected-error {{non-aggregate type 'NonAggr1a'}} 25 26struct NonAggr1b { 27 NonAggr1b(const NonAggr1b &); 28 int k; 29}; 30NonAggr1b na1b = { 42 }; // expected-error {{non-aggregate type 'NonAggr1b'}} 31 32// no brace-or-equal-initializers for non-static data members, ... 33struct NonAggr2 { 34 int m = { 123 }; 35}; 36NonAggr2 na2 = { 42 }; // expected-error {{non-aggregate type 'NonAggr2'}} 37 38// no private... 39struct NonAggr3 { 40private: 41 int n; 42}; 43NonAggr3 na3 = { 42 }; // expected-error {{non-aggregate type 'NonAggr3'}} 44 45// or protected non-static data members, ... 46struct NonAggr4 { 47protected: 48 int n; 49}; 50NonAggr4 na4 = { 42 }; // expected-error {{non-aggregate type 'NonAggr4'}} 51 52// no base classes, ... 53struct NonAggr5 : Aggr { 54}; 55NonAggr5 na5 = { b }; // expected-error {{non-aggregate type 'NonAggr5'}} 56 57// and no virtual functions. 58struct NonAggr6 { 59 virtual void f(); 60 int n; 61}; 62NonAggr6 na6 = { 42 }; // expected-error {{non-aggregate type 'NonAggr6'}} 63