]> gcc.gnu.org Git - gcc.git/blame - gcc/testsuite/g++.dg/cpp0x/std-layout1.C
PR c++/92590 - wrong handling of inherited default ctor.
[gcc.git] / gcc / testsuite / g++.dg / cpp0x / std-layout1.C
CommitLineData
4b2e63de 1// { dg-do compile { target c++11 } }
c32097d8
JM
2
3// [basic.types]/10:
4// Scalar types, standard-layout class types (Clause 9), arrays of such
5// types and cv-qualified versions of these types (3.9.3) are collectively
6// called standard-layout types.
7
8// [class]/7:
9// A standard-layout class is a class that:
10// * has no non-static data members of type non-standard-layout class (or
11// array of such types) or reference,
12// * has no virtual functions (10.3) and no virtual base classes (10.1),
13// * has the same access control (Clause 11) for all non-static data members,
14// * has no non-standard-layout base classes,
15// * either has no non-static data members in the most-derived class and at
16// most one base class with non-static data members, or has no base classes
17// with non-static data members, and
18// * has no base classes of the same type as the first non-static data member.
19
20#include <type_traits>
21
22#define TRY(expr) static_assert (expr, #expr)
23#define YES(type) TRY(std::is_standard_layout<type>::value); \
24 TRY(std::is_standard_layout<type[]>::value); \
4b2e63de 25 TRY(std::is_standard_layout<const volatile type>::value)
c32097d8
JM
26#define NO(type) TRY(!std::is_standard_layout<type>::value); \
27 TRY(!std::is_standard_layout<type[]>::value); \
4b2e63de 28 TRY(!std::is_standard_layout<const volatile type>::value)
c32097d8
JM
29#define NONPOD(type) TRY(!std::is_pod<type>::value); \
30 TRY(!std::is_pod<type[]>::value); \
4b2e63de 31 TRY(!std::is_pod<const volatile type>::value)
c32097d8
JM
32
33struct A;
34
35YES(int);
36YES(__complex int);
37YES(void *);
38YES(int A::*);
39typedef int (A::*pmf)();
40YES(pmf);
41
42struct A { ~A(); };
43YES(A);
44NONPOD(A);
45struct F: public A { int i; };
46YES(F);
47NONPOD(F);
48struct G: public A { A a; };
49NO(G);
50struct M { A a; };
51YES(M);
52
53class B
54{
55 int i;
56 __complex int c;
57 void *p;
58 double ar[4];
59 int A::* pm;
60 int (A::*pmf)();
61};
62YES(B);
63struct D: public B { };
64YES(D);
65struct E: public B { int q; };
66NO(E);
67struct D2: public B { };
68YES(D2);
69struct I: public D, public D2 { };
70NO(I);
71
72struct C
73{
74 int i;
75private:
76 int j;
77};
78NO(C);
79struct H: public C { };
80NO(H);
81struct N { C c; };
82NO(N);
83
84struct J { virtual void f(); };
85struct J2: J { };
86NO(J);
87NO(J2);
88struct K { };
89struct L: virtual K {};
90YES(K);
91NO(L);
This page took 6.991353 seconds and 5 git commands to generate.