/* Help friends in C++.
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
- 2007 Free Software Foundation, Inc.
+ 2007, 2008 Free Software Foundation, Inc.
This file is part of GCC.
tree friends = FRIEND_DECLS (list);
for (; friends ; friends = TREE_CHAIN (friends))
{
- tree friend = TREE_VALUE (friends);
+ tree this_friend = TREE_VALUE (friends);
- if (friend == NULL_TREE)
+ if (this_friend == NULL_TREE)
continue;
- if (supplicant == friend)
+ if (supplicant == this_friend)
return 1;
- if (is_specialization_of_friend (supplicant, friend))
+ if (is_specialization_of_friend (supplicant, this_friend))
return 1;
}
break;
int class_template_depth = template_class_depth (type);
int friend_depth = processing_template_decl - class_template_depth;
- if (! IS_AGGR_TYPE (friend_type))
+ if (! MAYBE_CLASS_TYPE_P (friend_type))
{
error ("invalid type %qT declared %<friend%>", friend_type);
return;
else if (same_type_p (type, friend_type))
{
if (complain)
- pedwarn ("class %qT is implicitly friends with itself",
+ warning (0, "class %qT is implicitly friends with itself",
type);
return;
}
bool funcdef_flag)
{
gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
- gcc_assert (!ctype || IS_AGGR_TYPE (ctype));
+ gcc_assert (!ctype || MAYBE_CLASS_TYPE_P (ctype));
/* Every decl that gets here is a friend of something. */
DECL_FRIEND_P (decl) = 1;
+ /* Unfortunately, we have to handle attributes here. Normally we would
+ handle them in start_decl_1, but since this is a friend decl start_decl_1
+ never gets to see it. */
+
+ /* Set attributes here so if duplicate decl, will have proper attributes. */
+ cplus_decl_attributes (&decl, attrlist, 0);
+
if (TREE_CODE (declarator) == TEMPLATE_ID_EXPR)
{
declarator = TREE_OPERAND (declarator, 0);
if (warn)
{
static int explained;
- warning (OPT_Wnon_template_friend, "friend declaration "
- "%q#D declares a non-template function", decl);
- if (! explained)
+ bool warned;
+
+ warned = warning (OPT_Wnon_template_friend, "friend declaration "
+ "%q#D declares a non-template function", decl);
+ if (! explained && warned)
{
- inform ("(if this is not what you intended, make sure "
+ inform (input_location, "(if this is not what you intended, make sure "
"the function template has already been declared "
"and add <> after the function name here) ");
explained = 1;
DECL_FRIEND_P (decl) = 1;
}
- /* Unfortunately, we have to handle attributes here. Normally we would
- handle them in start_decl_1, but since this is a friend decl start_decl_1
- never gets to see it. */
-
- /* Set attributes here so if duplicate decl, will have proper attributes. */
- cplus_decl_attributes (&decl, attrlist, 0);
-
return decl;
}