From: Jason Merrill Date: Tue, 9 May 2017 20:38:03 +0000 (-0400) Subject: * class.c (check_bases): Ignore empty bases. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c0aad6778c5c5c9bf262b89edb91655a1df7da0e;p=gcc.git * class.c (check_bases): Ignore empty bases. From-SVN: r247816 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3a12217fbf8..7c633182666 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,7 @@ 2017-05-09 Jason Merrill + * class.c (check_bases): Ignore empty bases. + PR c++/70979 - literal class and closure types * class.c (finalize_literal_type_property): Handle closures specifically. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index fc717665539..085dbc389d9 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1860,7 +1860,9 @@ check_bases (tree t, members */ for (basefield = TYPE_FIELDS (basetype); basefield; basefield = DECL_CHAIN (basefield)) - if (TREE_CODE (basefield) == FIELD_DECL) + if (TREE_CODE (basefield) == FIELD_DECL + && DECL_SIZE (basefield) + && !integer_zerop (DECL_SIZE (basefield))) { if (field) CLASSTYPE_NON_STD_LAYOUT (t) = 1; diff --git a/gcc/testsuite/g++.dg/ext/is_std_layout1.C b/gcc/testsuite/g++.dg/ext/is_std_layout1.C new file mode 100644 index 00000000000..007c94a453c --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_std_layout1.C @@ -0,0 +1,12 @@ +// { dg-do compile { target c++11 } } + +template 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));