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: Avoid crashing on illegal code



This patch fixes a PR recently filed by Gerald Pfiefer.

Tested on i686-pc-linux-gnu.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2000-09-18  Mark Mitchell  <mark@codesourcery.com>

	* decl.c (start_function): Robustify.

Index: testsuite/g++.old-deja/g++.other/crash23.C
===================================================================
RCS file: crash23.C
diff -N crash23.C
*** /dev/null	Tue May  5 13:32:27 1998
--- crash23.C	Mon Sep 18 23:45:57 2000
***************
*** 0 ****
--- 1,7 ----
+ // Build don't link:
+ // Origin: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
+ 
+ class T;
+ inline void operator<(T&, T&) { }
+ inline void operator<(T&, T&) { }
+ 
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.692
diff -c -p -r1.692 decl.c
*** decl.c	2000/09/17 07:38:14	1.692
--- decl.c	2000/09/19 06:46:10
*************** start_function (declspecs, declarator, a
*** 13711,13719 ****
    current_function_decl = decl1;
    cfun->decl = decl1;
  
!   my_friendly_assert ((DECL_PENDING_INLINE_P (decl1) 
! 		       || !DECL_SAVED_FUNCTION_DATA (decl1)),
! 		      20000911);
  
    if (ctype && !doing_friend && !DECL_STATIC_FUNCTION_P (decl1))
      {
--- 13711,13724 ----
    current_function_decl = decl1;
    cfun->decl = decl1;
  
!   /* If we are (erroneously) defining a function that we have already
!      defined before, wipe out what we knew before.  */
!   if (!DECL_PENDING_INLINE_P (decl1) 
!       && DECL_SAVED_FUNCTION_DATA (decl1))
!     {
!       free (DECL_SAVED_FUNCTION_DATA (decl1));
!       DECL_SAVED_FUNCTION_DATA (decl1) = NULL;
!     }
  
    if (ctype && !doing_friend && !DECL_STATIC_FUNCTION_P (decl1))
      {

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