This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[C++ PATCH]: Fix bug 3


Hi,
I've installed this patch which fixes bug 3 where a typedef member
did not get its name injected properly during declaring a class.

built & tested on i686-pc-linux-gnu, approved by Mark

nathan

-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2000-11-28  Nathan Sidwell  <nathan@codesourcery.com>

	* decl.c (struct binding_level): Adjust class_shadowed comments
	to reflect reality.
	(push_class_level_binding): Ajust comments to reflect reality.
	Set IDENTIFIER_CLASS_VALUE when replacing an existing binding.
	Don't set TREE_VALUE on the class_shadowed list.

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.717
diff -c -3 -p -r1.717 decl.c
*** decl.c	2000/11/27 12:53:37	1.717
--- decl.c	2000/11/28 09:44:27
*************** struct binding_level
*** 433,447 ****
  
      /* If this binding level is the binding level for a class, then
         class_shadowed is a TREE_LIST.  The TREE_PURPOSE of each node
!        is the name of an entity bound in the class; the TREE_VALUE is
!        the IDENTIFIER_CLASS_VALUE before we entered the class.  Thus,
!        when leaving class scope, we can restore the
!        IDENTIFIER_CLASS_VALUE by walking this list.  The TREE_TYPE is
         the DECL bound by this name in the class.  */
      tree class_shadowed;
  
      /* Similar to class_shadowed, but for IDENTIFIER_TYPE_VALUE, and
!        is used for all binding levels.  */
      tree type_shadowed;
  
      /* A TREE_LIST.  Each TREE_VALUE is the LABEL_DECL for a local
--- 433,445 ----
  
      /* If this binding level is the binding level for a class, then
         class_shadowed is a TREE_LIST.  The TREE_PURPOSE of each node
!        is the name of an entity bound in the class.  The TREE_TYPE is
         the DECL bound by this name in the class.  */
      tree class_shadowed;
  
      /* Similar to class_shadowed, but for IDENTIFIER_TYPE_VALUE, and
!        is used for all binding levels. In addition the TREE_VALUE is the
!        IDENTIFIER_TYPE_VALUE before we entered the class.  */
      tree type_shadowed;
  
      /* A TREE_LIST.  Each TREE_VALUE is the LABEL_DECL for a local
*************** push_class_level_binding (name, x)
*** 4432,4440 ****
        else
  	old_decl = BINDING_VALUE (binding);
  
!       /* There was already a binding for X containing fewer
! 	 functions than are named in X.  Find the previous
! 	 declaration of X on the class-shadowed list, and update it.  */
        for (shadow = class_binding_level->class_shadowed;
  	   shadow;
  	   shadow = TREE_CHAIN (shadow))
--- 4430,4437 ----
        else
  	old_decl = BINDING_VALUE (binding);
  
!       /* Find the previous binding of name on the class-shadowed
!          list, and update it.  */
        for (shadow = class_binding_level->class_shadowed;
  	   shadow;
  	   shadow = TREE_CHAIN (shadow))
*************** push_class_level_binding (name, x)
*** 4444,4460 ****
  	    BINDING_VALUE (binding) = x;
  	    INHERITED_VALUE_BINDING_P (binding) = 0;
  	    TREE_TYPE (shadow) = x;
  	    return;
  	  }
      }
  
    /* If we didn't replace an existing binding, put the binding on the
!      stack of bindings for the identifier, and update
!      IDENTIFIER_CLASS_VALUE.  */
    if (push_class_binding (name, x))
      {
        class_binding_level->class_shadowed
! 	= tree_cons (name, IDENTIFIER_CLASS_VALUE (name),
  		     class_binding_level->class_shadowed);
        /* Record the value we are binding NAME to so that we can know
  	 what to pop later.  */
--- 4441,4457 ----
  	    BINDING_VALUE (binding) = x;
  	    INHERITED_VALUE_BINDING_P (binding) = 0;
  	    TREE_TYPE (shadow) = x;
+ 	    IDENTIFIER_CLASS_VALUE (name) = x;
  	    return;
  	  }
      }
  
    /* If we didn't replace an existing binding, put the binding on the
!      stack of bindings for the identifier, and update the shadowed list.  */
    if (push_class_binding (name, x))
      {
        class_binding_level->class_shadowed
! 	= tree_cons (name, NULL,
  		     class_binding_level->class_shadowed);
        /* Record the value we are binding NAME to so that we can know
  	 what to pop later.  */
Index: testsuite/g++.old-deja/g++.other/lookup16.C
===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/g++.old-deja/g++.other/lookup16.C,v
retrieving revision 1.3
diff -c -3 -p -r1.3 lookup16.C
*** lookup16.C	1999/09/08 08:50:57	1.3
--- lookup16.C	2000/11/28 09:44:27
***************
*** 2,11 ****
  // Copyright (C) 1999 Free Software Foundation, Inc.
  // Contributed by Nathan Sidwell 25 Aug 1999 <nathan@acm.org>
  
  // typenames are not injected early enough, [basic.scope.pdecl]3.3.1/4
  // indicates this should compile.
- 
- // excess errors test - XFAIL
  
  struct A {
  };
--- 2,10 ----
  // Copyright (C) 1999 Free Software Foundation, Inc.
  // Contributed by Nathan Sidwell 25 Aug 1999 <nathan@acm.org>
  
+ // Bug 3
  // typenames are not injected early enough, [basic.scope.pdecl]3.3.1/4
  // indicates this should compile.
  
  struct A {
  };

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]