mirror of git://gcc.gnu.org/git/gcc.git
re PR c++/66850 (Adding a forward declaration of a template containing a template template parm causes ICE on valid code)
Fix PR c++/66850 gcc/cp/ChangeLog: PR c++/66850 * pt.c (redeclare_class_template): Set the DECL_CONTEXTs of each template template parm in the redeclaration. (lookup_template_class_1): Peel off irrelevant template levels from current_template_parms before augmenting the argument list. gcc/testsuite/ChangeLog: PR c++/66850 * g++.dg/template/pr66850.C: New test. From-SVN: r225801
This commit is contained in:
parent
524d2e49f2
commit
09f725f4a6
|
|
@ -1,3 +1,12 @@
|
||||||
|
2015-07-14 Patrick Palka <ppalka@gcc.gnu.org>
|
||||||
|
|
||||||
|
PR c++/66850
|
||||||
|
* pt.c (redeclare_class_template): Set the DECL_CONTEXTs of each
|
||||||
|
template template parm in the redeclaration.
|
||||||
|
(lookup_template_class_1): Peel off irrelevant template levels
|
||||||
|
from current_template_parms before augmenting the argument
|
||||||
|
list.
|
||||||
|
|
||||||
2015-07-14 Andrea Azzarone <azzaronea@gmail.com>
|
2015-07-14 Andrea Azzarone <azzaronea@gmail.com>
|
||||||
|
|
||||||
PR c++/65071
|
PR c++/65071
|
||||||
|
|
|
||||||
25
gcc/cp/pt.c
25
gcc/cp/pt.c
|
|
@ -5302,6 +5302,14 @@ redeclare_class_template (tree type, tree parms)
|
||||||
/* Update the new parameters, too; they'll be used as the
|
/* Update the new parameters, too; they'll be used as the
|
||||||
parameters for any members. */
|
parameters for any members. */
|
||||||
TREE_PURPOSE (TREE_VEC_ELT (parms, i)) = tmpl_default;
|
TREE_PURPOSE (TREE_VEC_ELT (parms, i)) = tmpl_default;
|
||||||
|
|
||||||
|
/* Give each template template parm in this redeclaration a
|
||||||
|
DECL_CONTEXT of the template for which they are a parameter. */
|
||||||
|
if (TREE_CODE (parm) == TEMPLATE_DECL)
|
||||||
|
{
|
||||||
|
gcc_assert (DECL_CONTEXT (parm) == NULL_TREE);
|
||||||
|
DECL_CONTEXT (parm) = tmpl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -7754,9 +7762,20 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context,
|
||||||
if (outer)
|
if (outer)
|
||||||
outer = TI_ARGS (get_template_info (DECL_TEMPLATE_RESULT (outer)));
|
outer = TI_ARGS (get_template_info (DECL_TEMPLATE_RESULT (outer)));
|
||||||
else if (current_template_parms)
|
else if (current_template_parms)
|
||||||
/* This is an argument of the current template, so we haven't set
|
{
|
||||||
DECL_CONTEXT yet. */
|
/* This is an argument of the current template, so we haven't set
|
||||||
outer = current_template_args ();
|
DECL_CONTEXT yet. */
|
||||||
|
tree relevant_template_parms;
|
||||||
|
|
||||||
|
/* Parameter levels that are greater than the level of the given
|
||||||
|
template template parm are irrelevant. */
|
||||||
|
relevant_template_parms = current_template_parms;
|
||||||
|
while (TMPL_PARMS_DEPTH (relevant_template_parms)
|
||||||
|
!= TEMPLATE_TYPE_LEVEL (TREE_TYPE (templ)))
|
||||||
|
relevant_template_parms = TREE_CHAIN (relevant_template_parms);
|
||||||
|
|
||||||
|
outer = template_parms_to_args (relevant_template_parms);
|
||||||
|
}
|
||||||
|
|
||||||
if (outer)
|
if (outer)
|
||||||
arglist = add_to_template_args (outer, arglist);
|
arglist = add_to_template_args (outer, arglist);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,8 @@
|
||||||
|
2015-07-14 Patrick Palka <ppalka@gcc.gnu.org>
|
||||||
|
|
||||||
|
PR c++/66850
|
||||||
|
* g++.dg/template/pr66850.C: New test.
|
||||||
|
|
||||||
2015-07-14 Sandra Loosemore <sandra@codesourcery.com>
|
2015-07-14 Sandra Loosemore <sandra@codesourcery.com>
|
||||||
Cesar Philippidis <cesar@codesourcery.com>
|
Cesar Philippidis <cesar@codesourcery.com>
|
||||||
Chung-Lin Tang <cltang@codesourcery.com>
|
Chung-Lin Tang <cltang@codesourcery.com>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
// PR c++/66850
|
||||||
|
// Each namespace contains an otherwise standalone test case, none of which
|
||||||
|
// should cause an ICE.
|
||||||
|
|
||||||
|
namespace X {
|
||||||
|
template <template <typename U, U> class> struct Sort;
|
||||||
|
|
||||||
|
template <template <typename U, U> class Comparator>
|
||||||
|
struct Sort
|
||||||
|
{
|
||||||
|
template <int I>
|
||||||
|
struct less_than
|
||||||
|
{
|
||||||
|
Comparator<int, I> a;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Y {
|
||||||
|
template <typename C, C> struct integral_constant {};
|
||||||
|
|
||||||
|
template <typename T, template <typename U, U> class> struct Sort;
|
||||||
|
|
||||||
|
template <template <typename U, U> class Comparator>
|
||||||
|
struct Sort<int, Comparator>
|
||||||
|
{
|
||||||
|
template <int I> struct less_than:
|
||||||
|
integral_constant<bool, Comparator<int, I>::value> {};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Z {
|
||||||
|
template <typename T, template <typename U, U> class> struct Sort;
|
||||||
|
|
||||||
|
template <template <typename U, U> class Comparator>
|
||||||
|
struct Sort<int, Comparator>
|
||||||
|
{
|
||||||
|
template <int I>
|
||||||
|
struct less_than
|
||||||
|
{
|
||||||
|
Comparator<int, I> a;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue