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]

Message-continuance and bug-report-guiding patch



These patches will make it somewhat easier to emit "clean" multi-line
error messages, when an error or warning message continues over more
than one line, but refers to the same file and line as the first
message.

As you see, this was accomplished by copying and tweaking most of the
message-functions in toplev.c, so this is not really original.

There are multi-line messages that point to more than one file- and
line-pair for the same error or warning.  Each such message will still
look like an individual message for each pair; any need to group
together all the pairs of a message is not addressed by these patches.

For messages from C compilations, this adds the functions
error_cont(), warning_cont() and pedwarn_cont().
For C++, the addition of some functions in cp/errfn.c is called for.
Names like cp_error_cont() and cp_error_cont_at() come to mind.

Except for the multi-line messages asking for bug reports, none have
been adopted yet, though.  See below for examples.


The main effect (after further adaption) is that editors and
programming environments that parse the function name and line number
in the error and warning messages (like emacs), have a chance to stop
at the same line only once per error.  To wit, fewer extra "C-x `" for
your fingers.
 It does not look like any testsuite modifications are needed (yet).


Examples of the old/new output:

bcp-1.c: In function `opt4':
bcp-1.c:26: warning: Delayed evaluation of __builtin_constant_p not supported on this target.
bcp-1.c:26: warning: Please report this as a bug to egcs-bugs@cygnus.com.

bcp-1.c: In function `opt4':
bcp-1.c:26: warning: Delayed evaluation of __builtin_constant_p not supported on this target.
bcp-1.c:               Please submit a full bug report to `egcs-bugs@cygnus.com'.
bcp-1.c:               See the GCC info manual (section Bugs) first,
bcp-1.c:               the file BUGS (included with the sources),
bcp-1.c:               or <URL:http://egcs.cygnus.com/faq.html#bugreport>.


err4.cc:11: Internal compiler error 40.
err4.cc:11: Please submit a full bug report to `egcs-bugs@cygnus.com'.

err4.cc:11: Internal compiler error 40.
err4.cc:      Please submit a full bug report to `egcs-bugs@cygnus.com'.
err4.cc:      See the GCC info manual (section Bugs) first,
err4.cc:      the file BUGS (included with the sources),
err4.cc:      or <URL:http://egcs.cygnus.com/faq.html#bugreport>.

That is, the line number and any "warning" prefix are replaced with
spaces, and the message is indented two extra spaces.  From what I
understand, this is the format that is generally preferred for message
continuance, but it is easily modified if not appropriate.


gcc/ChangeLog:

Sun Sep 13 17:44:58 1998  Hans-Peter Nilsson  <hp@axis.se>

	* toplev.h: Declare warning_cont() error_cont(), pedwarn_cont(),
	pedwarn_cont_with_file_and_line(), warning_cont_with_file_and_line()
	and error_cont_with_file_and_line().

	* toplev.c (v_message_cont_with_file_and_line): New.
	(v_error_cont_with_file_and_line): New.
	(error_cont_with_file_and_line): New.
	(verror_cont): New.
	(v_warning_cont_with_file_and_line): New.
	(warning_cont_with_file_and_line): 
	(vwarning_cont): New.
	(vpedwarn_cont): New.
	(pedwarn_cont): New.
	(v_pedwarn_cont_with_file_and_line): New.
	(pedwarn_cont_with_file_and_line): New.
	(request_bug_report): New.

	* expr.c (expand_builtin): Use request_bug_report() when target
	does not support __builtin_constant_p.


gcc/cp/ChangeLog:

Sun Sep 13 18:13:42 1998  Hans-Peter Nilsson  <hp@axis.se>

	* typeck2.c (my_friendly_abort): Use request_bug_report().

Index: egcs/gcc/expr.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/expr.c,v
retrieving revision 1.95
diff -p -c -r1.95 expr.c
*** expr.c	1998/09/08 22:47:54	1.95
--- expr.c	1998/09/13 15:36:19
*************** expand_builtin (exp, target, subtarget, 
*** 8848,8854 ****
  	      if (! can_handle_constant_p)
  		{
  		  warning ("Delayed evaluation of __builtin_constant_p not supported on this target.");
! 		  warning ("Please report this as a bug to egcs-bugs@cygnus.com.");
  		  return const0_rtx;
  		}
  	      return gen_rtx_CONSTANT_P_RTX (TYPE_MODE (integer_type_node),
--- 8848,8854 ----
  	      if (! can_handle_constant_p)
  		{
  		  warning ("Delayed evaluation of __builtin_constant_p not supported on this target.");
! 		  request_bug_report (warning_cont);
  		  return const0_rtx;
  		}
  	      return gen_rtx_CONSTANT_P_RTX (TYPE_MODE (integer_type_node),
Index: egcs/gcc/toplev.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/toplev.c,v
retrieving revision 1.94
diff -p -c -r1.94 toplev.c
*** toplev.c	1998/09/10 00:40:19	1.94
--- toplev.c	1998/09/13 15:37:18
*************** static char *decl_name PROTO((tree, int)
*** 179,198 ****
--- 179,208 ----
  static void vmessage PROTO((char *, char *, va_list));
  static void v_message_with_file_and_line PROTO((char *, int, char *,
  						char *, va_list));
+ static void v_message_cont_with_file_and_line PROTO((char *, int, char *,
+ 						     char *, va_list)); 
  static void v_message_with_decl PROTO((tree, char *, char *, va_list));
  static void file_and_line_for_asm PROTO((rtx, char **, int *));
  static void v_error_with_file_and_line PROTO((char *, int, char *, va_list));
+ static void v_error_cont_with_file_and_line PROTO((char *, int, char *, va_list));
  static void v_error_with_decl PROTO((tree, char *, va_list));
  static void v_error_for_asm PROTO((rtx, char *, va_list));
  static void verror PROTO((char *, va_list));
+ static void verror_cont PROTO((char *, va_list));
  static void vfatal PROTO((char *, va_list)) ATTRIBUTE_NORETURN;
  static void v_warning_with_file_and_line PROTO ((char *, int, char *, va_list));
+ static void v_warning_cont_with_file_and_line PROTO ((char *, int, char *,
+ 						      va_list));
  static void v_warning_with_decl PROTO((tree, char *, va_list));
  static void v_warning_for_asm PROTO((rtx, char *, va_list));
  static void vwarning PROTO((char *, va_list));
+ static void vwarning_cont PROTO((char *, va_list));
  static void vpedwarn PROTO((char *, va_list));
+ static void vpedwarn_cont PROTO((char *, va_list));
  static void v_pedwarn_with_decl PROTO((tree, char *, va_list));
  static void v_pedwarn_with_file_and_line PROTO((char *, int, char *, va_list));
+ static void v_pedwarn_cont_with_file_and_line PROTO((char *, int, char *,
+ 						     va_list));
  static void vsorry PROTO((char *, va_list));
  static void v_really_sorry PROTO((char *, va_list)) ATTRIBUTE_NORETURN;
  static void float_signal PROTO((int));
*************** v_message_with_file_and_line (file, line
*** 1518,1523 ****
--- 1528,1568 ----
    fputc ('\n', stderr);
  }
  
+ /* Like v_message_with_file_and_line(), but with two extra speces and
+    only whitespace where the linenumber-specification and prefix would
+    be.  If you change v_message_with_file_and_line(), modify this
+    accordingly. */
+ 
+ static void
+ v_message_cont_with_file_and_line (file, line, prefix, s, ap)
+      char *file;
+      int line;
+      char *prefix;
+      char *s;
+      va_list ap;
+ {
+   /* Any sprintf:ed int in decimal, plus ":" will fit here. */
+   char linespec_str[sizeof (int) * 3 + 2];
+   int  n_spaces = 3;
+ 
+   if (prefix)
+     n_spaces += strlen (prefix) + 2;
+ 
+   if (file)
+     {
+       /* Space will replace linenumber and ":".  */
+       sprintf (linespec_str, "%d:", line);
+ 
+       n_spaces += strlen (linespec_str);
+       fprintf (stderr, "%s:%*s", file, n_spaces, " ");
+     }
+   else
+     fprintf (stderr, "%s:%*s", progname, n_spaces, " ");
+ 
+   vfprintf (stderr, s, ap);
+   fputc ('\n', stderr);
+ }
+ 
  /* Print a message relevant to the given DECL.  */
  
  static void
*************** error_with_file_and_line VPROTO((char *f
*** 1653,1658 ****
--- 1698,1737 ----
    va_end (ap);
  }
  
+ /* Continue error report, line LINE of file FILE.  */
+ 
+ static void
+ v_error_cont_with_file_and_line (file, line, s, ap)
+      char *file;
+      int line;
+      char *s;
+      va_list ap;
+ {
+   v_message_cont_with_file_and_line (file, line, (char *)NULL, s, ap);
+ }
+ 
+ void
+ error_cont_with_file_and_line VPROTO((char *file, int line, char *s, ...))
+ {
+ #ifndef __STDC__
+   char *file;
+   int line;
+   char *s;
+ #endif
+   va_list ap;
+ 
+   VA_START (ap, s);
+ 
+ #ifndef __STDC__
+   file = va_arg (ap, char *);
+   line = va_arg (ap, int);
+   s = va_arg (ap, char *);
+ #endif
+ 
+   v_error_cont_with_file_and_line (file, line, s, ap);
+   va_end (ap);
+ }
+ 
  /* Report an error at the declaration DECL.
     S is a format string which uses %s to substitute the declaration
     name; subsequent substitutions are a la printf.  */
*************** error VPROTO((char *s, ...))
*** 1755,1760 ****
--- 1834,1867 ----
    va_end (ap);
  }
  
+ /* Continue an error report.  */
+ 
+ static void
+ verror_cont (s, ap)
+      char *s;
+      va_list ap;
+ {
+   v_message_cont_with_file_and_line (input_filename, lineno, (char *)NULL, s, ap);
+ }
+ 
+ void
+ error_cont VPROTO((char *s, ...))
+ {
+ #ifndef __STDC__
+   char *s;
+ #endif
+   va_list ap;
+ 
+   VA_START (ap, s);
+ 
+ #ifndef __STDC__
+   s = va_arg (ap, char *);
+ #endif
+ 
+   verror_cont (s, ap);
+   va_end (ap);
+ }
+ 
  /* Report a fatal error at the current line number.  */
  
  static void
*************** warning_with_file_and_line VPROTO((char 
*** 1822,1827 ****
--- 1929,1969 ----
    va_end (ap);
  }
  
+ /* Continue a warning at FILE and LINE. */
+ 
+ static void
+ v_warning_cont_with_file_and_line (file, line, s, ap)
+      char *file;
+      int line;
+      char *s;
+      va_list ap;
+ {
+   if (! inhibit_warnings)
+     v_message_cont_with_file_and_line (file, line, "warning", s, ap);
+ }
+ 
+ void
+ warning_cont_with_file_and_line VPROTO((char *file, int line, char *s, ...))
+ {
+ #ifndef __STDC__
+   char *file;
+   int line;
+   char *s;
+ #endif
+   va_list ap;
+ 
+   VA_START (ap, s);
+ 
+ #ifndef __STDC__
+   file = va_arg (ap, char *);
+   line = va_arg (ap, int);
+   s = va_arg (ap, char *);
+ #endif
+ 
+   v_warning_cont_with_file_and_line (file, line, s, ap);
+   va_end (ap);
+ }
+ 
  /* Report a warning at the declaration DECL.
     S is a format string which uses %s to substitute the declaration
     name; subsequent substitutions are a la printf.  */
*************** warning VPROTO((char *s, ...))
*** 1928,1933 ****
--- 2070,2103 ----
    va_end (ap);
  }
  
+ /* Continue a warning message.  */
+ 
+ static void
+ vwarning_cont (s, ap)
+      char *s;
+      va_list ap;
+ {
+   v_warning_cont_with_file_and_line (input_filename, lineno, s, ap);
+ }
+ 
+ void
+ warning_cont VPROTO((char *s, ...))
+ {
+ #ifndef __STDC__
+   char *s;
+ #endif
+   va_list ap;
+ 
+   VA_START (ap, s);
+ 
+ #ifndef __STDC__
+   s = va_arg (ap, char *);
+ #endif
+ 
+   vwarning_cont (s, ap);
+   va_end (ap);
+ }
+ 
  /* These functions issue either warnings or errors depending on
     -pedantic-errors.  */
  
*************** pedwarn VPROTO((char *s, ...))
*** 1961,1966 ****
--- 2131,2165 ----
  }
  
  static void
+ vpedwarn_cont (s, ap)
+      char *s;
+      va_list ap;
+ {
+   if (flag_pedantic_errors)
+     verror_cont (s, ap);
+   else
+     vwarning_cont (s, ap);
+ }
+ 
+ void
+ pedwarn_cont VPROTO((char *s, ...))
+ {
+ #ifndef __STDC__
+   char *s;
+ #endif
+   va_list ap;
+ 
+   VA_START (ap, s);
+ 
+ #ifndef __STDC__
+   s = va_arg (ap, char *);
+ #endif
+ 
+   vpedwarn_cont (s, ap);
+   va_end (ap);
+ }
+ 
+ static void
  v_pedwarn_with_decl (decl, s, ap)
       tree decl;
       char *s;
*************** pedwarn_with_file_and_line VPROTO((char 
*** 2037,2042 ****
--- 2236,2276 ----
    va_end (ap);
  }
  
+ static void
+ v_pedwarn_cont_with_file_and_line (file, line, s, ap)
+      char *file;
+      int line;
+      char *s;
+      va_list ap;
+ {
+   if (flag_pedantic_errors)
+     v_error_cont_with_file_and_line (file, line, s, ap);
+   else
+     v_warning_cont_with_file_and_line (file, line, s, ap);
+ }
+ 
+ void
+ pedwarn_cont_with_file_and_line VPROTO((char *file, int line, char *s, ...))
+ {
+ #ifndef __STDC__
+   char *file;
+   int line;
+   char *s;
+ #endif
+   va_list ap;
+ 
+   VA_START (ap, s);
+ 
+ #ifndef __STDC__
+   file = va_arg (ap, char *);
+   line = va_arg (ap, int);
+   s = va_arg (ap, char *);
+ #endif
+ 
+   v_pedwarn_cont_with_file_and_line (file, line, s, ap);
+   va_end (ap);
+ }
+ 
  /* Apologize for not implementing some feature.  */
  
  static void
*************** really_sorry VPROTO((char *s, ...))
*** 2103,2108 ****
--- 2337,2356 ----
  
    v_really_sorry (s, ap);
    va_end (ap);
+ }
+ 
+ /* Provide a place for bug-report-requests for all languages, to call
+    when the bugs appear.  There are other places with this
+    information, for use with flags "--help" et al.  */
+ 
+ void
+ request_bug_report (errprnt_fn)
+      void (*errprnt_fn) PROTO ((char *, ...));
+ {
+   (*errprnt_fn)  ("Please submit a full bug report to `egcs-bugs@cygnus.com'.");
+   (*errprnt_fn)  ("See the GCC info manual (section Bugs) first,");
+   (*errprnt_fn)  ("the file BUGS (included with the sources),");
+   (*errprnt_fn)  ("or <URL:http://egcs.cygnus.com/faq.html#bugreport>.");
  }
  
  /* More 'friendly' abort that prints the line and file.
Index: egcs/gcc/toplev.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/toplev.h,v
retrieving revision 1.9
diff -p -c -r1.9 toplev.h
*** toplev.h	1998/09/06 05:56:20	1.9
--- toplev.h	1998/09/13 15:37:18
*************** extern void fatal_insn			PROTO ((char *,
*** 28,47 ****
--- 28,60 ----
    ATTRIBUTE_NORETURN;
  extern void warning			PVPROTO ((char *, ...))
  						ATTRIBUTE_PRINTF_1;
+ extern void warning_cont		PVPROTO ((char *, ...))
+ 						ATTRIBUTE_PRINTF_1;
  extern void error			PVPROTO ((char *, ...))
  						ATTRIBUTE_PRINTF_1;
+ extern void error_cont			PVPROTO ((char *, ...))
+ 						ATTRIBUTE_PRINTF_1;
  extern void pedwarn			PVPROTO ((char *, ...))
  						ATTRIBUTE_PRINTF_1;
+ extern void pedwarn_cont		PVPROTO ((char *, ...))
+ 						ATTRIBUTE_PRINTF_1;
  extern void pedwarn_with_file_and_line	PVPROTO ((char *, int, char *, ...))
  						ATTRIBUTE_PRINTF_3;
+ extern void pedwarn_cont_with_file_and_line PVPROTO ((char *, int, char *, ...))
+ 						ATTRIBUTE_PRINTF_3;
  extern void warning_with_file_and_line	PVPROTO ((char *, int, char *, ...))
  						ATTRIBUTE_PRINTF_3;
+ extern void warning_cont_with_file_and_line PVPROTO ((char *, int, char *, ...))
+ 						ATTRIBUTE_PRINTF_3;
  extern void error_with_file_and_line	PVPROTO ((char *, int, char *, ...))
  						ATTRIBUTE_PRINTF_3;
+ extern void error_cont_with_file_and_line PVPROTO ((char *, int, char *, ...))
+ 						ATTRIBUTE_PRINTF_3;
  extern void sorry			PVPROTO ((char *s, ...))
  						ATTRIBUTE_PRINTF_1;
  extern void really_sorry		PVPROTO((char *s, ...))
    ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
+ extern void request_bug_report		PROTO ((void (*)(char *, ...)));
  extern void default_print_error_function PROTO ((char *));
  extern void report_error_function	PROTO ((char *));
  
Index: egcs/gcc/cp/typeck2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/typeck2.c,v
retrieving revision 1.30
diff -p -c -r1.30 typeck2.c
*** typeck2.c	1998/09/07 14:25:34	1.30
--- typeck2.c	1998/09/13 15:37:29
*************** my_friendly_abort (i)
*** 383,389 ****
  	    ack ("Internal compiler error.");
  	  else
  	    ack ("Internal compiler error %d.", i);
! 	  ack ("Please submit a full bug report to `egcs-bugs@cygnus.com'.");
  	}
        else
  	error ("confused by earlier errors, bailing out");
--- 383,390 ----
  	    ack ("Internal compiler error.");
  	  else
  	    ack ("Internal compiler error %d.", i);
! 
! 	  request_bug_report (error_cont);
  	}
        else
  	error ("confused by earlier errors, bailing out");
*************** my_friendly_abort (i)
*** 397,403 ****
    else
      error ("Internal compiler error %d.", i);
  
!   fatal ("Please submit a full bug report to `egcs-bugs@cygnus.com'.");
  }
  
  void
--- 398,405 ----
    else
      error ("Internal compiler error %d.", i);
  
!   request_bug_report (error_cont);
!   exit (FATAL_EXIT_CODE);
  }
  
  void

brgds, H-P
-- 
Hans-Peter Nilsson, Axis Communications AB, S - 223 70 LUND, SWEDEN
Hans-Peter.Nilsson@axis.se | Tel +46 462701867,2701800
Fax +46 46136130 | RFC 1855 compliance implemented; report loss of brain.


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