Skip to content

Commit 485c9ff

Browse files
committed
libgccjit: Don't abort on fatal errors
1 parent 348ce97 commit 485c9ff

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

gcc/diagnostic-core.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ extern void error_at (rich_location *, const char *, ...)
112112
extern void error_meta (rich_location *, const diagnostics::metadata &,
113113
const char *, ...)
114114
ATTRIBUTE_GCC_DIAG(3,4);
115-
extern void fatal_error (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3)
116-
ATTRIBUTE_NORETURN;
115+
extern void fatal_error (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
117116
/* Pass one of the OPT_W* from options.h as the second parameter. */
118117
extern bool pedwarn (location_t,
119118
diagnostics::option_id,

gcc/diagnostic-global-context.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,8 @@ fatal_error (location_t loc, const char *gmsgid, ...)
766766
diagnostics::kind::fatal);
767767
va_end (ap);
768768

769-
gcc_unreachable ();
769+
if (!global_dc->dont_abort_on_fatal_error ())
770+
gcc_unreachable ();
770771
}
771772

772773
/* An internal consistency check has failed. We make no attempt to

gcc/diagnostics/context.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,8 +1037,12 @@ context::action_after_output (enum kind diag_kind)
10371037
if (m_abort_on_error)
10381038
real_abort ();
10391039
fnotice (stderr, "compilation terminated.\n");
1040-
finish ();
1041-
exit (FATAL_EXIT_CODE);
1040+
if (!m_dont_abort_on_fatal_error)
1041+
{
1042+
finish ();
1043+
exit (FATAL_EXIT_CODE);
1044+
}
1045+
break;
10421046

10431047
default:
10441048
gcc_unreachable ();

gcc/diagnostics/context.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,18 @@ class context
565565
m_abort_on_error = val;
566566
}
567567

568+
void
569+
set_dont_abort_on_fatal_error (bool val)
570+
{
571+
m_dont_abort_on_fatal_error = val;
572+
}
573+
574+
bool
575+
dont_abort_on_fatal_error () const
576+
{
577+
return m_dont_abort_on_fatal_error;
578+
}
579+
568580
/* Accessor for use in serialization, e.g. by C++ modules. */
569581
auto &
570582
get_classification_history ()
@@ -679,6 +691,9 @@ class context
679691
/* True if we should raise a SIGABRT on errors. */
680692
bool m_abort_on_error;
681693

694+
/* True if we should not abort on fatal errors. Mainly used for libgccjit. */
695+
bool m_dont_abort_on_fatal_error = false;
696+
682697
public:
683698
/* True if we should show the column number on diagnostics. */
684699
bool m_show_column;

gcc/jit/dummy-frontend.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,7 @@ class jit_diagnostic_listener : public diagnostics::text_sink
10201020
: diagnostics::text_sink (dc),
10211021
m_playback_ctxt (playback_ctxt)
10221022
{
1023+
dc.set_dont_abort_on_fatal_error (true);
10231024
}
10241025

10251026
void dump (FILE *out, int indent) const final override

0 commit comments

Comments
 (0)