c++: Fix ICE with omitted template args [PR93956].
authorJason Merrill <jason@redhat.com>
Tue, 10 Mar 2020 21:51:46 +0000 (17:51 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 11 Mar 2020 02:01:03 +0000 (22:01 -0400)
reshape_init only wants to work on BRACE_ENCLOSED_INITIALIZER_P, i.e. raw
initializer lists, and here was getting a CONSTRUCTOR that had already been
processed for type A<int>.  maybe_aggr_guide should also use that test.

gcc/cp/ChangeLog
2020-03-10  Jason Merrill  <jason@redhat.com>

PR c++/93956
* pt.c (maybe_aggr_guide): Check BRACE_ENCLOSED_INITIALIZER_P.

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp1z/class-deduction70.C [new file with mode: 0644]

index e62aefde0c70b6f15a2dd99c6bac18d7f6ece54a..b60b1ecc60463c39bb0431c7987ae6e7fb010abb 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-10  Jason Merrill  <jason@redhat.com>
+
+       PR c++/93956
+       * pt.c (maybe_aggr_guide): Check BRACE_ENCLOSED_INITIALIZER_P.
+
 2020-03-10  Jason Merrill  <jason@redhat.com>
 
        PR c++/93922
index 49ee3920049e3cf6d2eda5dfd8c76ef47419f470..179716b56800ef15fc9db7b5d1b8ad8d6d7e7b4a 100644 (file)
@@ -28182,7 +28182,7 @@ maybe_aggr_guide (tree tmpl, tree init, vec<tree,va_gc> *args)
   tsubst_flags_t complain = tf_none;
 
   tree parms = NULL_TREE;
-  if (TREE_CODE (init) == CONSTRUCTOR)
+  if (BRACE_ENCLOSED_INITIALIZER_P (init))
     {
       init = reshape_init (type, init, complain);
       if (init == error_mark_node)
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction70.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction70.C
new file mode 100644 (file)
index 0000000..f14bdf0
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/93596
+
+template <typename> struct A {};
+template <typename> struct B {};
+template <typename> struct C {
+  void foo () { B a = A<int> { foo }; } // { dg-error "" }
+};