Commit 1cd7d7bf by Mark Mitchell Committed by Mark Mitchell

re PR c++/29020 (ICE using A<N>::A instead of A<N> in friend declaration)

	PR c++/29020
	* friend.c (do_friend): Improve comments; add assertion.
	* parser.c (cp_parser_nested_name_specifier_opt): Resolve
	typenames for qualified names used in declarations, even when
	caching qualified name lookup.
	PR c++/29020
	* g++.dg/template/friend48.C: New test.

From-SVN: r117425
parent 404d8401
2006-10-03 Mark Mitchell <mark@codesourcery.com> 2006-10-03 Mark Mitchell <mark@codesourcery.com>
PR c++/29020
* friend.c (do_friend): Improve comments; add assertion.
* parser.c (cp_parser_nested_name_specifier_opt): Resolve
typenames for qualified names used in declarations, even when
caching qualified name lookup.
PR c++/29138 PR c++/29138
* decl2.c (grokfield): Don't handle access declarations here. * decl2.c (grokfield): Don't handle access declarations here.
* parser.c (cp_parser_using_declaration): Handle access * parser.c (cp_parser_using_declaration): Handle access
......
...@@ -396,21 +396,21 @@ make_friend_class (tree type, tree friend_type, bool complain) ...@@ -396,21 +396,21 @@ make_friend_class (tree type, tree friend_type, bool complain)
} }
} }
/* Main friend processor. /* Record DECL (a FUNCTION_DECL) as a friend of the
CURRENT_CLASS_TYPE. If DECL is a member function, CTYPE is the
CTYPE is the class this friend belongs to. class of which it is a member, as named in the friend declaration.
DECLARATOR is the name of the friend. FUNCDEF_FLAG is true if the
DECLARATOR is the name of the friend. friend declaration is a definition of the function. FLAGS is as
for grokclass fn. */
DECL is the FUNCTION_DECL that the friend is.
FLAGS is just used for `grokclassfn'. */
tree tree
do_friend (tree ctype, tree declarator, tree decl, do_friend (tree ctype, tree declarator, tree decl,
tree attrlist, enum overload_flags flags, tree attrlist, enum overload_flags flags,
bool funcdef_flag) bool funcdef_flag)
{ {
gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
gcc_assert (!ctype || IS_AGGR_TYPE (ctype));
/* Every decl that gets here is a friend of something. */ /* Every decl that gets here is a friend of something. */
DECL_FRIEND_P (decl) = 1; DECL_FRIEND_P (decl) = 1;
...@@ -421,8 +421,6 @@ do_friend (tree ctype, tree declarator, tree decl, ...@@ -421,8 +421,6 @@ do_friend (tree ctype, tree declarator, tree decl,
declarator = DECL_NAME (get_first_fn (declarator)); declarator = DECL_NAME (get_first_fn (declarator));
} }
gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
if (ctype) if (ctype)
{ {
/* CLASS_TEMPLATE_DEPTH counts the number of template headers for /* CLASS_TEMPLATE_DEPTH counts the number of template headers for
......
...@@ -3632,10 +3632,17 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, ...@@ -3632,10 +3632,17 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser,
{ {
/* Grab the nested-name-specifier and continue the loop. */ /* Grab the nested-name-specifier and continue the loop. */
cp_parser_pre_parsed_nested_name_specifier (parser); cp_parser_pre_parsed_nested_name_specifier (parser);
/* If we originally encountered this nested-name-specifier
with IS_DECLARATION set to false, we will not have
resolved TYPENAME_TYPEs, so we must do so here. */
if (is_declaration if (is_declaration
&& TREE_CODE (parser->scope) == TYPENAME_TYPE) && TREE_CODE (parser->scope) == TYPENAME_TYPE)
parser->scope = resolve_typename_type (parser->scope, {
/*only_current_p=*/false); new_scope = resolve_typename_type (parser->scope,
/*only_current_p=*/false);
if (new_scope != error_mark_node)
parser->scope = new_scope;
}
success = true; success = true;
continue; continue;
} }
......
2006-10-03 Mark Mitchell <mark@codesourcery.com>
PR c++/29020
* g++.dg/template/friend48.C: New test.
2006-10-04 Paul Thomas <pault@gcc.gnu.org> 2006-10-04 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29098 PR fortran/29098
// PR c++/29020
template<int> struct A
{
void foo();
};
struct B
{
template<int N> friend void A<N>::A::foo();
};
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