aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-03-09 22:34:37 -0500
committerJason Merrill <jason@gcc.gnu.org>2018-03-09 22:34:37 -0500
commit7ed12599fa74fdfd9bd36853b50a6086f89df061 (patch)
tree5761c7fd2968c4467971f776cd61248b41e22ae9
parent732a431dc94ae7f921e21245061946a1cfe8d9b5 (diff)
downloadgcc-7ed12599fa74fdfd9bd36853b50a6086f89df061.zip
gcc-7ed12599fa74fdfd9bd36853b50a6086f89df061.tar.gz
gcc-7ed12599fa74fdfd9bd36853b50a6086f89df061.tar.bz2
PR c++/84770 - ICE with typedef and parameter pack.
* pt.c (verify_unstripped_args_1): Split out from verify_unstripped_args. From-SVN: r258408
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/pt.c37
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/variadic173.C10
3 files changed, 35 insertions, 16 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 95ed64d..7ed0d5e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2018-03-09 Jason Merrill <jason@redhat.com>
+ PR c++/84770 - ICE with typedef and parameter pack.
+ * pt.c (verify_unstripped_args_1): Split out from
+ verify_unstripped_args.
+
PR c++/84785 - ICE with alias template and default targs.
* pt.c (type_unification_real): Set processing_template_decl if
saw_undeduced == 1.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d91e8bb..a92b36a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -1134,26 +1134,31 @@ optimize_specialization_lookup_p (tree tmpl)
gone through coerce_template_parms by now. */
static void
+verify_unstripped_args_1 (tree inner)
+{
+ for (int i = 0; i < TREE_VEC_LENGTH (inner); ++i)
+ {
+ tree arg = TREE_VEC_ELT (inner, i);
+ if (TREE_CODE (arg) == TEMPLATE_DECL)
+ /* OK */;
+ else if (TYPE_P (arg))
+ gcc_assert (strip_typedefs (arg, NULL) == arg);
+ else if (ARGUMENT_PACK_P (arg))
+ verify_unstripped_args_1 (ARGUMENT_PACK_ARGS (arg));
+ else if (strip_typedefs (TREE_TYPE (arg), NULL) != TREE_TYPE (arg))
+ /* Allow typedefs on the type of a non-type argument, since a
+ parameter can have them. */;
+ else
+ gcc_assert (strip_typedefs_expr (arg, NULL) == arg);
+ }
+}
+
+static void
verify_unstripped_args (tree args)
{
++processing_template_decl;
if (!any_dependent_template_arguments_p (args))
- {
- tree inner = INNERMOST_TEMPLATE_ARGS (args);
- for (int i = 0; i < TREE_VEC_LENGTH (inner); ++i)
- {
- tree arg = TREE_VEC_ELT (inner, i);
- if (TREE_CODE (arg) == TEMPLATE_DECL)
- /* OK */;
- else if (TYPE_P (arg))
- gcc_assert (strip_typedefs (arg, NULL) == arg);
- else if (strip_typedefs (TREE_TYPE (arg), NULL) != TREE_TYPE (arg))
- /* Allow typedefs on the type of a non-type argument, since a
- parameter can have them. */;
- else
- gcc_assert (strip_typedefs_expr (arg, NULL) == arg);
- }
- }
+ verify_unstripped_args_1 (INNERMOST_TEMPLATE_ARGS (args));
--processing_template_decl;
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic173.C b/gcc/testsuite/g++.dg/cpp0x/variadic173.C
new file mode 100644
index 0000000..a0ca89b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic173.C
@@ -0,0 +1,10 @@
+// PR c++/84770
+// { dg-do compile { target c++11 } }
+
+typedef int T;
+
+template<T&...> struct A {};
+
+int i;
+
+A<i> a;