Hi,
just reminded the hard way that, for friend *template* declarations,
cp_parser_init_declarator (vs cp_parser_member_declaration) has to pass
the actual friend_p information. I'm finishing testing the below.
Thanks,
Paolo.
//////////////////////
/cp
2014-06-11 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/19200
* parser.c (cp_parser_init_declarator): Actually pass friend_p
to cp_parser_declarator.
/testsuite
2014-06-11 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/19200
* g++.dg/parse/friend11.C: New.
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 211479)
+++ cp/parser.c (working copy)
@@ -16545,7 +16545,7 @@ cp_parser_init_declarator (cp_parser* parser,
bool is_direct_init = false;
bool is_non_constant_init;
int ctor_dtor_or_conv_p;
- bool friend_p;
+ bool friend_p = cp_parser_friend_p (decl_specifiers);
tree pushed_scope = NULL_TREE;
bool range_for_decl_p = false;
bool saved_default_arg_ok_p = parser->default_arg_ok_p;
@@ -16574,7 +16574,7 @@ cp_parser_init_declarator (cp_parser* parser,
= cp_parser_declarator (parser, CP_PARSER_DECLARATOR_NAMED,
&ctor_dtor_or_conv_p,
/*parenthesized_p=*/NULL,
- member_p, /*friend_p=*/false);
+ member_p, friend_p);
/* Gather up the deferred checks. */
stop_deferring_access_checks ();
@@ -16746,9 +16746,6 @@ cp_parser_init_declarator (cp_parser* parser,
decl_specifiers->type = integer_type_node;
}
- /* Check to see whether or not this declaration is a friend. */
- friend_p = cp_parser_friend_p (decl_specifiers);
-
/* Enter the newly declared entry in the symbol table. If we're
processing a declaration in a class-specifier, we wait until
after processing the initializer. */
Index: testsuite/g++.dg/parse/friend11.C
===================================================================
--- testsuite/g++.dg/parse/friend11.C (revision 0)
+++ testsuite/g++.dg/parse/friend11.C (working copy)
@@ -0,0 +1,6 @@
+// PR c++/19200
+
+struct S {
+ struct T{};
+ template<typename> friend void S(T);
+};