blob: 9b92340fa457d456f0550bb64ca61b8872dee981 [file] [log] [blame]
Richard Smith7a614d82011-06-11 17:19:42 +00001// 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++03, this is {{non-aggregate type 'NonAggr1a'}}.
22// In C++0x, 'user-provided' is only defined for special member functions, so
23// this type is considered to be an aggregate. This is probably a langauge
24// defect.
25NonAggr1a na1a = { 42 };
26
27struct NonAggr1b {
28 NonAggr1b(const NonAggr1b &);
29 int k;
30};
31NonAggr1b na1b = { 42 }; // expected-error {{non-aggregate type 'NonAggr1b'}}
32
33// no brace-or-equal-initializers for non-static data members, ...
34struct NonAggr2 {
35 int m = { 123 };
36};
37NonAggr2 na2 = { 42 }; // expected-error {{non-aggregate type 'NonAggr2'}}
38
39// no private...
40struct NonAggr3 {
41private:
42 int n;
43};
44NonAggr3 na3 = { 42 }; // expected-error {{non-aggregate type 'NonAggr3'}}
45
46// or protected non-static data members, ...
47struct NonAggr4 {
48protected:
49 int n;
50};
51NonAggr4 na4 = { 42 }; // expected-error {{non-aggregate type 'NonAggr4'}}
52
53// no base classes, ...
54struct NonAggr5 : Aggr {
55};
56NonAggr5 na5 = { b }; // expected-error {{non-aggregate type 'NonAggr5'}}
57
58// and no virtual functions.
59struct NonAggr6 {
60 virtual void f();
61 int n;
62};
63NonAggr6 na6 = { 42 }; // expected-error {{non-aggregate type 'NonAggr6'}}