Skip to content

Commit 9244ae6

Browse files
committed
libgccjit: Don't abort on fatal errors
1 parent 3e3878e commit 9244ae6

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
@@ -144,8 +144,7 @@ extern void error_at (rich_location *, const char *, ...)
144144
extern void error_meta (rich_location *, const diagnostic_metadata &,
145145
const char *, ...)
146146
ATTRIBUTE_GCC_DIAG(3,4);
147-
extern void fatal_error (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3)
148-
ATTRIBUTE_NORETURN;
147+
extern void fatal_error (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
149148
/* Pass one of the OPT_W* from options.h as the second parameter. */
150149
extern bool pedwarn (location_t,
151150
diagnostic_option_id,

gcc/diagnostic-global-context.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,8 @@ fatal_error (location_t loc, const char *gmsgid, ...)
502502
global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_FATAL);
503503
va_end (ap);
504504

505-
gcc_unreachable ();
505+
if (!global_dc->dont_abort_on_fatal_error ())
506+
gcc_unreachable ();
506507
}
507508

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

gcc/diagnostic.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,8 +996,12 @@ diagnostic_context::action_after_output (diagnostic_t diag_kind)
996996
if (m_abort_on_error)
997997
real_abort ();
998998
fnotice (stderr, "compilation terminated.\n");
999-
finish ();
1000-
exit (FATAL_EXIT_CODE);
999+
if (!m_dont_abort_on_fatal_error)
1000+
{
1001+
finish ();
1002+
exit (FATAL_EXIT_CODE);
1003+
}
1004+
break;
10011005

10021006
default:
10031007
gcc_unreachable ();

gcc/diagnostic.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,18 @@ class diagnostic_context
830830
m_abort_on_error = val;
831831
}
832832

833+
void
834+
set_dont_abort_on_fatal_error (bool val)
835+
{
836+
m_dont_abort_on_fatal_error = val;
837+
}
838+
839+
bool
840+
dont_abort_on_fatal_error () const
841+
{
842+
return m_dont_abort_on_fatal_error;
843+
}
844+
833845
private:
834846
void error_recursion () ATTRIBUTE_NORETURN;
835847

@@ -889,6 +901,9 @@ class diagnostic_context
889901
/* True if we should raise a SIGABRT on errors. */
890902
bool m_abort_on_error;
891903

904+
/* True if we should not abort on fatal errors. Mainly used for libgccjit. */
905+
bool m_dont_abort_on_fatal_error = false;
906+
892907
public:
893908
/* True if we should show the column number on diagnostics. */
894909
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 diagnostic_text_output_format
10201020
: diagnostic_text_output_format (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)