(C++) patch to struct tree_binding

Jason Merrill jason@cygnus.com
Thu Jan 28 10:50:00 GMT 1999


The old code required the C compiler to support assignment to a cast, a gcc
extension.

1999-01-28  Jason Merrill  <jason@yorick.cygnus.com>

	* cp-tree.h (struct tree_binding): Replace scope field with a union.
	(BINDING_SCOPE): Adjust.
	* decl.c (BINDING_LEVEL): Adjust.

Index: cp-tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.191
diff -c -p -r1.191 cp-tree.h
*** cp-tree.h	1999/01/26 02:33:41	1.191
--- cp-tree.h	1999/01/28 17:44:25
*************** typedef struct ptrmem_cst
*** 138,144 ****
     _TYPE node, or a NAMESPACE_DECL.)  This macro should be used only
     for namespace-level bindings; on the IDENTIFIER_BINDING list
     BINDING_LEVEL is used instead.  */
! #define BINDING_SCOPE(NODE) ((tree) ((struct tree_binding*)NODE)->scope)
  
  /* This is the declaration bound to the name. Possible values:
     variable, overloaded function, namespace, template, enumerator.  */
--- 138,144 ----
     _TYPE node, or a NAMESPACE_DECL.)  This macro should be used only
     for namespace-level bindings; on the IDENTIFIER_BINDING list
     BINDING_LEVEL is used instead.  */
! #define BINDING_SCOPE(NODE) (((struct tree_binding*)NODE)->scope.scope)
  
  /* This is the declaration bound to the name. Possible values:
     variable, overloaded function, namespace, template, enumerator.  */
*************** typedef struct ptrmem_cst
*** 159,165 ****
  struct tree_binding
  {
    char common[sizeof (struct tree_common)];
!   void* scope;
    tree value;
  };
  
--- 159,168 ----
  struct tree_binding
  {
    char common[sizeof (struct tree_common)];
!   union {
!     tree scope;
!     struct binding_level *level;
!   } scope;
    tree value;
  };
  
Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.304
diff -c -p -r1.304 decl.c
*** decl.c	1999/01/26 02:33:43	1.304
--- decl.c	1999/01/28 17:44:26
*************** pushlevel_temporary (tag_transparent)
*** 1039,1045 ****
  /* For a binding between a name and an entity at a block scope,
     this is the `struct binding_level' for the block.  */
  #define BINDING_LEVEL(NODE) \
!    ((struct binding_level*) ((struct tree_binding*)NODE)->scope)
  
  /* These are currently unused, but permanent, CPLUS_BINDING nodes.
     They are kept here because they are allocated from the permanent
--- 1039,1045 ----
  /* For a binding between a name and an entity at a block scope,
     this is the `struct binding_level' for the block.  */
  #define BINDING_LEVEL(NODE) \
!    (((struct tree_binding*)NODE)->scope.level)
  
  /* These are currently unused, but permanent, CPLUS_BINDING nodes.
     They are kept here because they are allocated from the permanent



More information about the Gcc-patches mailing list