]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cp-tree.h: Declare warn_nontemplate_friend.
authorBenjamin Kosnik <bkoz@gcc.gnu.org>
Thu, 3 Sep 1998 16:10:00 +0000 (16:10 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Thu, 3 Sep 1998 16:10:00 +0000 (16:10 +0000)
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

gcc/cp/decl2.c
gcc/cp/friend.c

index f5c1031502d22ebcc082271a977d68926064c585..e24af379e9712f767e29342e99cd7925a515d8bc 100644 (file)
@@ -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;
     }
index 561c9d747b321beaaf2f1d86a6847d77c80dea9a..d01ecdafdf1646734bacfd35d75a4a0ff551bf19 100644 (file)
@@ -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;
                }
            }