From b4e93c5826ee7112463d2ed0ee9a4959b5362b78 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 17 Jan 2018 13:08:05 -0500 Subject: [PATCH] PR c++/81843 - ICE with variadic member template. PR c++/72801 * pt.c (unify_pack_expansion): Don't try to deduce enclosing template args. From-SVN: r256808 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/pt.c | 3 +++ gcc/testsuite/g++.dg/cpp0x/variadic171.C | 12 ++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic171.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a041f355e40..1cae4acaaca 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2018-01-17 Jason Merrill + PR c++/81843 - ICE with variadic member template. + PR c++/72801 + * pt.c (unify_pack_expansion): Don't try to deduce enclosing + template args. + PR c++/82331 - ICE with variadic partial specialization of auto * pt.c (unify) [TEMPLATE_PARM_INDEX]: Set processing_template_decl around call to tsubst. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9b5c35b4a21..5687bb21252 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -20068,6 +20068,7 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms, /* Add in any args remembered from an earlier partial instantiation. */ targs = add_to_template_args (PACK_EXPANSION_EXTRA_ARGS (parm), targs); + int levels = TMPL_ARGS_DEPTH (targs); packed_args = expand_template_argument_pack (packed_args); @@ -20083,6 +20084,8 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms, /* Determine the index and level of this parameter pack. */ template_parm_level_and_index (parm_pack, &level, &idx); + if (level < levels) + continue; /* Keep track of the parameter packs and their corresponding argument packs. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic171.C b/gcc/testsuite/g++.dg/cpp0x/variadic171.C new file mode 100644 index 00000000000..1e268141d6d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic171.C @@ -0,0 +1,12 @@ +// PR c++/81843 +// { dg-do compile { target c++11 } } + +template < typename > struct A; +template < typename, typename > struct B; +template < typename ... S > struct C +{ + template < typename > struct D {}; + template < typename ... T > struct D < A < B < S, T > ... > >; +}; + +C <>::D < A < B < int, int > > > c;