diff options
author | Benjamin Kosnik <bkoz@gcc.gnu.org> | 1998-09-03 16:10:00 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@gcc.gnu.org> | 1998-09-03 16:10:00 +0000 |
commit | 7f84cec92c19faa9e728407d8809dbf5562f17f0 (patch) | |
tree | bfc27424252d98ef221b076b7d7e7eb1207eecfd /gcc | |
parent | 56e3f54ca01ad037f6d84e382c1b769c406eaf33 (diff) | |
download | gcc-7f84cec92c19faa9e728407d8809dbf5562f17f0.zip gcc-7f84cec92c19faa9e728407d8809dbf5562f17f0.tar.gz gcc-7f84cec92c19faa9e728407d8809dbf5562f17f0.tar.bz2 |
cp-tree.h: Declare warn_nontemplate_friend.
d
1998-09-03 Benjamin Kosnik <bkoz@cygnus.com>
* 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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/decl2.c | 10 | ||||
-rw-r--r-- | gcc/cp/friend.c | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index f5c1031..e24af37 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 561c9d7..d01ecda 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; } } |