From 9b7dd5e868e5c3978ea8c6cfef383c2846321ddf Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 28 Mar 2007 14:05:29 +0000 Subject: decl.c (redeclaration_error_message): Complain when redeclaring a friend function with default template arguments... 2007-03-28 Douglas Gregor * decl.c (redeclaration_error_message): Complain when redeclaring a friend function with default template arguments (C++0x mode only). * cp-tree.h (check_default_tmpl_args): Declare. * pt.c (check_default_tmpl_args): In C++0x mode, permit default template arguments in function templates. Add support for checking the default template arguments of friend templates. (push_template_decl_real): Fix call to check_default_tmpl_args. (type_unification_real): If a template parameter has not been deduced but provides a default template argument, substitute into that default template argument. * parser.c (cp_parser_init_declarator): When declaring (but not defining!) a function template in C++0x mode, check for default template arguments. 2007-03-28 Douglas Gregor * g++.dg/cpp0x/temp_default1.C: New. * g++.dg/cpp0x/temp_default3.C: New. * g++.dg/cpp0x/temp_default2.C: New. * g++.dg/cpp0x/temp_default4.C: New. From-SVN: r123300 --- gcc/cp/parser.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/cp/parser.c') diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index ec90726..da573cb 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -11721,6 +11721,13 @@ cp_parser_init_declarator (cp_parser* parser, ((is_parenthesized_init || !is_initialized) ? 0 : LOOKUP_ONLYCONVERTING)); } + else if (flag_cpp0x && friend_p && decl && TREE_CODE (decl) == FUNCTION_DECL) + /* Core issue #226 (C++0x only): A default template-argument + shall not be specified in a friend class template + declaration. */ + check_default_tmpl_args (decl, current_template_parms, /*is_primary=*/1, + /*is_partial=*/0, /*is_friend_decl=*/1); + if (!friend_p && pushed_scope) pop_scope (pushed_scope); -- cgit v1.1