class.c (is_really_empty_class): A zero-length array is empty.
authorJason Merrill <jason@redhat.com>
Tue, 12 Apr 2016 20:28:40 +0000 (16:28 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 12 Apr 2016 20:28:40 +0000 (16:28 -0400)
* class.c (is_really_empty_class): A zero-length array is empty.
An unnamed bit-field doesn't make a class non-empty.

From-SVN: r234916

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

index 88b6a10..823ab11 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 e66f0b9..02a992f 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;
 }