public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/redhat/heads/gcc-8-branch)] c++: Fix ICE-after-error on partial spec [92068]
@ 2020-09-17 16:51 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-09-17 16:51 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:43c8ce6831f3604f2182dc1b7f867dc048eaaa9c
commit 43c8ce6831f3604f2182dc1b7f867dc048eaaa9c
Author: Jason Merrill <jason@redhat.com>
Date: Sat Mar 14 17:10:39 2020 -0400
c++: Fix ICE-after-error on partial spec [92068]
Here the template arguments for the partial specialization are valid
arguments for the template, but not for a partial specialization, because
'd' can never be deduced to anything other than an empty pack.
gcc/cp/ChangeLog
2020-03-14 Jason Merrill <jason@redhat.com>
PR c++/92068
* pt.c (process_partial_specialization): Error rather than crash on
extra pack expansion.
Diff:
---
gcc/cp/ChangeLog | 6 ++++++
gcc/cp/pt.c | 9 ++++++++-
gcc/testsuite/g++.dg/cpp0x/variadic178.C | 6 ++++++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 27b36eb7642..ed2405e6f33 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2020-03-14 Jason Merrill <jason@redhat.com>
+
+ PR c++/92068
+ * pt.c (process_partial_specialization): Error rather than crash on
+ extra pack expansion.
+
2020-03-14 Jason Merrill <jason@redhat.com>
PR c++/93248
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index a2274f34725..a7a5fa06d05 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -4919,6 +4919,14 @@ process_partial_specialization (tree decl)
return decl;
}
+ else if (nargs > DECL_NTPARMS (maintmpl))
+ {
+ error ("too many arguments for partial specialization %qT", type);
+ inform (DECL_SOURCE_LOCATION (maintmpl), "primary template here");
+ /* Avoid crash below. */
+ return decl;
+ }
+
/* If we aren't in a dependent class, we can actually try deduction. */
else if (tpd.level == 1
/* FIXME we should be able to handle a partial specialization of a
@@ -4944,7 +4952,6 @@ process_partial_specialization (tree decl)
Also, we verify that pack expansions only occur at the
end of the argument list. */
- gcc_assert (nargs == DECL_NTPARMS (maintmpl));
tpd2.parms = 0;
for (i = 0; i < nargs; ++i)
{
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic178.C b/gcc/testsuite/g++.dg/cpp0x/variadic178.C
new file mode 100644
index 00000000000..f0e65958de3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic178.C
@@ -0,0 +1,6 @@
+// PR c++/92068
+// { dg-do compile { target c++11 } }
+
+template <typename, typename> struct a;
+template <typename b, typename c, typename... d>
+struct a<b, c, d...> { }; // { dg-error "arguments" }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-17 16:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 16:51 [gcc(refs/vendors/redhat/heads/gcc-8-branch)] c++: Fix ICE-after-error on partial spec [92068] Jakub Jelinek
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).