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]

PATCH for crash during error-reporting



This patch keeps us from bailing out before reporting errors in
synthesized methods of template classes.

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com

Index: testsuite/g++.old-deja/g++.pt/crash20.C
===================================================================
RCS file: crash20.C
diff -N crash20.C
*** /dev/null	Mon Dec 31 20:00:00 1979
--- crash20.C	Wed Aug 12 14:37:14 1998
***************
*** 0 ****
--- 1,9 ----
+ // Build don't link:
+ 
+ template <class T = int>
+ struct A { const T x; A() : x(0) { } A(T x) : x(x) { } }; 
+ 
+ template <class B>
+ void func () { B y; y = B(); } // ERROR - can't use default assignment
+ 
+ int main (void) { func< A<> >(); } // ERROR - instantiated from here
Index: cp/pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.176
diff -c -p -r1.176 pt.c
*** pt.c	1998/08/09 15:20:39	1.176
--- pt.c	1998/08/12 21:37:38
*************** print_template_context (err)
*** 3699,3723 ****
    int line = lineno;
    char *file = input_filename;
  
!   if (err)
      {
!       if (current_function_decl == p->decl)
! 	/* Avoid redundancy with the the "In function" line.  */;
!       else if (current_function_decl == NULL_TREE)
! 	fprintf (stderr, "%s: In instantiation of `%s':\n",
! 		 file, decl_as_string (p->decl, 0));
        else
- 	my_friendly_abort (980521);
- 
-       if (p)
  	{
  	  line = p->line;
  	  file = p->file;
  	  p = p->next;
  	}
      }
  
-  next:
    for (; p; p = p->next)
      {
        fprintf (stderr, "%s:%d:   instantiated from `%s'\n", file, line,
--- 3699,3726 ----
    int line = lineno;
    char *file = input_filename;
  
!   if (err && p)
      {
!       if (current_function_decl != p->decl
! 	  && current_function_decl != NULL_TREE)
! 	/* We can get here during the processing of some synthesized
! 	   method.  Then, p->decl will be the function that's causing
! 	   the synthesis.  */
! 	;
        else
  	{
+ 	  if (current_function_decl == p->decl)
+ 	    /* Avoid redundancy with the the "In function" line.  */;
+ 	  else 
+ 	    fprintf (stderr, "%s: In instantiation of `%s':\n",
+ 		     file, decl_as_string (p->decl, 0));
+ 	  
  	  line = p->line;
  	  file = p->file;
  	  p = p->next;
  	}
      }
  
    for (; p; p = p->next)
      {
        fprintf (stderr, "%s:%d:   instantiated from `%s'\n", file, line,


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