diff mbox series

[pushed] c++: temporarily restore VEC_INIT_EXPR gimplify [PR103936]

Message ID 20220107052242.3018311-1-jason@redhat.com
State New
Headers show
Series [pushed] c++: temporarily restore VEC_INIT_EXPR gimplify [PR103936] | expand

Commit Message

Jason Merrill Jan. 7, 2022, 5:22 a.m. UTC
PR103936 demonstrates that some VEC_INIT_EXPR can still survive into
GENERIC; until that's fixed let's put back the handling in cp_gimplify_expr.

	PR c++/103936
	PR c++/65591

gcc/cp/ChangeLog:

	* cp-gimplify.c (cp_gimplify_expr): Restore VEC_INIT_EXPR handling.

gcc/testsuite/ChangeLog:

	* g++.dg/init/aggr15.C: New test.
---
 gcc/cp/cp-gimplify.c               | 13 +++++++++++++
 gcc/testsuite/g++.dg/init/aggr15.C | 11 +++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/init/aggr15.C


base-commit: 32d8ff73718fd07a9a7dfd2566d3b7b69f37b6bd
prerequisite-patch-id: c8b7209fa1db3783c5225b16cb048a523ea374d1
prerequisite-patch-id: 663e00a9e27f9b6b2188c8872b028e3ceabd7f1d
diff mbox series

Patch

diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 114fa78b353..8b097c46158 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -469,6 +469,19 @@  cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
       ret = GS_OK;
       break;
 
+    case VEC_INIT_EXPR:
+      {
+	*expr_p = expand_vec_init_expr (NULL_TREE, *expr_p,
+					tf_warning_or_error);
+
+	hash_set<tree> pset;
+	cp_walk_tree (expr_p, cp_fold_r, &pset, NULL);
+	cp_genericize_tree (expr_p, false);
+	copy_if_shared (expr_p);
+	ret = GS_OK;
+      }
+      break;
+
     case THROW_EXPR:
       /* FIXME communicate throw type to back end, probably by moving
 	 THROW_EXPR into ../tree.def.  */
diff --git a/gcc/testsuite/g++.dg/init/aggr15.C b/gcc/testsuite/g++.dg/init/aggr15.C
new file mode 100644
index 00000000000..a19a0f8e47b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/aggr15.C
@@ -0,0 +1,11 @@ 
+// PR c++/65591
+
+struct ss {
+    ss() {};
+};
+struct C {
+      ss s[1000];
+};
+int main() {
+      C cs[5] = {};
+}