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]
Other format: [Raw text]

[PATCH] Fix 19608


Hi,
this patch fixes 19608, an ICE on invalid.  A friend function defined inside
a local class is ill-formed, but we create a DECL with the same context as
the function containing the class -- rather than set the context to *be*
that function.  This causes us to not correctly restore the context after
parsing the friend function's body. Fixed by pushing and popping
current_function_decl, rather than looking at the inline function's context
at all.

booted & tested on i686-pc-linux-gnu.

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2005-02-14  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/19608
	* parser.c (cp_parser_late_parsing_for_member): Use
	current_function_decl as scope to push to and from.

Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.315
diff -c -3 -p -r1.315 parser.c
*** cp/parser.c	10 Feb 2005 04:39:41 -0000	1.315
--- cp/parser.c	14 Feb 2005 15:30:11 -0000
*************** cp_parser_late_parsing_for_member (cp_pa
*** 15286,15294 ****
        tokens = DECL_PENDING_INLINE_INFO (member_function);
        DECL_PENDING_INLINE_INFO (member_function) = NULL;
        DECL_PENDING_INLINE_P (member_function) = 0;
!       /* If this was an inline function in a local class, enter the scope
! 	 of the containing function.  */
!       function_scope = decl_function_context (member_function);
        if (function_scope)
  	push_function_context_to (function_scope);
  
--- 15286,15295 ----
        tokens = DECL_PENDING_INLINE_INFO (member_function);
        DECL_PENDING_INLINE_INFO (member_function) = NULL;
        DECL_PENDING_INLINE_P (member_function) = 0;
!       
!       /* If this is a local class, enter the scope of the containing
! 	 function.  */
!       function_scope = current_function_decl;
        if (function_scope)
  	push_function_context_to (function_scope);
  
 // Copyright (C) 2005 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 14 Feb 2005 <nathan@codesourcery.com>

// Origin: Jorn Wolfgang Rennecke <amylaar@gcc.gnu.org>
// Bug 19608: ICE on invalid


void f ()
{
  class c
    {
      friend void g () { } // { dg-error "local class definition" "" }
    };
}

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