libgccjit: Don't abort on fatal errors
diff --git a/gcc/diagnostic-core.h b/gcc/diagnostic-core.h
index 1e89c9f..bced8aa 100644
--- a/gcc/diagnostic-core.h
+++ b/gcc/diagnostic-core.h
@@ -144,8 +144,7 @@
extern void error_meta (rich_location *, const diagnostic_metadata &,
const char *, ...)
ATTRIBUTE_GCC_DIAG(3,4);
-extern void fatal_error (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3)
- ATTRIBUTE_NORETURN;
+extern void fatal_error (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
/* Pass one of the OPT_W* from options.h as the second parameter. */
extern bool pedwarn (location_t,
diagnostic_option_id,
diff --git a/gcc/diagnostic-global-context.cc b/gcc/diagnostic-global-context.cc
index 1165915..0b85e69 100644
--- a/gcc/diagnostic-global-context.cc
+++ b/gcc/diagnostic-global-context.cc
@@ -502,7 +502,8 @@
global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_FATAL);
va_end (ap);
- gcc_unreachable ();
+ if (!global_dc->dont_abort_on_fatal_error ())
+ gcc_unreachable ();
}
/* An internal consistency check has failed. We make no attempt to
diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
index ab52e34..9c46c9d 100644
--- a/gcc/diagnostic.cc
+++ b/gcc/diagnostic.cc
@@ -996,8 +996,12 @@
if (m_abort_on_error)
real_abort ();
fnotice (stderr, "compilation terminated.\n");
- finish ();
- exit (FATAL_EXIT_CODE);
+ if (!m_dont_abort_on_fatal_error)
+ {
+ finish ();
+ exit (FATAL_EXIT_CODE);
+ }
+ break;
default:
gcc_unreachable ();
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index cdd6f26..8fe3ef0 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -830,6 +830,18 @@
m_abort_on_error = val;
}
+ void
+ set_dont_abort_on_fatal_error (bool val)
+ {
+ m_dont_abort_on_fatal_error = val;
+ }
+
+ bool
+ dont_abort_on_fatal_error () const
+ {
+ return m_dont_abort_on_fatal_error;
+ }
+
private:
void error_recursion () ATTRIBUTE_NORETURN;
@@ -889,6 +901,9 @@
/* True if we should raise a SIGABRT on errors. */
bool m_abort_on_error;
+ /* True if we should not abort on fatal errors. Mainly used for libgccjit. */
+ bool m_dont_abort_on_fatal_error = false;
+
public:
/* True if we should show the column number on diagnostics. */
bool m_show_column;
diff --git a/gcc/jit/dummy-frontend.cc b/gcc/jit/dummy-frontend.cc
index b0fcdd5..781afbf 100644
--- a/gcc/jit/dummy-frontend.cc
+++ b/gcc/jit/dummy-frontend.cc
@@ -1020,6 +1020,7 @@
: diagnostic_text_output_format (dc),
m_playback_ctxt (playback_ctxt)
{
+ dc.set_dont_abort_on_fatal_error (true);
}
void dump (FILE *out, int indent) const final override