]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* class.c (is_really_empty_class): A zero-length array is empty.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 12 Apr 2016 20:28:40 +0000 (20:28 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 12 Apr 2016 20:28:40 +0000 (20:28 +0000)
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

gcc/cp/ChangeLog
gcc/cp/class.c

index 88b6a10bb7bbd08b84322057ba7569071460e643..823ab1110ab36e4b4dfc2c11ca99f0b759e607d3 100644 (file)
@@ -1,3 +1,8 @@
+2016-04-12  Jason Merrill  <jason@redhat.com>
+
+       * 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  <paolo.carlini@oracle.com>
 
        PR c++/68722
index e66f0b9c51e9352609a9fea1ce3633ee4088019b..02a992fa518525410c80397acd1344c29712eb0d 100644 (file)
@@ -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;
 }