summaryrefslogtreecommitdiff
path: root/gcc/cp/friend.c
diff options
context:
space:
mode:
authoraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2001-02-15 12:54:18 +0000
committeraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2001-02-15 12:54:18 +0000
commit8f966d798871cdbed21b5d8b3bfe165f0442700f (patch)
tree81ac9d8e1448195f72838801e225a13df0dd869d /gcc/cp/friend.c
parentce24a99a9efb0d85add3e2274cb6a18d4637ef67 (diff)
downloadgcc-8f966d798871cdbed21b5d8b3bfe165f0442700f.tar.gz
* friend.c (do_friend): Don't take the nested [template] class
into account when deciding whether to warn about the friend function not referring to a template function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39713 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/friend.c')
-rw-r--r--gcc/cp/friend.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c
index b817c7c3917..170f63bea1d 100644
--- a/gcc/cp/friend.c
+++ b/gcc/cp/friend.c
@@ -380,6 +380,14 @@ do_friend (ctype, declarator, decl, parmdecls, attrlist,
if (! DECL_USE_TEMPLATE (decl))
{
+ /* We must check whether the decl refers to template
+ arguments before push_template_decl_real adds a
+ reference to the containing template class. */
+ int warn = (warn_nontemplate_friend
+ && ! funcdef_flag && ! is_friend_template
+ && current_template_parms
+ && uses_template_parms (decl));
+
/* We can call pushdecl here, because the TREE_CHAIN of this
FUNCTION_DECL is not needed for other purposes. Don't do
this for a template instantiation. However, we don't
@@ -393,9 +401,7 @@ do_friend (ctype, declarator, decl, parmdecls, attrlist,
else
decl = push_template_decl_real (decl, /*is_friend=*/1);
- if (warn_nontemplate_friend
- && ! funcdef_flag && ! is_friend_template
- && current_template_parms && uses_template_parms (decl))
+ if (warn)
{
static int explained;
cp_warning ("friend declaration `%#D' declares a non-template function", decl);