This is the mail archive of the gcc-bugs@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]

PATCH for local classes in egcs 980214 make crash



>>>>> "David" == David C Binderman <dcb@pncl.co.uk> writes:

    David> Hello there,

    David> The following code produces an internal compiler error on
    David> egcs-980214, and for most of this year's versions of egcs.

Here's a patch for this abort.  Jason, is this OK?

-- 
Mark Mitchell		mmitchell@usa.net
Stanford University	http://www.stanford.edu

void
f()
{
  class Local_2 {
    friend class Friend;

    int i;
  };
  
  class Friend {
  public:
    void g() {
      Local_2 l2;
      l2.i = 3;
    }
  };
}

Wed Mar 11 16:21:15 1998  Mark Mitchell  <mmitchell@usa.net>

	* decl.c (pushtag): Deal with friend class injection in local
	classes.

Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.75
diff -c -p -r1.75 decl.c
*** decl.c	1998/03/03 22:26:57	1.75
--- decl.c	1998/03/12 00:17:38
*************** pushtag (name, type, globalize)
*** 2170,2177 ****
    if (name)
      {
        context = type ? TYPE_CONTEXT (type) : NULL_TREE;
!       if (! context && ! globalize)
!         context = current_scope ();
        if (context)
  	c_decl = TREE_CODE (context) == FUNCTION_DECL
  	  ? context : TYPE_MAIN_DECL (context);
--- 2170,2188 ----
    if (name)
      {
        context = type ? TYPE_CONTEXT (type) : NULL_TREE;
!       if (! context)
! 	{
! 	  tree cs = current_scope ();
! 
! 	  if (! globalize)
! 	    context = cs;
! 	  else if (cs != NULL_TREE 
! 		   && TREE_CODE_CLASS (TREE_CODE (cs)) == 't')
! 	    /* When declaring a friend class of a local class, we want
! 	       to inject the newly named class into the scope
! 	       containing the local class, not the namespace scope.  */
! 	    context = hack_decl_function_context (get_type_decl (cs));
! 	}
        if (context)
  	c_decl = TREE_CODE (context) == FUNCTION_DECL
  	  ? context : TYPE_MAIN_DECL (context);


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