From: Benjamin Kosnik Date: Thu, 3 Sep 1998 16:10:00 +0000 (+0000) Subject: cp-tree.h: Declare warn_nontemplate_friend. X-Git-Tag: prereleases/libgcj-0.1~3225 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7f84cec92c19faa9e728407d8809dbf5562f17f0;p=thirdparty%2Fgcc.git cp-tree.h: Declare warn_nontemplate_friend. d 1998-09-03 Benjamin Kosnik * cp-tree.h: Declare warn_nontemplate_friend. * decl2.c (lang_decode_option): Set. * lang-options.h: Add -Wnon-template-friend. * friend.c (do_friend): Use to toggle non-template function warning. g++/17054 From-SVN: r22220 --- diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index f5c1031502d2..e24af379e971 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -307,6 +307,11 @@ int warn_unknown_pragmas; /* Tri state variable. */ int warn_multichar = 1; +/* Nonzero means warn when non-templatized friend functions are + declared within a template */ + +int warn_nontemplate_friend = 1; + /* Nonzero means `$' can be in an identifier. */ #ifndef DOLLARS_IN_IDENTIFIERS @@ -704,6 +709,8 @@ lang_decode_option (argc, argv) /* Set to greater than 1, so that even unknown pragmas in system headers will be warned about. */ warn_unknown_pragmas = setting * 2; + else if (!strcmp (p, "non-template-friend")) + warn_nontemplate_friend = setting; else if (!strcmp (p, "comment")) ; /* cpp handles this one. */ else if (!strcmp (p, "comments")) @@ -735,7 +742,8 @@ lang_decode_option (argc, argv) warn_sign_promo = setting; /* Only warn about unknown pragmas that are not in system headers. */ - warn_unknown_pragmas = 1; + warn_unknown_pragmas = 1; + warn_nontemplate_friend = setting; } else return strings_processed; } diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 561c9d747b32..d01ecdafdf16 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -447,7 +447,8 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag) else decl = push_template_decl_real (decl, /*is_friend=*/1); - if (! funcdef_flag && ! flag_guiding_decls && ! is_friend_template + if (warn_nontemplate_friend + && ! funcdef_flag && ! flag_guiding_decls && ! is_friend_template && current_template_parms && uses_template_parms (decl)) { static int explained; @@ -458,6 +459,7 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag) warning (" (if this is not what you intended, make sure"); warning (" the function template has already been declared,"); warning (" and add <> after the function name here)"); + warning (" To disable warning use -Wno-non-template-friend"); explained = 1; } }