Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!tut.cis.ohio-state.edu!UUNET.UU.NET!jclark!jjc
From: jclark!jjc@UUNET.UU.NET (James Clark)
Newsgroups: gnu.g++.bug
Subject: friend bug and fix
Message-ID: <8908181219.AA27643@jclark.uucp>
Date: 18 Aug 89 12:19:33 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 55

g++ 1.35.1- incorrectly accepts this:

class A {
  int n;
 public:
  A();
  friend int foo(double);
  friend int foo(char);
};

int foo(A a)
{
  return a.n;
}

I think the fix for this is:

*** cplus-init.c.distrib        Fri Aug 18 13:01:19 1989
--- cplus-init.c        Fri Aug 18 13:02:00 1989
***************
*** 1703,1717 ****
  add_friend (type, decl)
       tree type, decl;
  {
    tree typedecl = TYPE_NAME (type);
    tree list = DECL_FRIENDLIST (typedecl);
    tree name = DECL_ORIGINAL_NAME (decl);
    tree ctype = TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE
!     ? TYPE_METHOD_BASETYPE (TREE_TYPE (decl)) : NULL_TREE;

    while (list)
      {
        if (name == TREE_PURPOSE (list))
        {
          tree friends = TREE_VALUE (list);
          while (friends)
--- 1703,1717 ----
  add_friend (type, decl)
       tree type, decl;
  {
    tree typedecl = TYPE_NAME (type);
    tree list = DECL_FRIENDLIST (typedecl);
    tree name = DECL_ORIGINAL_NAME (decl);
    tree ctype = TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE
!     ? TYPE_METHOD_BASETYPE (TREE_TYPE (decl)) : error_mark_node;

    while (list)
      {
        if (name == TREE_PURPOSE (list))
        {
          tree friends = TREE_VALUE (list);
          while (friends)

James Clark
jjc@jclark.uucp