friend.c (is_friend): Be lenient with member functions to deal with nested friends.
authorMark Mitchell <mark@markmitchell.com>
Tue, 28 Jul 1998 16:50:16 +0000 (16:50 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 28 Jul 1998 16:50:16 +0000 (16:50 +0000)
* friend.c (is_friend): Be lenient with member functions to deal
with nested friends.

From-SVN: r21444

gcc/cp/ChangeLog
gcc/cp/friend.c
gcc/testsuite/g++.old-deja/g++.other/friend3.C [new file with mode: 0644]

index f1cd93e5de8079f9278941a5c42807d266a110b1..db4baa19242fd01f10bbb39098847470686d3eb1 100644 (file)
@@ -1,3 +1,8 @@
+1998-07-28  Mark Mitchell  <mark@markmitchell.com>
+
+       * friend.c (is_friend): Be lenient with member functions to deal
+       with nested friends.
+
 1998-07-28  Jason Merrill  <jason@yorick.cygnus.com>
 
        * class.c (finish_struct_1): Convert integer_zero_node to
index 4bd0b08ecff7e4e0c8d6cf3062d57fb81daf495b..5a97766fe0451e01ef7e802d030aa26105044c49 100644 (file)
@@ -77,8 +77,15 @@ is_friend (type, supplicant)
                     friendship.  This is bogus in general since two
                     specializations of a template with non-type
                     template parameters may have the same type, but
-                    be different.  */
-                 if (flag_guiding_decls 
+                    be different.  
+
+                    Temporarily, we are also more lenient to deal
+                    with nested friend functions, for which there can
+                    be more than one FUNCTION_DECL, despite being the
+                    same function.  When that's fixed, the
+                    FUNCTION_MEMBER_P bit can go.  */
+                 if ((flag_guiding_decls 
+                      || DECL_FUNCTION_MEMBER_P (supplicant))
                      && comptypes (TREE_TYPE (supplicant),
                                    TREE_TYPE (TREE_VALUE (friends)), 1))
                    return 1;
diff --git a/gcc/testsuite/g++.old-deja/g++.other/friend3.C b/gcc/testsuite/g++.old-deja/g++.other/friend3.C
new file mode 100644 (file)
index 0000000..84c6b2d
--- /dev/null
@@ -0,0 +1,23 @@
+// Build don't link:
+
+class foo {
+public:
+    class bar;
+    void func(bar *);
+    class bar {
+      int st;
+      friend void foo::func(bar *);
+    };
+};
+
+
+void foo::func(bar *obj) {
+  obj->st++;
+}
+
+void test02() {
+  foo obj_f;
+  foo::bar obj_b;
+  
+  obj_f.func( &obj_b);
+}