c++ patch to vbase pointer names

Jason Merrill jason@cygnus.com
Thu Oct 1 12:34:00 GMT 1998


I just checked in this patch to fix g++.other/nested2.C, by using the
mangled name instead of the simple name.

1998-10-01  Jason Merrill  <jason@yorick.cygnus.com>

	* cp-tree.h (FORMAT_VBASE_NAME): New macro.
	* class.c (build_vbase_pointer): Use it.
	* rtti.c (expand_class_desc): Likewise.
	* tree.c (build_vbase_pointer_fields): Likewise.

Index: class.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/class.c,v
retrieving revision 1.86
diff -c -p -r1.86 class.c
*** class.c	1998/09/20 12:30:49	1.86
--- class.c	1998/10/01 18:55:19
*************** build_vbase_pointer (exp, type)
*** 146,154 ****
       tree exp, type;
  {
    char *name;
  
-   name = (char *) alloca (TYPE_NAME_LENGTH (type) + sizeof (VBASE_NAME) + 1);
-   sprintf (name, VBASE_NAME_FORMAT, TYPE_NAME_STRING (type));
    return build_component_ref (exp, get_identifier (name), NULL_TREE, 0);
  }
  
--- 146,153 ----
       tree exp, type;
  {
    char *name;
+   FORMAT_VBASE_NAME (name, type);
  
    return build_component_ref (exp, get_identifier (name), NULL_TREE, 0);
  }
  
Index: cp-tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.143
diff -c -p -r1.143 cp-tree.h
*** cp-tree.h	1998/09/25 08:59:49	1.143
--- cp-tree.h	1998/10/01 18:55:20
*************** extern int current_function_parms_stored
*** 2140,2145 ****
--- 2140,2152 ----
    && IDENTIFIER_POINTER (ID_NODE)[2] == 'b' \
    && IDENTIFIER_POINTER (ID_NODE)[3] == JOINER)
  
+ /* Store the vbase pointer field name for type TYPE into pointer BUF.  */
+ #define FORMAT_VBASE_NAME(BUF,TYPE) do {				\
+   BUF = (char *) alloca (TYPE_ASSEMBLER_NAME_LENGTH (TYPE)		\
+ 			 + sizeof (VBASE_NAME) + 1);			\
+   sprintf (BUF, VBASE_NAME_FORMAT, TYPE_ASSEMBLER_NAME_STRING (TYPE));	\
+ } while (0)
+ 
  #define TEMP_NAME_P(ID_NODE) (!strncmp (IDENTIFIER_POINTER (ID_NODE), AUTO_TEMP_NAME, sizeof (AUTO_TEMP_NAME)-1))
  #define VFIELD_NAME_P(ID_NODE) (!strncmp (IDENTIFIER_POINTER (ID_NODE), VFIELD_NAME, sizeof(VFIELD_NAME)-1))
  
Index: rtti.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/rtti.c,v
retrieving revision 1.18
diff -c -p -r1.18 rtti.c
*** rtti.c	1998/09/07 14:25:25	1.18
--- rtti.c	1998/10/01 18:55:20
*************** expand_class_desc (tdecl, type)
*** 801,808 ****
  	  char *name;
  	  tree field;
  
! 	  name = (char *) alloca (TYPE_NAME_LENGTH (t)+sizeof (VBASE_NAME)+1);
! 	  sprintf (name, VBASE_NAME_FORMAT, TYPE_NAME_STRING (t));
  	  field = lookup_field (type, get_identifier (name), 0, 0);
  	  offset = size_binop (FLOOR_DIV_EXPR, 
  		DECL_FIELD_BITPOS (field), size_int (BITS_PER_UNIT));
--- 801,807 ----
  	  char *name;
  	  tree field;
  
! 	  FORMAT_VBASE_NAME (name, t);
  	  field = lookup_field (type, get_identifier (name), 0, 0);
  	  offset = size_binop (FLOOR_DIV_EXPR, 
  		DECL_FIELD_BITPOS (field), size_int (BITS_PER_UNIT));
Index: tree.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/tree.c,v
retrieving revision 1.66
diff -c -p -r1.66 tree.c
*** tree.c	1998/09/24 23:53:35	1.66
--- tree.c	1998/10/01 18:55:20
*************** build_vbase_pointer_fields (rec)
*** 882,889 ****
        if (TREE_VIA_VIRTUAL (base_binfo))
  	{
  	  int j;
! 	  char *name = (char *)alloca (TYPE_NAME_LENGTH (basetype)
! 				       + sizeof (VBASE_NAME) + 1);
  
  	  /* The offset for a virtual base class is only used in computing
  	     virtual function tables and for initializing virtual base
--- 882,888 ----
        if (TREE_VIA_VIRTUAL (base_binfo))
  	{
  	  int j;
! 	  char *name;
  
  	  /* The offset for a virtual base class is only used in computing
  	     virtual function tables and for initializing virtual base
*************** build_vbase_pointer_fields (rec)
*** 903,909 ****
  				   ))
  		goto got_it;
  	    }
! 	  sprintf (name, VBASE_NAME_FORMAT, TYPE_NAME_STRING (basetype));
  	  decl = build_lang_field_decl (FIELD_DECL, get_identifier (name),
  					build_pointer_type (basetype));
  	  /* If you change any of the below, take a look at all the
--- 902,908 ----
  				   ))
  		goto got_it;
  	    }
! 	  FORMAT_VBASE_NAME (name, basetype);
  	  decl = build_lang_field_decl (FIELD_DECL, get_identifier (name),
  					build_pointer_type (basetype));
  	  /* If you change any of the below, take a look at all the



More information about the Gcc-patches mailing list