This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Error handling change
- To: gcc-patches at gcc dot gnu dot org
- Subject: Error handling change
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- Date: Sat, 16 Dec 00 11:25:49 EST
The record addition of finish_abort had the affect of removing the
utility of fatal_error_function, so I reworked the code to restore it
while keeping the change that led to its inclusion. I also enhanced
trim_filename to work better when the error is from a language subdirectory.
I also added some blank lines before function declarations, but didn't
clutter up the diff below with them.
Sat Dec 16 10:41:11 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* diagnostic.c (finish_abort): Deleted.
(fatal): Add code from fninish_abort.
(error_recursion, fancy_abort): Call fatal, not finish_abort.
(trim_filename): Remove leading "../".
* diagnostic.h (finish_abort): Deleted.
* toplev.c (crash_signal): Call fatal, not finish_abort.
*** diagnostic.c 2000/12/04 17:14:15 1.46
--- diagnostic.c 2000/12/16 12:58:45
*************** fatal VPARAMS ((const char *msgid, ...))
*** 1410,1413 ****
--- 1419,1428 ----
#endif
+ if (errorcount > 1 || sorrycount > 0)
+ {
+ fprintf (stderr, "confused by earlier errors, bailing out\n");
+ exit (FATAL_EXIT_CODE);
+ }
+
if (fatal_function != 0)
(*fatal_function) (_(msgid), &ap);
*************** fatal VPARAMS ((const char *msgid, ...))
*** 1417,1420 ****
--- 1432,1439 ----
report_diagnostic (&dc);
va_end (ap);
+
+ fprintf
+ (stderr, "Please submit a full bug report.\n See %s for instructions.\n",
+ GCCBUGURL);
exit (FATAL_EXIT_CODE);
}
*************** error_recursion ()
*** 1638,1644 ****
finish_diagnostic ();
! fputs (_("Internal compiler error: Error reporting routines re-entered.\n"),
! stderr);
! finish_abort ();
}
--- 1663,1667 ----
finish_diagnostic ();
! fatal ("Internal compiler error: Error reporting routines re-entered.");
}
*************** trim_filename (name)
*** 1653,1658 ****
static const char this_file[] = __FILE__;
const char *p = name, *q = this_file;
! while (*p == *q && *p != 0 && *q != 0) p++, q++;
while (p > name && p[-1] != DIR_SEPARATOR
#ifdef DIR_SEPARATOR_2
--- 1677,1704 ----
static const char this_file[] = __FILE__;
const char *p = name, *q = this_file;
+
+ /* First skip any "../" in each filename. This allows us to give a proper
+ reference to a file in a subdirectory. */
+ while (p[0] == '.' && p[1] == '.'
+ && (p[2] == DIR_SEPARATOR
+ #ifdef DIR_SEPARATOR_2
+ || p[2] == DIR_SEPARATOR_2
+ #endif
+ ))
+ p += 3;
! while (q[0] == '.' && q[1] == '.'
! && (q[2] == DIR_SEPARATOR
! #ifdef DIR_SEPARATOR_2
! || p[2] == DIR_SEPARATOR_2
! #endif
! ))
! q += 3;
!
! /* Now skip any parts the two filenames have in common. */
! while (*p == *q && *p != 0 && *q != 0)
! p++, q++;
!
! /* Now go backwards until the previous directory separator. */
while (p > name && p[-1] != DIR_SEPARATOR
#ifdef DIR_SEPARATOR_2
*************** fancy_abort (file, line, function)
*** 1674,1703 ****
const char *function;
{
! error ("Internal compiler error in %s, at %s:%d",
function, trim_filename (file), line);
- finish_abort ();
}
- /* Finish reporting an internal compiler error. If the only error we've
- seen is the current one, encourage the user to file a bug report;
- otherwise, fixing their code will probably avoid the crash. */
-
- void
- finish_abort ()
- {
- if (errorcount > 1 || sorrycount > 0)
- fprintf (stderr, "confused by earlier errors, bailing out\n");
- else
- fprintf (stderr, "\
- Please submit a full bug report.\n\
- See %s for instructions.\n",
- GCCBUGURL);
-
- exit (FATAL_EXIT_CODE);
- }
-
/* Setup DC for reporting a diagnostic MESSAGE (an error or a WARNING),
using arguments pointed to by ARGS_PTR, issued at a location specified
by FILE and LINE. */
void
set_diagnostic_context (dc, message, args_ptr, file, line, warn)
--- 1720,1731 ----
const char *function;
{
! fatal ("Internal compiler error in %s, at %s:%d",
function, trim_filename (file), line);
}
/* Setup DC for reporting a diagnostic MESSAGE (an error or a WARNING),
using arguments pointed to by ARGS_PTR, issued at a location specified
by FILE and LINE. */
+
void
set_diagnostic_context (dc, message, args_ptr, file, line, warn)
*** diagnostic.h 2000/12/01 19:31:01 1.19
--- diagnostic.h 2000/12/16 12:58:46
*************** int error_function_changed PARAMS (
*** 208,212 ****
void record_last_error_function PARAMS ((void));
void report_problematic_module PARAMS ((output_buffer *));
- void finish_abort PARAMS ((void)) ATTRIBUTE_NORETURN;
#endif /* __GCC_DIAGNOSTIC_H__ */
--- 208,211 ----
*** toplev.c 2000/12/07 07:56:42 1.404
--- toplev.c 2000/12/16 12:59:09
*************** crash_signal (signo)
*** 1699,1704 ****
int signo;
{
! error ("Internal error: %s.", strsignal (signo));
! finish_abort ();
}
--- 1699,1703 ----
int signo;
{
! fatal ("Internal error: %s.", strsignal (signo));
}