🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1828

problem with pointers to members

#1828
From: Michael Tiemann
Date: Mon, 03 Apr 1989 15:53
188 lines
5898 bytes
I will be sending a copy of this to bug-g++@prep.ai.mit.edu, but
possibly with a few more changes to cplus-decl.c.

Michael

   Date: Sun, 2 Apr 89 10:10:53 BST
   From: James Clark <mcvax!jclark!jjc@uunet.uu.net>

   g++ rejects a valid program:

   Script started on Sun Apr  2 08:52:56 1989
   jclark% cat test.c
   struct foo {
     void bar(int foo::*p);
   };

   void foo::bar(int foo::*p)
   {
   }

   jclark% g++ -c -v test.c
   g++ version 1.34.1
    /usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ test.c /tmp/cca27586.cpp
   GNU CPP version 1.34
    /usr/local/lib/gcc-c++ /tmp/cca27586.cpp -quiet -dumpbase test.c -version -o /tmp/cca27586.s
   GNU C++ version 1.34.1 (sparc) compiled by GNU C version 1.34.
   In method foo::bar ((struct foo ::*)):
   test.c:6: conflicting types for `void foo::bar ((struct foo ::*))'
   test.c:2: previous declaration of `void foo::bar ((struct foo ::*))'
   jclark% exit
   jclark% 
   script done on Sun Apr  2 08:53:22 1989

   James Clark
   jjc@jclark.uucp
   uunet!mcvax!jclark!jjc

Here are 3 fixes from 1.34.2 sources which will get this back on
track.  Actually, only one fix is needed, but the other two are useful
in the case that the program actually were errorneous:


yahi% diff -c2 cplus-decl.c~ cplus-decl.c
*** cplus-decl.c~	Sun Apr  2 19:47:20 1989
--- cplus-decl.c	Mon Apr  3 08:48:30 1989
***************
*** 908,918 ****
  
    finish_function (1);
    /* Now tell GNU LD that this is part of the static destructor set.  */
    {
      extern struct _iob *asm_out_file;
!     fprintf (asm_out_file, ".stabs \"___DTOR_LIST__\", 0x16, 0, 0, ");
      assemble_name (asm_out_file, IDENTIFIER_POINTER (fnname));
      fputc ('\n', asm_out_file);
    }
  
    /* if it needed cleaning, then it will need messing up: drop through  */
--- 908,921 ----
  
    finish_function (1);
+ 
+ #ifndef FASCIST_ASSEMBLER
    /* Now tell GNU LD that this is part of the static destructor set.  */
    {
      extern struct _iob *asm_out_file;
!     fprintf (asm_out_file, ".stabs \"___DTOR_LIST__\",22,0,0,");
      assemble_name (asm_out_file, IDENTIFIER_POINTER (fnname));
      fputc ('\n', asm_out_file);
    }
+ #endif
  
    /* if it needed cleaning, then it will need messing up: drop through  */
***************
*** 994,1005 ****
  
        finish_function (1);
        /* Now tell GNU LD that this is part of the static constructor set.  */
        {
          extern struct _iob *asm_out_file;
!         fprintf (asm_out_file, ".stabs \"___CTOR_LIST__\", 0x16, 0, 0, ");
          assemble_name (asm_out_file, IDENTIFIER_POINTER (fnname));
          fputc ('\n', asm_out_file);
        }
! 
      }
  
--- 997,1009 ----
  
        finish_function (1);
+ #ifndef FASCIST_ASSEMBLER
        /* Now tell GNU LD that this is part of the static constructor set.  */
        {
          extern struct _iob *asm_out_file;
!         fprintf (asm_out_file, ".stabs \"___CTOR_LIST__\",22,0,0,");
          assemble_name (asm_out_file, IDENTIFIER_POINTER (fnname));
          fputc ('\n', asm_out_file);
        }
! #endif
      }
  
***************
*** 1155,1164 ****
        finish_function (1);
  
        {
          extern struct _iob *asm_out_file;
!         fprintf (asm_out_file, ".stabs \"___ZTOR_LIST__\", 0x16, 0, 0, ");
          assemble_name (asm_out_file, IDENTIFIER_POINTER (fnname));
          fputc ('\n', asm_out_file);
        }
      }
  #endif
--- 1159,1170 ----
        finish_function (1);
  
+ #ifndef FASCIST_ASSEMBLER
        {
          extern struct _iob *asm_out_file;
!         fprintf (asm_out_file, ".stabs \"___ZTOR_LIST__\",22,0,0,");
          assemble_name (asm_out_file, IDENTIFIER_POINTER (fnname));
          fputc ('\n', asm_out_file);
        }
+ #endif
      }
  #endif
***************
*** 7540,7546 ****
--- 7546,7556 ----
    else
      {
+       int hashcode;
+ 
        t = make_node (MEMBER_TYPE);
        TYPE_METHOD_BASETYPE (t) = basetype;
        TREE_TYPE (t) = type;
+       hashcode = TREE_UID (basetype) + TREE_UID (type);
+       t = type_hash_canon (hashcode, t);
      }
    return t;
yahi% diff -c2 cplus-typeck.c~ cplus-typeck.c
*** cplus-typeck.c~	Mon Apr  3 00:02:05 1989
--- cplus-typeck.c	Mon Apr  3 08:18:25 1989
***************
*** 436,439 ****
--- 436,444 ----
        return 0;
  
+     case MEMBER_TYPE:
+       return (comptypes (TYPE_POINTER_TO (TYPE_METHOD_BASETYPE (t1)),
+ 			 TYPE_POINTER_TO (TYPE_METHOD_BASETYPE (t2)), strict)
+ 	      && comptypes (TREE_TYPE (t1), TREE_TYPE (t2), strict));
+ 
      case METHOD_TYPE:
        /* This case is anti-symmetrical!
yahi% diff -c2 cplus-method.c~ cplus-method.c
*** cplus-method.c~	Sun Apr  2 03:32:20 1989
--- cplus-method.c	Mon Apr  3 07:59:54 1989
***************
*** 173,177 ****
  	  }
  
! 	dump_type_prefix (TREE_TYPE (type), &old_p);
  
  	OB_PUTC ('(');
--- 173,177 ----
  	  }
  
! 	dump_type_prefix (type, &old_p);
  
  	OB_PUTC ('(');
***************
*** 192,196 ****
  	  OB_PUTS ("auto ");
  
! 	dump_type_prefix (TREE_TYPE (type), &old_p);
  
  	OB_PUTC ('(');
--- 192,196 ----
  	  OB_PUTS ("auto ");
  
! 	dump_type_prefix (type, &old_p);
  
  	OB_PUTC ('(');

yahi% 

Michael
Technical Details
Message-ID: <8904031553.AA04712@yahi.stanford.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!YAHI.STANFORD.EDU!mdt
References: <8904020910.AA27649@jclark.uucp>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!YAHI.STANFORD.EDU!mdt
From: mdt@YAHI.STANFORD.EDU (Michael Tiemann)
Newsgroups: gnu.g++.bug
Subject: problem with pointers to members
Message-ID: <8904031553.AA04712@yahi.stanford.edu>
Date: 3 Apr 89 15:53:08 GMT
References: <8904020910.AA27649@jclark.uucp>
Sender: daemon@tut.cis.ohio-state.edu
Reply-To: tiemann@lurch.stanford.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 188