re PR c++/71822 (ICE: in gimplify_expr, at gimplify.c:11025)
authorJakub Jelinek <jakub@redhat.com>
Mon, 18 Jul 2016 18:40:12 +0000 (20:40 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 18 Jul 2016 18:40:12 +0000 (20:40 +0200)
PR c++/71822
* cp-gimplify.c (cp_gimplify_expr) <case VEC_INIT_EXPR>: Recursively
fold *expr_p before genericizing it.

* g++.dg/template/defarg21.C: New test.

From-SVN: r238440

gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/defarg21.C [new file with mode: 0644]

index 888d4aa894c4ad90fb7aa18c470ac1f91ec5f27a..3cd6b133869e8d5180e8236d2b57617ccd33ee55 100644 (file)
@@ -1,5 +1,9 @@
 2016-07-18  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/71822
+       * cp-gimplify.c (cp_gimplify_expr) <case VEC_INIT_EXPR>: Recursively
+       fold *expr_p before genericizing it.
+
        PR c++/71871
        * typeck.c (build_x_conditional_expr): Revert the 2012-10-25 change.
 
index 8496d7cfee70ac2436e0876b860adda7a352f3c5..de6c9296aa83d08d0abe7d488d02d4ad95afa9f6 100644 (file)
@@ -621,6 +621,8 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
                                  init, VEC_INIT_EXPR_VALUE_INIT (*expr_p),
                                  from_array,
                                  tf_warning_or_error);
+       hash_set<tree> pset;
+       cp_walk_tree (expr_p, cp_fold_r, &pset, NULL);
        cp_genericize_tree (expr_p);
        ret = GS_OK;
        input_location = loc;
index aa35fb2033b9d46b62bf474a455b126a18593fd3..2f6471a6c6b04012dc4fefabbbaef49affb548c6 100644 (file)
@@ -1,5 +1,8 @@
 2016-07-18  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/71822
+       * g++.dg/template/defarg21.C: New test.
+
        PR c++/71871
        * g++.dg/ext/vector31.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/template/defarg21.C b/gcc/testsuite/g++.dg/template/defarg21.C
new file mode 100644 (file)
index 0000000..6ac2276
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/71822
+// { dg-do compile }
+
+int bar (int);
+
+template <typename T>
+struct A
+{
+  explicit A (int x = bar (sizeof (T)));
+};
+
+struct B
+{
+  A <int> b[2];
+};
+
+void
+baz ()
+{
+  B b;
+}