C++ PATCH: ICE with missing }

Nathan Sidwell nathan@acm.org
Wed Apr 14 03:23:00 GMT 1999


Hi,
here's a patch for the ICE in
http://egcs.cygnus.com/ml/egcs-bugs/1999-03/msg00831.html . Although the code is
wrong, we still ICE after issuing a 'parse error at end of input'. The problem
is that compile_file blindly uses poplevel to pop any unclosed scopes at the
end of a file. If we're inside a class, this is wrong and poplevel_class should
be called.
poplevel checks the scope type we're leaving and aborts if it's a class. Rather
than change toplevel, I patched poplevel to simply call poplevel_class when it
detects a mistake like this. I guess we could be unlucky and ICE somewhere else
...

Enjoy

nathan

-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
      You can up the bandwidth, but you can't up the speed of light      
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk
egcs/gcc/cp/ChangeLog:
Fri Apr  9 19:00:07 BST 1999  Nathan Sidwell  <nathan@acm.org>

	* decl.c (poplevel): Punt to poplevel_class, rather than abort.

Index: egcs/gcc/cp/decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.333
diff -c -3 -p -r1.333 decl.c
*** decl.c	1999/04/02 15:36:08	1.333
--- decl.c	1999/04/09 17:59:53
*************** poplevel (keep, reverse, functionbody)
*** 1331,1339 ****
  
    if (current_binding_level->parm_flag == 2
        || current_binding_level->class_shadowed)
!     /* We should not be using poplevel to pop a class binding level.
!        Use poplevel_class instead.  */
!     my_friendly_abort (0);
  
    /* We used to use KEEP == 2 to indicate that the new block should go
       at the beginning of the list of blocks at this binding level,
--- 1331,1343 ----
  
    if (current_binding_level->parm_flag == 2
        || current_binding_level->class_shadowed)
!     {
!       /* We should not be using poplevel to pop a class binding level.
!          Use poplevel_class instead.  But, we get can get called from the
!          toplevel when there were missing close braces, so call
!          poplevel_class anyway, and keep our fingers crossed.  */
!       return poplevel_class(0);
!     }
  
    /* We used to use KEEP == 2 to indicate that the new block should go
       at the beginning of the list of blocks at this binding level,


More information about the Gcc-patches mailing list