public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR c++/105760: ICE in build_deduction_guide for invalid template
@ 2024-05-06 13:20 Simon Martin
  2024-05-06 16:28 ` Jason Merrill
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Martin @ 2024-05-06 13:20 UTC (permalink / raw)
  To: gcc-patches

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?

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  <simartin@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  <jason@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  <simartin@gcc.gnu.org>
+
+       PR c++/105760
+       * g++.dg/parse/error66.C: New test.
+
  2024-05-05  Harald Anlauf  <anlauf@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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-14 15:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-06 13:20 [PATCH] Fix PR c++/105760: ICE in build_deduction_guide for invalid template Simon Martin
2024-05-06 16:28 ` Jason Merrill
2024-05-14 15:31   ` Simon Martin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).