aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-06-24 10:34:35 -0400
committerJason Merrill <jason@gcc.gnu.org>2019-06-24 10:34:35 -0400
commitc3337b44c40dd1545e00034cb8e1ae1c0dae0fa6 (patch)
tree6953d615a801d5850ae540a1655ee62259f6d18a
parenta3c8d7fbe29d4ab60cc46196a1376854734a4f8d (diff)
downloadgcc-c3337b44c40dd1545e00034cb8e1ae1c0dae0fa6.zip
gcc-c3337b44c40dd1545e00034cb8e1ae1c0dae0fa6.tar.gz
gcc-c3337b44c40dd1545e00034cb8e1ae1c0dae0fa6.tar.bz2
Don't use a separate CLASSTYPE_AS_BASE if it's the same size.
* class.c (layout_class_type): Don't use a separate CLASSTYPE_AS_BASE if it's the same size. From-SVN: r272618
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/class.c6
2 files changed, 11 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f47df48..efb6c3d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2019-06-24 Jason Merrill <jason@redhat.com>
+
+ * class.c (layout_class_type): Don't use a separate
+ CLASSTYPE_AS_BASE if it's the same size.
+
2019-06-23 Marek Polacek <polacek@redhat.com>
* call.c (convert_default_arg): Use DEFERRED_PARSE instead of
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index de37e43..e0df9ef 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -6453,6 +6453,12 @@ layout_class_type (tree t, tree *virtuals_p)
/* Let the back end lay out the type. */
finish_record_layout (rli, /*free_p=*/true);
+ /* If we didn't end up needing an as-base type, don't use it. */
+ if (CLASSTYPE_AS_BASE (t) != t
+ && tree_int_cst_equal (TYPE_SIZE (t),
+ TYPE_SIZE (CLASSTYPE_AS_BASE (t))))
+ CLASSTYPE_AS_BASE (t) = t;
+
if (TYPE_SIZE_UNIT (t)
&& TREE_CODE (TYPE_SIZE_UNIT (t)) == INTEGER_CST
&& !TREE_OVERFLOW (TYPE_SIZE_UNIT (t))