p1-0x.cpp revision dd67723af339f94870149ee1934dd652f83ca738
1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %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'}}
56template<typename...BaseList>
57struct MaybeAggr5a : BaseList... {};
58MaybeAggr5a<> ma5a0 = {}; // ok
59MaybeAggr5a<Aggr> ma5a1 = {}; // expected-error {{non-aggregate type 'MaybeAggr5a<Aggr>'}}
60
61// and no virtual functions.
62struct NonAggr6 {
63  virtual void f();
64  int n;
65};
66NonAggr6 na6 = { 42 }; // expected-error {{non-aggregate type 'NonAggr6'}}
67