OSDN Git Service

* call.c (struct z_candidate): Add explicit_targs field.
[pf3gnuchains/gcc-fork.git] / gcc / cp / friend.c
index ffb0baa..03748fe 100644 (file)
@@ -1,6 +1,6 @@
 /* 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.
 
@@ -59,15 +59,15 @@ is_friend (tree type, tree supplicant)
              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;
@@ -227,7 +227,7 @@ make_friend_class (tree type, tree friend_type, bool complain)
   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;
@@ -253,7 +253,7 @@ make_friend_class (tree type, tree friend_type, bool complain)
   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;
     }
@@ -408,11 +408,18 @@ do_friend (tree ctype, tree declarator, tree decl,
           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);
@@ -561,11 +568,13 @@ do_friend (tree ctype, tree declarator, tree decl,
          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;
@@ -582,12 +591,5 @@ do_friend (tree ctype, tree declarator, tree decl,
       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;
 }