aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-03-14 17:10:39 -0400
committerJason Merrill <jason@redhat.com>2020-03-14 17:13:25 -0400
commit3a285529ee338ef2867ae7add26b6493f004bf0d (patch)
treec4ddceeb69449d9780ea7659e97410fab77ed623 /gcc
parentb3b0c671cc341fd04afc045a8d42d7a845d7f73c (diff)
downloadgcc-3a285529ee338ef2867ae7add26b6493f004bf0d.zip
gcc-3a285529ee338ef2867ae7add26b6493f004bf0d.tar.gz
gcc-3a285529ee338ef2867ae7add26b6493f004bf0d.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c9
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/variadic178.C6
3 files changed, 20 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index bb7f590..c9375234 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
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++/92909
* pt.c (find_parameter_packs_r): [DECL_EXPR]: Walk
DECL_ORIGINAL_TYPE of a typedef.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index bd2f9be..48ac486 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5038,6 +5038,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
@@ -5064,7 +5072,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 0000000..f0e6595
--- /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" }