On 6 May 2024, at 18:28, Jason Merrill wrote:

On 5/6/24 09:20, Simon Martin wrote:
Hi,

We currently ICE upon the following invalid snippet because we fail to properly handle tsubst_arg_types returning error_mark_node in build_deduction_guide.

== cut ==
template<class... Ts, class>
struct A { A(Ts...); };
A a;
== cut ==

This patch fixes this, and has been successfully tested on x86_64-pc-linux-gnu. OK for trunk?

OK, thanks.
Sorry for the delay replying, and thanks for the review. Could someone please commit the patch on my behalf since my sourceware account is not active anymore?

Thanks!

Thanks!

-- Simon

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a78d9d546d6..9acef73e7ac 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2024-05-06  Simon Martin  <simar...@gcc.gnu.org>
+
+       PR c++/105760
+       * pt.c (build_deduction_guide): Check for error_mark_node
+       result from tsubst_arg_types.
+
  2024-05-03  Jason Merrill  <ja...@redhat.com>

         PR c++/114935
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index d68d688016d..da5d9b8a665 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -30018,6 +30018,8 @@ build_deduction_guide (tree type, tree ctor, tree outer_args, tsubst_flags_t com              references to members of an unknown specialization.  */
           cp_evaluated ev;
          fparms = tsubst_arg_types (fparms, targs, NULL_TREE, complain, ctor);
+         if (fparms == error_mark_node)
+           ok = false;
           fargs = tsubst (fargs, targs, complain, ctor);
           if (ci)
             {
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 03c88bbed07..8c606a8fb4f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2024-05-06  Simon Martin  <simar...@gcc.gnu.org>
+
+       PR c++/105760
+       * g++.dg/parse/error66.C: New test.
+
  2024-05-05  Harald Anlauf  <anl...@gmx.de>

         PR fortran/114827
diff --git a/gcc/testsuite/g++.dg/parse/error66.C b/gcc/testsuite/g++.dg/parse/error66.C
new file mode 100644
index 00000000000..82f4b8b8a53
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/error66.C
@@ -0,0 +1,6 @@
+// PR c++/105760
+// { dg-do compile { target c++17 } }
+
+template<class... Ts, class> // { dg-error "must be at the end of the template parameter list" }
+struct A { A(Ts...); };
+A a;

Reply via email to