From: jason Date: Tue, 12 Apr 2016 20:28:40 +0000 (+0000) Subject: * class.c (is_really_empty_class): A zero-length array is empty. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4ff9a8e5ad5f1aab62432b21ffa40a6645017243;p=thirdparty%2Fgcc.git * class.c (is_really_empty_class): A zero-length array is empty. An unnamed bit-field doesn't make a class non-empty. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234916 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 88b6a10bb7bb..823ab1110ab3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2016-04-12 Jason Merrill + + * class.c (is_really_empty_class): A zero-length array is empty. + An unnamed bit-field doesn't make a class non-empty. + 2016-04-12 Paolo Carlini PR c++/68722 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index e66f0b9c51e9..02a992fa5185 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -8406,12 +8406,15 @@ is_really_empty_class (tree type) for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) if (TREE_CODE (field) == FIELD_DECL && !DECL_ARTIFICIAL (field) + /* An unnamed bit-field is not a data member. */ + && (DECL_NAME (field) || !DECL_C_BIT_FIELD (field)) && !is_really_empty_class (TREE_TYPE (field))) return false; return true; } else if (TREE_CODE (type) == ARRAY_TYPE) - return is_really_empty_class (TREE_TYPE (type)); + return (integer_zerop (array_type_nelts_top (type)) + || is_really_empty_class (TREE_TYPE (type))); return false; }