From: Jason Merrill Date: Thu, 25 May 2017 21:24:36 +0000 (-0400) Subject: PR c++/80605 - __is_standard_layout and zero-length array X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0fa367aa6bd587508199e90723ee6b84e0fb503d;p=gcc.git PR c++/80605 - __is_standard_layout and zero-length array * class.c (check_bases): Use DECL_FIELD_IS_BASE. From-SVN: r248470 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 279bcdb4989..9b7b58651f8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2017-05-25 Jason Merrill + + PR c++/80605 - __is_standard_layout and zero-length array + * class.c (check_bases): Use DECL_FIELD_IS_BASE. + 2017-05-25 Nathan Sidwell Kill OVL_CURRENT, OVL_NEXT. @@ -727,6 +732,7 @@ 2017-05-09 Jason Merrill + PR c++/80605 - __is_standard_layout and empty base * class.c (check_bases): Ignore empty bases. PR c++/70979 - literal class and closure types diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 984fb09ff4b..eddc1188667 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1842,8 +1842,8 @@ check_bases (tree t, for (basefield = TYPE_FIELDS (basetype); basefield; basefield = DECL_CHAIN (basefield)) if (TREE_CODE (basefield) == FIELD_DECL - && DECL_SIZE (basefield) - && !integer_zerop (DECL_SIZE (basefield))) + && !(DECL_FIELD_IS_BASE (basefield) + && integer_zerop (DECL_SIZE (basefield)))) { if (field) CLASSTYPE_NON_STD_LAYOUT (t) = 1; diff --git a/gcc/testsuite/g++.dg/ext/is_std_layout2.C b/gcc/testsuite/g++.dg/ext/is_std_layout2.C new file mode 100644 index 00000000000..02dc4f7ffb5 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_std_layout2.C @@ -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), "");