Commit 4d3f2fa6 by Jason Merrill Committed by Jason Merrill

re PR c++/53492 (ICE in retrieve_specialization, at cp/pt.c:985)

	PR c++/53492
	* parser.c (cp_parser_class_head): Also check PRIMARY_TEMPLATE_P
	when deciding whether to call push_template_decl for a member class.
	* pt.c (push_template_decl_real): Return after wrong levels error.

From-SVN: r208455
parent 31dad809
2014-03-10 Jason Merrill <jason@redhat.com>
PR c++/53492
* parser.c (cp_parser_class_head): Also check PRIMARY_TEMPLATE_P
when deciding whether to call push_template_decl for a member class.
* pt.c (push_template_decl_real): Return after wrong levels error.
2014-03-08 Adam Butcher <adam@jessamine.co.uk> 2014-03-08 Adam Butcher <adam@jessamine.co.uk>
PR c++/60033 PR c++/60033
......
...@@ -19888,7 +19888,13 @@ cp_parser_class_head (cp_parser* parser, ...@@ -19888,7 +19888,13 @@ cp_parser_class_head (cp_parser* parser,
pushed_scope = push_scope (nested_name_specifier); pushed_scope = push_scope (nested_name_specifier);
/* Get the canonical version of this type. */ /* Get the canonical version of this type. */
type = TYPE_MAIN_DECL (TREE_TYPE (type)); type = TYPE_MAIN_DECL (TREE_TYPE (type));
if (PROCESSING_REAL_TEMPLATE_DECL_P () /* Call push_template_decl if it seems like we should be defining a
template either from the template headers or the type we're
defining, so that we diagnose both extra and missing headers. */
if ((PROCESSING_REAL_TEMPLATE_DECL_P ()
|| (CLASSTYPE_TEMPLATE_INFO (TREE_TYPE (type))
&& PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE
(TREE_TYPE (type)))))
&& !CLASSTYPE_TEMPLATE_SPECIALIZATION (TREE_TYPE (type))) && !CLASSTYPE_TEMPLATE_SPECIALIZATION (TREE_TYPE (type)))
{ {
type = push_template_decl (type); type = push_template_decl (type);
......
...@@ -4908,6 +4908,8 @@ push_template_decl_real (tree decl, bool is_friend) ...@@ -4908,6 +4908,8 @@ push_template_decl_real (tree decl, bool is_friend)
{ {
error ("expected %d levels of template parms for %q#D, got %d", error ("expected %d levels of template parms for %q#D, got %d",
i, decl, TMPL_ARGS_DEPTH (args)); i, decl, TMPL_ARGS_DEPTH (args));
DECL_INTERFACE_KNOWN (decl) = 1;
return error_mark_node;
} }
else else
for (current = decl; i > 0; --i, parms = TREE_CHAIN (parms)) for (current = decl; i > 0; --i, parms = TREE_CHAIN (parms))
......
// PR c++/53492
template<typename T> struct A
{
template<typename U> struct B;
};
template <> template<class T> struct A<T>::B { }; // { dg-error "expected 2 levels" }
A<int>::B<int> b; // { dg-error "" }
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