Commit 3807059e by Jason Merrill Committed by Jason Merrill

re PR c++/58632 (ICE reusing template parameter name as class name)

	PR c++/58632
	* decl.c (lookup_and_check_tag): Ignore template parameters if
	scope == ts_current.
	* pt.c (check_template_shadow): Don't complain about the injected
	class name.

From-SVN: r207208
parent 1b2b9969
2014-01-28 Jason Merrill <jason@redhat.com>
PR c++/58632
* decl.c (lookup_and_check_tag): Ignore template parameters if
scope == ts_current.
* pt.c (check_template_shadow): Don't complain about the injected
class name.
* decl.c (duplicate_decls): Tweak.
PR c++/53756
......
......@@ -11982,7 +11982,10 @@ lookup_and_check_tag (enum tag_types tag_code, tree name,
if (decl
&& (DECL_CLASS_TEMPLATE_P (decl)
|| DECL_TEMPLATE_TEMPLATE_PARM_P (decl)))
/* If scope is ts_current we're defining a class, so ignore a
template template parameter. */
|| (scope != ts_current
&& DECL_TEMPLATE_TEMPLATE_PARM_P (decl))))
decl = DECL_TEMPLATE_RESULT (decl);
if (decl && TREE_CODE (decl) == TYPE_DECL)
......
......@@ -3527,6 +3527,11 @@ check_template_shadow (tree decl)
&& TEMPLATE_PARMS_FOR_INLINE (current_template_parms)))
return true;
/* Don't complain about the injected class name, as we've already
complained about the class itself. */
if (DECL_SELF_REFERENCE_P (decl))
return false;
error ("declaration of %q+#D", decl);
error (" shadows template parm %q+#D", olddecl);
return false;
......
// PR c++/58632
template<template<int I> class A> // { dg-message "shadows" }
class A {}; // { dg-error "declaration" }
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