PR c++/80605 - __is_standard_layout and empty base

* class.c (check_bases): Ignore empty bases.
	* class.c (check_bases): Use DECL_FIELD_IS_BASE.

From-SVN: r248753
This commit is contained in:
Jason Merrill 2017-05-31 13:53:06 -04:00 committed by Jason Merrill
parent 0634d9fe36
commit bb399e300f
4 changed files with 27 additions and 1 deletions

View File

@ -1,5 +1,11 @@
2017-05-31 Jason Merrill <jason@redhat.com> 2017-05-31 Jason Merrill <jason@redhat.com>
PR c++/80605 - __is_standard_layout and zero-length array
* class.c (check_bases): Use DECL_FIELD_IS_BASE.
PR c++/80605 - __is_standard_layout and empty base
* class.c (check_bases): Ignore empty bases.
PR c++/66297, DR 1684 - literal class and constexpr member fns PR c++/66297, DR 1684 - literal class and constexpr member fns
* constexpr.c (is_valid_constexpr_fn): Only complain about * constexpr.c (is_valid_constexpr_fn): Only complain about
non-literal enclosing class in C++11. non-literal enclosing class in C++11.

View File

@ -1861,7 +1861,9 @@ check_bases (tree t,
members */ members */
for (basefield = TYPE_FIELDS (basetype); basefield; for (basefield = TYPE_FIELDS (basetype); basefield;
basefield = DECL_CHAIN (basefield)) basefield = DECL_CHAIN (basefield))
if (TREE_CODE (basefield) == FIELD_DECL) if (TREE_CODE (basefield) == FIELD_DECL
&& !(DECL_FIELD_IS_BASE (basefield)
&& integer_zerop (DECL_SIZE (basefield))))
{ {
if (field) if (field)
CLASSTYPE_NON_STD_LAYOUT (t) = 1; CLASSTYPE_NON_STD_LAYOUT (t) = 1;

View File

@ -0,0 +1,12 @@
// { dg-do compile { target c++11 } }
template <int> struct E { };
struct E1: E<0>, E<1> { };
struct E2: E<2>, E<3> { };
struct A1x { int n; };
struct D2: A1x, E1, E2 { };
#define SA(X) static_assert((X),#X)
SA(__is_standard_layout (D2));

View File

@ -0,0 +1,6 @@
// { dg-do compile { target c++11 } }
// { dg-options "" }
struct S { int a[0]; };
struct T : public S { int b[0]; int c; };
static_assert(!__is_standard_layout (T), "");