diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.dg/cpp0x/std-layout1.C | |
download | cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.bz2 cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x/std-layout1.C')
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/std-layout1.C | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/std-layout1.C b/gcc/testsuite/g++.dg/cpp0x/std-layout1.C new file mode 100644 index 000000000..bdad82111 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/std-layout1.C @@ -0,0 +1,91 @@ +// { dg-options "-std=c++0x" } + +// [basic.types]/10: +// Scalar types, standard-layout class types (Clause 9), arrays of such +// types and cv-qualified versions of these types (3.9.3) are collectively +// called standard-layout types. + +// [class]/7: +// A standard-layout class is a class that: +// * has no non-static data members of type non-standard-layout class (or +// array of such types) or reference, +// * 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 no non-standard-layout base classes, +// * 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 +// with non-static data members, and +// * has no base classes of the same type as the first non-static data member. + +#include <type_traits> + +#define TRY(expr) static_assert (expr, #expr) +#define YES(type) TRY(std::is_standard_layout<type>::value); \ + TRY(std::is_standard_layout<type[]>::value); \ + TRY(std::is_standard_layout<const volatile type>::value); +#define NO(type) TRY(!std::is_standard_layout<type>::value); \ + TRY(!std::is_standard_layout<type[]>::value); \ + TRY(!std::is_standard_layout<const volatile type>::value); +#define NONPOD(type) TRY(!std::is_pod<type>::value); \ + TRY(!std::is_pod<type[]>::value); \ + TRY(!std::is_pod<const volatile type>::value); + +struct A; + +YES(int); +YES(__complex int); +YES(void *); +YES(int A::*); +typedef int (A::*pmf)(); +YES(pmf); + +struct A { ~A(); }; +YES(A); +NONPOD(A); +struct F: public A { int i; }; +YES(F); +NONPOD(F); +struct G: public A { A a; }; +NO(G); +struct M { A a; }; +YES(M); + +class B +{ + int i; + __complex int c; + void *p; + double ar[4]; + int A::* pm; + int (A::*pmf)(); +}; +YES(B); +struct D: public B { }; +YES(D); +struct E: public B { int q; }; +NO(E); +struct D2: public B { }; +YES(D2); +struct I: public D, public D2 { }; +NO(I); + +struct C +{ + int i; +private: + int j; +}; +NO(C); +struct H: public C { }; +NO(H); +struct N { C c; }; +NO(N); + +struct J { virtual void f(); }; +struct J2: J { }; +NO(J); +NO(J2); +struct K { }; +struct L: virtual K {}; +YES(K); +NO(L); |