diff options
author | David Malcolm <dmalcolm@redhat.com> | 2016-05-17 19:28:47 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2016-05-17 19:28:47 +0000 |
commit | 6b5423a512421989934071586c9ddb6ee42ac417 (patch) | |
tree | ff6f37c704f22faac7eab9e79f10232646b62933 /gcc/jit/dummy-frontend.c | |
parent | f51703a8f80c9935f27148bb53ec7591716fd519 (diff) | |
download | gcc-6b5423a512421989934071586c9ddb6ee42ac417.zip gcc-6b5423a512421989934071586c9ddb6ee42ac417.tar.gz gcc-6b5423a512421989934071586c9ddb6ee42ac417.tar.bz2 |
jit: gcc diagnostics are jit errors
libgccjit performs numerous checks at the API boundary, but
if these succeed, it ignores errors and other diagnostics emitted
within the core of gcc, and treats the compile of a gcc_jit_context
as having succeeded.
This patch ensures that if any diagnostics are emitted, they
are visible from the libgccjit API, and that the the context is
flagged as having failed.
For now any kind of diagnostic is treated as a jit error,
so warnings and notes also count as errors.
gcc/jit/ChangeLog:
* dummy-frontend.c: Include diagnostic.h.
(jit_begin_diagnostic): New function.
(jit_end_diagnostic): New function.
(jit_langhook_init): Register jit_begin_diagnostic
and jit_end_diagnostic with the global_dc.
* jit-playback.c: Include diagnostic.h.
(gcc::jit::playback::context::add_diagnostic): New method.
* jit-playback.h (struct diagnostic_context): Add forward
declaration.
(gcc::jit::playback::context::add_diagnostic): New method.
gcc/testsuite/ChangeLog:
* jit.dg/test-error-array-bounds.c: New test case.
From-SVN: r236342
Diffstat (limited to 'gcc/jit/dummy-frontend.c')
-rw-r--r-- | gcc/jit/dummy-frontend.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/jit/dummy-frontend.c b/gcc/jit/dummy-frontend.c index 7194ba6..2631153 100644 --- a/gcc/jit/dummy-frontend.c +++ b/gcc/jit/dummy-frontend.c @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see #include "debug.h" #include "langhooks.h" #include "langhooks-def.h" +#include "diagnostic.h" #include <mpfr.h> @@ -90,6 +91,35 @@ struct ggc_root_tab jit_root_tab[] = LAST_GGC_ROOT_TAB }; +/* JIT-specific implementation of diagnostic callbacks. */ + +/* Implementation of "begin_diagnostic". */ + +static void +jit_begin_diagnostic (diagnostic_context */*context*/, + diagnostic_info */*diagnostic*/) +{ + gcc_assert (gcc::jit::active_playback_ctxt); + JIT_LOG_SCOPE (gcc::jit::active_playback_ctxt->get_logger ()); + + /* No-op (apart from logging); the real error-handling is done in the + "end_diagnostic" hook. */ +} + +/* Implementation of "end_diagnostic". */ + +static void +jit_end_diagnostic (diagnostic_context *context, + diagnostic_info *diagnostic) +{ + gcc_assert (gcc::jit::active_playback_ctxt); + JIT_LOG_SCOPE (gcc::jit::active_playback_ctxt->get_logger ()); + + /* Delegate to the playback context (and thence to the + recording context). */ + gcc::jit::active_playback_ctxt->add_diagnostic (context, diagnostic); +} + /* Language hooks. */ static bool @@ -105,6 +135,10 @@ jit_langhook_init (void) registered_root_tab = true; } + gcc_assert (global_dc); + global_dc->begin_diagnostic = jit_begin_diagnostic; + global_dc->end_diagnostic = jit_end_diagnostic; + build_common_tree_nodes (false); /* I don't know why this has to be done explicitly. */ |