From 08d6d8bb00d6feddc6916739276aeea4600cd188 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 12 Apr 2016 16:28:40 -0400 Subject: [PATCH] class.c (is_really_empty_class): A zero-length array is empty. * 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 | 5 +++++ gcc/cp/class.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 88b6a10bb7b..823ab1110ab 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 e66f0b9c51e..02a992fa518 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; }