// { dg-options "-std=c++0x" }
|
// { dg-options "-std=c++0x" }
|
|
|
// [basic.types]/10:
|
// [basic.types]/10:
|
// Scalar types, standard-layout class types (Clause 9), arrays of such
|
// Scalar types, standard-layout class types (Clause 9), arrays of such
|
// types and cv-qualified versions of these types (3.9.3) are collectively
|
// types and cv-qualified versions of these types (3.9.3) are collectively
|
// called standard-layout types.
|
// called standard-layout types.
|
|
|
// [class]/7:
|
// [class]/7:
|
// A standard-layout class is a class that:
|
// A standard-layout class is a class that:
|
// * has no non-static data members of type non-standard-layout class (or
|
// * has no non-static data members of type non-standard-layout class (or
|
// array of such types) or reference,
|
// array of such types) or reference,
|
// * has no virtual functions (10.3) and no virtual base classes (10.1),
|
// * has no virtual functions (10.3) and no virtual base classes (10.1),
|
// * has the same access control (Clause 11) for all non-static data members,
|
// * has the same access control (Clause 11) for all non-static data members,
|
// * has no non-standard-layout base classes,
|
// * has no non-standard-layout base classes,
|
// * either has no non-static data members in the most-derived class and at
|
// * either has no non-static data members in the most-derived class and at
|
// most one base class with non-static data members, or has no base classes
|
// most one base class with non-static data members, or has no base classes
|
// with non-static data members, and
|
// with non-static data members, and
|
// * has no base classes of the same type as the first non-static data member.
|
// * has no base classes of the same type as the first non-static data member.
|
|
|
#include
|
#include
|
|
|
#define TRY(expr) static_assert (expr, #expr)
|
#define TRY(expr) static_assert (expr, #expr)
|
#define YES(type) TRY(std::is_standard_layout::value); \
|
#define YES(type) TRY(std::is_standard_layout::value); \
|
TRY(std::is_standard_layout::value); \
|
TRY(std::is_standard_layout::value); \
|
TRY(std::is_standard_layout::value);
|
TRY(std::is_standard_layout::value);
|
#define NO(type) TRY(!std::is_standard_layout::value); \
|
#define NO(type) TRY(!std::is_standard_layout::value); \
|
TRY(!std::is_standard_layout::value); \
|
TRY(!std::is_standard_layout::value); \
|
TRY(!std::is_standard_layout::value);
|
TRY(!std::is_standard_layout::value);
|
#define NONPOD(type) TRY(!std::is_pod::value); \
|
#define NONPOD(type) TRY(!std::is_pod::value); \
|
TRY(!std::is_pod::value); \
|
TRY(!std::is_pod::value); \
|
TRY(!std::is_pod::value);
|
TRY(!std::is_pod::value);
|
|
|
struct A;
|
struct A;
|
|
|
YES(int);
|
YES(int);
|
YES(__complex int);
|
YES(__complex int);
|
YES(void *);
|
YES(void *);
|
YES(int A::*);
|
YES(int A::*);
|
typedef int (A::*pmf)();
|
typedef int (A::*pmf)();
|
YES(pmf);
|
YES(pmf);
|
|
|
struct A { ~A(); };
|
struct A { ~A(); };
|
YES(A);
|
YES(A);
|
NONPOD(A);
|
NONPOD(A);
|
struct F: public A { int i; };
|
struct F: public A { int i; };
|
YES(F);
|
YES(F);
|
NONPOD(F);
|
NONPOD(F);
|
struct G: public A { A a; };
|
struct G: public A { A a; };
|
NO(G);
|
NO(G);
|
struct M { A a; };
|
struct M { A a; };
|
YES(M);
|
YES(M);
|
|
|
class B
|
class B
|
{
|
{
|
int i;
|
int i;
|
__complex int c;
|
__complex int c;
|
void *p;
|
void *p;
|
double ar[4];
|
double ar[4];
|
int A::* pm;
|
int A::* pm;
|
int (A::*pmf)();
|
int (A::*pmf)();
|
};
|
};
|
YES(B);
|
YES(B);
|
struct D: public B { };
|
struct D: public B { };
|
YES(D);
|
YES(D);
|
struct E: public B { int q; };
|
struct E: public B { int q; };
|
NO(E);
|
NO(E);
|
struct D2: public B { };
|
struct D2: public B { };
|
YES(D2);
|
YES(D2);
|
struct I: public D, public D2 { };
|
struct I: public D, public D2 { };
|
NO(I);
|
NO(I);
|
|
|
struct C
|
struct C
|
{
|
{
|
int i;
|
int i;
|
private:
|
private:
|
int j;
|
int j;
|
};
|
};
|
NO(C);
|
NO(C);
|
struct H: public C { };
|
struct H: public C { };
|
NO(H);
|
NO(H);
|
struct N { C c; };
|
struct N { C c; };
|
NO(N);
|
NO(N);
|
|
|
struct J { virtual void f(); };
|
struct J { virtual void f(); };
|
struct J2: J { };
|
struct J2: J { };
|
NO(J);
|
NO(J);
|
NO(J2);
|
NO(J2);
|
struct K { };
|
struct K { };
|
struct L: virtual K {};
|
struct L: virtual K {};
|
YES(K);
|
YES(K);
|
NO(L);
|
NO(L);
|
|
|