mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-28 06:14:10 +08:00
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
This commit is contained in:
parent
56e3f54ca0
commit
7f84cec92c
@ -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"))
|
||||
@ -736,6 +743,7 @@ lang_decode_option (argc, argv)
|
||||
/* Only warn about unknown pragmas that are not in system
|
||||
headers. */
|
||||
warn_unknown_pragmas = 1;
|
||||
warn_nontemplate_friend = setting;
|
||||
}
|
||||
else return strings_processed;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user