aboutsummaryrefslogtreecommitdiff
path: root/gcc/errors.c
diff options
context:
space:
mode:
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>2001-02-24 11:45:36 +0000
committerRichard Kenner <kenner@vlsi1.ultra.nyu.edu>2001-02-24 11:45:36 +0000
commit828b2d5e28ccb84159c03a40bba884d286dd14d3 (patch)
tree237515354deb20334a68d9bffe4d16c8e58568e4 /gcc/errors.c
parentd842f6294aa3fd51f03d725a9d28cd6cf2787c5e (diff)
* errors.c (internal_error, trim_filename): New functions.
(fancy_abort): Call internal_error. * errors.h (internal_error, trim_filename): New declarations. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@40037 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/errors.c')
-rw-r--r--gcc/errors.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/gcc/errors.c b/gcc/errors.c
index 8ccd7d0b2e0..e1a3f13a8fd 100644
--- a/gcc/errors.c
+++ b/gcc/errors.c
@@ -1,5 +1,5 @@
/* Basic error reporting routines.
- Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -105,6 +105,57 @@ fatal VPARAMS ((const char *format, ...))
exit (FATAL_EXIT_CODE);
}
+/* Similar, but say we got an internal error. */
+
+void
+internal_error VPARAMS ((const char *format, ...))
+{
+#ifndef ANSI_PROTOTYPES
+ const char *format;
+#endif
+ va_list ap;
+
+ VA_START (ap, format);
+
+#ifndef ANSI_PROTOTYPES
+ format = va_arg (ap, const char *);
+#endif
+
+ fprintf (stderr, "%s: Internal error", progname);
+ vfprintf (stderr, format, ap);
+ va_end (ap);
+ fputc ('\n', stderr);
+ exit (FATAL_EXIT_CODE);
+}
+
+/* Given a partial pathname as input, return another pathname that
+ shares no directory elements with the pathname of __FILE__. This
+ is used by fancy_abort() to print `Internal compiler error in expr.c'
+ instead of `Internal compiler error in ../../GCC/gcc/expr.c'. This
+ version if for the gen* programs and so neededn't handle subdirectories. */
+
+const char *
+trim_filename (name)
+ const char *name;
+{
+ static const char this_file[] = __FILE__;
+ const char *p = name, *q = this_file;
+
+ /* 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
+ && p[-1] != DIR_SEPARATOR_2
+#endif
+ )
+ p--;
+
+ return p;
+}
+
/* "Fancy" abort. Reports where in the compiler someone gave up.
This file is used only by build programs, so we're not as polite as
the version in diagnostic.c. */
@@ -114,5 +165,5 @@ fancy_abort (file, line, func)
int line;
const char *func;
{
- fatal ("ICE in %s, at %s:%d", func, file, line);
+ internal_error ("abort in %s, at %s:%d", func, file, line);
}