[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/6] FIXME: initial support for gcc diagnostics as jit errors
Currently libgccjit ignores errors and other diagnostics emitted
within the core of gcc, and treates 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 mark the context as
having failed.
TODO:
- ChangeLog
- better blurb
- testing
- what to do about non-error diagnostics (warnings etc)
---
gcc/jit/dummy-frontend.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/gcc/jit/dummy-frontend.c b/gcc/jit/dummy-frontend.c
index 7194ba6..5830ff1 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,37 @@ struct ggc_root_tab jit_root_tab[] =
LAST_GGC_ROOT_TAB
};
+
+/* JIT-specific implementation of diagnostic callbacks. */
+
+/* FIXME. */
+
+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 ());
+ /* TODO: report diagnostic; propagate errors. */
+}
+
+/* FIXME. */
+
+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 ());
+ /* TODO: report diagnostic; propagate errors. */
+ pretty_printer *pp = context->printer;
+ //pp_clear_state (pp);
+ const char *text = pp_formatted_text (pp);
+ gcc::jit::active_playback_ctxt->add_error (NULL, "%s", text);
+ /* FIXME: what if it isn't an error? */
+ pp_clear_output_area (pp);
+}
+
/* Language hooks. */
static bool
@@ -105,6 +137,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. */
--
1.8.5.3