[C++ PATCH]: fix bug 262 ICE

Nathan Sidwell nathan@codesourcery.com
Mon Jun 26 04:07:00 GMT 2000


Hi,
I've installed the attached patch and tests which fix bug 262
That report turned out to be user error, but we ICE before
telling so.

handle_class_head pushes the scope within which the decl it locates
resides. later on we pop the scope of the type to  which that decl
refers to. If that decl is a typedef within one scope to a type in
another scope, we go bang! The common error is to write something like
        class X::X
here X::X is the implicit typedef of ::X within its own scope. So we
push ::X as a scope, but pop ::.

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

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-06-23  Nathan Sidwell  <nathan@codesourcery.com>

	* decl2.c (handle_class_head): Bash typedefs to the type's main
	decl.

Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl2.c,v
retrieving revision 1.370
diff -c -3 -p -r1.370 decl2.c
*** decl2.c	2000/06/23 01:14:39	1.370
--- decl2.c	2000/06/23 10:27:08
*************** handle_class_head (aggr, scope, id)
*** 5362,5368 ****
    tree decl;
  
    if (TREE_CODE (id) == TYPE_DECL)
!     decl = id;
    else if (DECL_CLASS_TEMPLATE_P (id))
      decl = DECL_TEMPLATE_RESULT (id);
    else 
--- 5362,5370 ----
    tree decl;
  
    if (TREE_CODE (id) == TYPE_DECL)
!     /* We must bash typedefs back to the main decl of the type. Otherwise
!        we become confused about scopes.  */
!     decl = TYPE_MAIN_DECL (TREE_TYPE (id));
    else if (DECL_CLASS_TEMPLATE_P (id))
      decl = DECL_TEMPLATE_RESULT (id);
    else 


More information about the Gcc-patches mailing list