aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2025-03-06 09:08:07 +0100
committerRichard Biener <rguenth@gcc.gnu.org>2025-03-06 10:57:05 +0100
commit3bd61c1dfaa2d7153eb4be82f423533ea937d0f9 (patch)
treea889597a00511f4c651ab2c9e043d05481c977dd
parentfdf846fdddcc0467b9f025757f081c5d54319d08 (diff)
downloadgcc-3bd61c1dfaa2d7153eb4be82f423533ea937d0f9.zip
gcc-3bd61c1dfaa2d7153eb4be82f423533ea937d0f9.tar.gz
gcc-3bd61c1dfaa2d7153eb4be82f423533ea937d0f9.tar.bz2
middle-end/119119 - re-gimplification of empty CTOR assignments
The following testcase runs into a re-gimplification issue during inlining when processing MEM[(struct e *)this_2(D)].a = {}; where re-gimplification does not handle assignments in the same way than the gimplifier but instead relies on rhs_predicate_for and gimplifying the RHS standalone. This fails to handle special-casing of CTORs. The is_gimple_mem_rhs_or_call predicate already handles clobbers but not empty CTORs so we end up in the fallback code trying to force the CTOR into a separate stmt using a temporary - but as we have a non-copyable type here that ICEs. The following generalizes empty CTORs in is_gimple_mem_rhs_or_call since those need no additional re-gimplification. PR middle-end/119119 * gimplify.cc (is_gimple_mem_rhs_or_call): All empty CTORs are OK when not a register type. * g++.dg/torture/pr11911.C: New testcase.
-rw-r--r--gcc/gimplify.cc2
-rw-r--r--gcc/testsuite/g++.dg/torture/pr11911.C21
2 files changed, 22 insertions, 1 deletions
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 160e7fc..6869f53 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -607,7 +607,7 @@ is_gimple_mem_rhs_or_call (tree t)
else
return (is_gimple_val (t)
|| is_gimple_lvalue (t)
- || TREE_CLOBBER_P (t)
+ || (TREE_CODE (t) == CONSTRUCTOR && CONSTRUCTOR_NELTS (t) == 0)
|| TREE_CODE (t) == CALL_EXPR);
}
diff --git a/gcc/testsuite/g++.dg/torture/pr11911.C b/gcc/testsuite/g++.dg/torture/pr11911.C
new file mode 100644
index 0000000..7dc836f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr11911.C
@@ -0,0 +1,21 @@
+// { dg-do compile }
+// { dg-require-effective-target c++17 }
+
+struct b {
+ int a;
+};
+struct c {
+ b d{};
+ c() = default;
+ c(c &) = delete;
+};
+struct e {
+ c a{};
+ e() {}
+};
+inline e f() { return {}; }
+struct g {
+ e cx;
+ g() : cx{f()} {}
+};
+void h() { g i; }