From: Mark Mitchell Date: Tue, 28 Jul 1998 16:50:16 +0000 (+0000) Subject: friend.c (is_friend): Be lenient with member functions to deal with nested friends. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8fb08bdddfb1f19debb76262e8afb99d39a789ea;p=gcc.git friend.c (is_friend): Be lenient with member functions to deal with nested friends. * friend.c (is_friend): Be lenient with member functions to deal with nested friends. From-SVN: r21444 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f1cd93e5de8..db4baa19242 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +1998-07-28 Mark Mitchell + + * friend.c (is_friend): Be lenient with member functions to deal + with nested friends. + 1998-07-28 Jason Merrill * class.c (finish_struct_1): Convert integer_zero_node to diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 4bd0b08ecff..5a97766fe04 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -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 index 00000000000..84c6b2d3b7c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/friend3.C @@ -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); +}