summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-22 08:29:56 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-22 08:29:56 +0000
commitc270ace47a7dfc573f33bf6e1543b8ad59b042c0 (patch)
treeef85c92dac9a135c13fd324d5a1fee8d324e20f0
parentcf5e422bfbdae5c03fc9342beed10993519a95a0 (diff)
downloadgcc-c270ace47a7dfc573f33bf6e1543b8ad59b042c0.tar.gz
PR target/84502
* stor-layout.c (finalize_type_size): Propagate TYPE_EMPTY_P flag to all type variants. * g++.dg/torture/pr84502.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257892 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/stor-layout.c8
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/torture/pr84502.C20
4 files changed, 32 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 914d6cba248..07dd795476d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,9 @@
2018-02-22 Jakub Jelinek <jakub@redhat.com>
+ PR target/84502
+ * stor-layout.c (finalize_type_size): Propagate TYPE_EMPTY_P flag
+ to all type variants.
+
PR tree-optimization/84503
* gimple-ssa-store-merging.c (merged_store_group::merge_into): Compute
width as info->bitpos + info->bitsize - start.
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 5fdf81a9a25..a4eeff18ec0 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -1883,6 +1883,9 @@ finalize_type_size (tree type)
&& TREE_CODE (TYPE_SIZE_UNIT (type)) != INTEGER_CST)
TYPE_SIZE_UNIT (type) = variable_size (TYPE_SIZE_UNIT (type));
+ /* Handle empty records as per the x86-64 psABI. */
+ TYPE_EMPTY_P (type) = targetm.calls.empty_record_p (type);
+
/* Also layout any other variants of the type. */
if (TYPE_NEXT_VARIANT (type)
|| type != TYPE_MAIN_VARIANT (type))
@@ -1895,6 +1898,7 @@ finalize_type_size (tree type)
unsigned int precision = TYPE_PRECISION (type);
unsigned int user_align = TYPE_USER_ALIGN (type);
machine_mode mode = TYPE_MODE (type);
+ bool empty_p = TYPE_EMPTY_P (type);
/* Copy it into all variants. */
for (variant = TYPE_MAIN_VARIANT (type);
@@ -1911,11 +1915,9 @@ finalize_type_size (tree type)
SET_TYPE_ALIGN (variant, valign);
TYPE_PRECISION (variant) = precision;
SET_TYPE_MODE (variant, mode);
+ TYPE_EMPTY_P (variant) = empty_p;
}
}
-
- /* Handle empty records as per the x86-64 psABI. */
- TYPE_EMPTY_P (type) = targetm.calls.empty_record_p (type);
}
/* Return a new underlying object for a bitfield started with FIELD. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 19b85bb350c..681971b208e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2018-02-22 Jakub Jelinek <jakub@redhat.com>
+ PR target/84502
+ * g++.dg/torture/pr84502.C: New test.
+
PR tree-optimization/84503
* gcc.dg/pr84503-1.c: New test.
* gcc.dg/pr84503-2.c: New test.
diff --git a/gcc/testsuite/g++.dg/torture/pr84502.C b/gcc/testsuite/g++.dg/torture/pr84502.C
new file mode 100644
index 00000000000..befde4e1f0c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr84502.C
@@ -0,0 +1,20 @@
+// PR target/84502
+// { dg-do run }
+
+template<typename T>
+struct A { };
+using X = A<int>;
+
+void
+foo (X, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
+{
+ if (a1 != 0 || a2 != 1 || a3 != 2 || a4 != 3
+ || a5 != 4 || a6 != 5 || a7 != 6 || a8 != 7)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ foo (X{}, 0, 1, 2, 3, 4, 5, 6, 7);
+}