Commit d7df0b91 by Dodji Seketeli Committed by Dodji Seketeli

re PR c++/43558 (Rejects specialization)

Fix PR c++/43558

gcc/cp/ChangeLog:
	PR c++/43558
	* cp-tree.h (TEMPLATE_TYPE_PARM_SIBLING_PARMS): New accessor macro.
	* pt.c (end_template_parm_list): Store sibling template parms of
	each TEMPLATE_TYPE_PARMs into its TEMPLATE_TYPE_PARM_SIBLING_PARMS.
	(push_template_decl_real): Don't store the containing template decl
	into the DECL_CONTEXT of TEMPLATE_TYPE_PARMs anymore.
	* typeck.c (get_template_parms_of_dependent_type): Get sibling parms
	of a TEMPLATE_TYPE_PARM from TEMPLATE_TYPE_PARM_SIBLING_PARMS.
	Simplify the logic.

gcc/testsuite/ChangeLog:
	PR c++/43558
	* g++.dg/template/typedef31.C: New test.

From-SVN: r157857
parent f0c01ffd
2010-03-31 Dodji Seketeli <dodji@redhat.com>
PR c++/43558
* cp-tree.h (TEMPLATE_TYPE_PARM_SIBLING_PARMS): New accessor macro.
* pt.c (end_template_parm_list): Store sibling template parms of
each TEMPLATE_TYPE_PARMs into its TEMPLATE_TYPE_PARM_SIBLING_PARMS.
(push_template_decl_real): Don't store the containing template decl
into the DECL_CONTEXT of TEMPLATE_TYPE_PARMs anymore.
* typeck.c (get_template_parms_of_dependent_type): Get sibling parms
of a TEMPLATE_TYPE_PARM from TEMPLATE_TYPE_PARM_SIBLING_PARMS.
Simplify the logic.
2010-03-30 Jason Merrill <jason@redhat.com>
PR c++/43076
......
......@@ -4240,6 +4240,10 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, TYPENAME_FLAG };
(TEMPLATE_PARM_DECL (TEMPLATE_TYPE_PARM_INDEX (NODE)))
#define TEMPLATE_TYPE_PARAMETER_PACK(NODE) \
(TEMPLATE_PARM_PARAMETER_PACK (TEMPLATE_TYPE_PARM_INDEX (NODE)))
/* The list of template parms that a given template parameter of type
TEMPLATE_TYPE_PARM belongs to.*/
#define TEMPLATE_TYPE_PARM_SIBLING_PARMS(NODE) \
(TREE_CHECK ((NODE), TEMPLATE_TYPE_PARM))->type.maxval
/* These constants can used as bit flags in the process of tree formatting.
......
......@@ -3571,6 +3571,9 @@ end_template_parm_list (tree parms)
next = TREE_CHAIN (parm);
TREE_VEC_ELT (saved_parmlist, nparms) = parm;
TREE_CHAIN (parm) = NULL_TREE;
if (TREE_CODE (TREE_VALUE (parm)) == TYPE_DECL)
TEMPLATE_TYPE_PARM_SIBLING_PARMS (TREE_TYPE (TREE_VALUE (parm))) =
current_template_parms;
}
--processing_template_parmlist;
......@@ -4622,9 +4625,6 @@ template arguments to %qD do not match original template %qD",
tree parm = TREE_VALUE (TREE_VEC_ELT (parms, i));
if (TREE_CODE (parm) == TEMPLATE_DECL)
DECL_CONTEXT (parm) = tmpl;
if (TREE_CODE (TREE_TYPE (parm)) == TEMPLATE_TYPE_PARM)
DECL_CONTEXT (TYPE_NAME (TREE_TYPE (parm))) = tmpl;
}
}
......
......@@ -1110,36 +1110,22 @@ get_template_parms_of_dependent_type (tree t)
template info from T itself. */
if ((tinfo = get_template_info (t)))
;
/* If T1 is a typedef or whatever has a template info associated
to its context, get the template parameters from that context. */
else if (TREE_CODE (t) == TEMPLATE_TYPE_PARM)
return TEMPLATE_TYPE_PARM_SIBLING_PARMS (t);
else if (typedef_variant_p (t)
&& !NAMESPACE_SCOPE_P (TYPE_NAME (t)))
tinfo = get_template_info (DECL_CONTEXT (TYPE_NAME (t)));
else if (TREE_CODE (t) == TEMPLATE_TYPE_PARM
&& DECL_CONTEXT (TYPE_NAME (t)) == NULL_TREE)
/* We have not yet created the DECL_TEMPLATE this
template type parm belongs to. It probably means
that we are in the middle of parsing the template parameters
of a template, and T is one of the parameters we have parsed.
Let's return the list of template parms we have parsed so far. */
return get_template_parms_at_level (current_template_parms,
TEMPLATE_TYPE_LEVEL (t));
/* If T is a TYPENAME_TYPE which context is a template type
parameter, get the template parameters from that context. */
else if (TYPE_CONTEXT (t)
&& TREE_CODE (TYPE_CONTEXT (t)) == TEMPLATE_TYPE_PARM)
return TEMPLATE_TYPE_PARM_SIBLING_PARMS (TYPE_CONTEXT (t));
else if (TYPE_CONTEXT (t)
&& !NAMESPACE_SCOPE_P (t))
tinfo = get_template_info (TYPE_CONTEXT (t));
if (tinfo)
tparms = DECL_TEMPLATE_PARMS (TI_TEMPLATE (tinfo));
/* If T is a template type parameter, get the template parameter
set it is part of. */
else if (TREE_CODE (t) == TEMPLATE_TYPE_PARM
&& DECL_CONTEXT (TYPE_NAME (t)))
tparms = DECL_TEMPLATE_PARMS (DECL_CONTEXT (TYPE_NAME (t)));
/* If T is a TYPENAME_TYPE which context is a template type
parameter, get the template parameters from that context. */
else if (TYPE_CONTEXT (t)
&& TREE_CODE (TYPE_CONTEXT (t)) == TEMPLATE_TYPE_PARM)
tparms = get_template_parms_of_dependent_type (TYPE_CONTEXT (t));
return tparms;
}
......
2010-03-31 Dodji Seketeli <dodji@redhat.com>
PR c++/43558
* g++.dg/template/typedef31.C: New test.
2010-03-31 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* g++.dg/ext/visibility/pragma-override1.C: Allow for .hidden in
......
// Origin: PR c++/43558
// { dg-do compile }
class Compressible;
template <class T, class EngineTag> class Engine;
template <class T>
class Engine<T, Compressible>
{
public:
typedef T Element_t;
//Element_t read(int);
T read(int);
};
template <class T>
T Engine<T, Compressible>::read(int)
{
}
Engine<int, Compressible> x;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment