diff options
-rw-r--r-- | gcc/c-family/c-opts.cc | 2 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 2 | ||||
-rw-r--r-- | gcc/cp/error.cc | 12 | ||||
-rw-r--r-- | gcc/diagnostic-format-json.cc | 20 | ||||
-rw-r--r-- | gcc/diagnostic-format-sarif.cc | 57 | ||||
-rw-r--r-- | gcc/diagnostic.cc | 17 | ||||
-rw-r--r-- | gcc/diagnostic.h | 17 | ||||
-rw-r--r-- | gcc/fortran/error.cc | 4 | ||||
-rw-r--r-- | gcc/jit/dummy-frontend.cc | 7 | ||||
-rw-r--r-- | gcc/jit/jit-playback.cc | 4 | ||||
-rw-r--r-- | gcc/jit/jit-playback.h | 2 | ||||
-rw-r--r-- | gcc/langhooks-def.h | 3 | ||||
-rw-r--r-- | gcc/langhooks.cc | 2 | ||||
-rw-r--r-- | gcc/langhooks.h | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/plugin/show_template_tree_color_plugin.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c | 4 | ||||
-rw-r--r-- | gcc/tree-diagnostic.cc | 6 | ||||
-rw-r--r-- | gcc/tree-diagnostic.h | 4 | ||||
-rw-r--r-- | libcc1/context.cc | 2 |
21 files changed, 90 insertions, 83 deletions
diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index d484ecf..60aa7c5 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -168,7 +168,7 @@ c_common_option_lang_mask (void) /* Diagnostic finalizer for C/C++/Objective-C/Objective-C++. */ static void c_diagnostic_finalizer (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info *diagnostic, diagnostic_t) { char *saved_prefix = pp_take_prefix (context->printer); diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 795152c..cb89d37 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -8083,7 +8083,7 @@ extern void cxx_print_type (FILE *, tree, int); extern void cxx_print_identifier (FILE *, tree, int); extern void cxx_print_error_function (diagnostic_context *, const char *, - struct diagnostic_info *); + const diagnostic_info *); /* in typeck.cc */ /* Says how we should behave when comparing two arrays one of which diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc index 3b1b5de..626f9ca 100644 --- a/gcc/cp/error.cc +++ b/gcc/cp/error.cc @@ -101,8 +101,10 @@ static void print_instantiation_partial_context (diagnostic_context *, struct tinst_level *, location_t); static void maybe_print_constraint_context (diagnostic_context *); -static void cp_diagnostic_starter (diagnostic_context *, diagnostic_info *); -static void cp_print_error_function (diagnostic_context *, diagnostic_info *); +static void cp_diagnostic_starter (diagnostic_context *, + const diagnostic_info *); +static void cp_print_error_function (diagnostic_context *, + const diagnostic_info *); static bool cp_printer (pretty_printer *, text_info *, const char *, int, bool, bool, bool, bool *, const char **); @@ -3530,7 +3532,7 @@ eh_spec_to_string (tree p, int /*v*/) /* Langhook for print_error_function. */ void cxx_print_error_function (diagnostic_context *context, const char *file, - diagnostic_info *diagnostic) + const diagnostic_info *diagnostic) { char *prefix; if (file) @@ -3544,7 +3546,7 @@ cxx_print_error_function (diagnostic_context *context, const char *file, static void cp_diagnostic_starter (diagnostic_context *context, - diagnostic_info *diagnostic) + const diagnostic_info *diagnostic) { diagnostic_report_current_module (context, diagnostic_location (diagnostic)); cp_print_error_function (context, diagnostic); @@ -3559,7 +3561,7 @@ cp_diagnostic_starter (diagnostic_context *context, a diagnostic message. Called from cp_diagnostic_starter. */ static void cp_print_error_function (diagnostic_context *context, - diagnostic_info *diagnostic) + const diagnostic_info *diagnostic) { /* If we are in an instantiation context, current_function_decl is likely to be wrong, so just rely on print_instantiation_full_context. */ diff --git a/gcc/diagnostic-format-json.cc b/gcc/diagnostic-format-json.cc index 141075b..418db74 100644 --- a/gcc/diagnostic-format-json.cc +++ b/gcc/diagnostic-format-json.cc @@ -43,12 +43,12 @@ public: m_cur_children_array = nullptr; } void - on_begin_diagnostic (diagnostic_info *) final override + on_begin_diagnostic (const diagnostic_info &) final override { /* No-op. */ } void - on_end_diagnostic (diagnostic_info *diagnostic, + on_end_diagnostic (const diagnostic_info &diagnostic, diagnostic_t orig_diag_kind) final override; void on_diagram (const diagnostic_diagram &) final override { @@ -188,7 +188,7 @@ json_from_metadata (const diagnostic_metadata *metadata) within current diagnostic group. */ void -json_output_format::on_end_diagnostic (diagnostic_info *diagnostic, +json_output_format::on_end_diagnostic (const diagnostic_info &diagnostic, diagnostic_t orig_diag_kind) { json::object *diag_obj = new json::object (); @@ -202,7 +202,7 @@ json_output_format::on_end_diagnostic (diagnostic_info *diagnostic, "must-not-happen" }; /* Lose the trailing ": ". */ - const char *kind_text = diagnostic_kind_text[diagnostic->kind]; + const char *kind_text = diagnostic_kind_text[diagnostic.kind]; size_t len = strlen (kind_text); gcc_assert (len > 2); gcc_assert (kind_text[len - 2] == ':'); @@ -217,15 +217,15 @@ json_output_format::on_end_diagnostic (diagnostic_info *diagnostic, diag_obj->set_string ("message", pp_formatted_text (m_context.printer)); pp_clear_output_area (m_context.printer); - if (char *option_text = m_context.make_option_name (diagnostic->option_index, + if (char *option_text = m_context.make_option_name (diagnostic.option_index, orig_diag_kind, - diagnostic->kind)) + diagnostic.kind)) { diag_obj->set_string ("option", option_text); free (option_text); } - if (char *option_url = m_context.make_option_url (diagnostic->option_index)) + if (char *option_url = m_context.make_option_url (diagnostic.option_index)) { diag_obj->set_string ("option_url", option_url); free (option_url); @@ -249,7 +249,7 @@ json_output_format::on_end_diagnostic (diagnostic_info *diagnostic, diag_obj->set_integer ("column-origin", m_context.m_column_origin); } - const rich_location *richloc = diagnostic->richloc; + const rich_location *richloc = diagnostic.richloc; json::array *loc_array = new json::array (); diag_obj->set ("locations", loc_array); @@ -280,9 +280,9 @@ json_output_format::on_end_diagnostic (diagnostic_info *diagnostic, TODO: inlining information TODO: macro expansion information. */ - if (diagnostic->metadata) + if (diagnostic.metadata) { - json::object *metadata_obj = json_from_metadata (diagnostic->metadata); + json::object *metadata_obj = json_from_metadata (diagnostic.metadata); diag_obj->set ("metadata", metadata_obj); } diff --git a/gcc/diagnostic-format-sarif.cc b/gcc/diagnostic-format-sarif.cc index 6777592..941fd0f 100644 --- a/gcc/diagnostic-format-sarif.cc +++ b/gcc/diagnostic-format-sarif.cc @@ -48,7 +48,7 @@ public: {} void add_notification_for_ice (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info &diagnostic, sarif_builder *builder); void prepare_to_flush (diagnostic_context *context); @@ -67,7 +67,7 @@ public: void on_nested_diagnostic (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info &diagnostic, diagnostic_t orig_diag_kind, sarif_builder *builder); void on_diagram (diagnostic_context *context, @@ -90,7 +90,7 @@ class sarif_ice_notification : public sarif_object { public: sarif_ice_notification (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info &diagnostic, sarif_builder *builder); }; @@ -159,7 +159,8 @@ class sarif_builder public: sarif_builder (diagnostic_context *context); - void end_diagnostic (diagnostic_context *context, diagnostic_info *diagnostic, + void end_diagnostic (diagnostic_context *context, + const diagnostic_info &diagnostic, diagnostic_t orig_diag_kind); void emit_diagram (diagnostic_context *context, const diagnostic_diagram &diagram); @@ -167,7 +168,7 @@ public: void flush_to_file (FILE *outf); - json::array *make_locations_arr (diagnostic_info *diagnostic); + json::array *make_locations_arr (const diagnostic_info &diagnostic); json::object *make_location_object (const rich_location &rich_loc, const logical_location *logical_loc); json::object *make_message_object (const char *msg) const; @@ -177,7 +178,7 @@ public: private: sarif_result *make_result_object (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info &diagnostic, diagnostic_t orig_diag_kind); void set_any_logical_locs_arr (json::object *location_obj, const logical_location *logical_loc); @@ -208,7 +209,7 @@ private: json::object *make_tool_component_reference_object_for_cwe () const; json::object * make_reporting_descriptor_object_for_warning (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info &diagnostic, diagnostic_t orig_diag_kind, const char *option_text); json::object *make_reporting_descriptor_object_for_cwe_id (int cwe_id) const; @@ -275,7 +276,7 @@ sarif_object::get_or_create_properties () void sarif_invocation::add_notification_for_ice (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info &diagnostic, sarif_builder *builder) { m_success = false; @@ -310,7 +311,7 @@ sarif_invocation::prepare_to_flush (diagnostic_context *context) void sarif_result::on_nested_diagnostic (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info &diagnostic, diagnostic_t /*orig_diag_kind*/, sarif_builder *builder) { @@ -318,7 +319,7 @@ sarif_result::on_nested_diagnostic (diagnostic_context *context, sometimes these will related to current_function_decl, but often they won't. */ json::object *location_obj - = builder->make_location_object (*diagnostic->richloc, NULL); + = builder->make_location_object (*diagnostic.richloc, NULL); json::object *message_obj = builder->make_message_object (pp_formatted_text (context->printer)); pp_clear_output_area (context->printer); @@ -366,7 +367,7 @@ sarif_result::add_related_location (json::object *location_obj) DIAGNOSTIC is an internal compiler error. */ sarif_ice_notification::sarif_ice_notification (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info &diagnostic, sarif_builder *builder) { /* "locations" property (SARIF v2.1.0 section 3.58.4). */ @@ -416,10 +417,10 @@ sarif_builder::sarif_builder (diagnostic_context *context) void sarif_builder::end_diagnostic (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info &diagnostic, diagnostic_t orig_diag_kind) { - if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT) + if (diagnostic.kind == DK_ICE || diagnostic.kind == DK_ICE_NOBT) { m_invocation_obj->add_notification_for_ice (context, diagnostic, this); return; @@ -528,7 +529,7 @@ make_rule_id_for_diagnostic_kind (diagnostic_t diag_kind) sarif_result * sarif_builder::make_result_object (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info &diagnostic, diagnostic_t orig_diag_kind) { sarif_result *result_obj = new sarif_result (); @@ -536,8 +537,8 @@ sarif_builder::make_result_object (diagnostic_context *context, /* "ruleId" property (SARIF v2.1.0 section 3.27.5). */ /* Ideally we'd have an option_name for these. */ if (char *option_text - = context->make_option_name (diagnostic->option_index, - orig_diag_kind, diagnostic->kind)) + = context->make_option_name (diagnostic.option_index, + orig_diag_kind, diagnostic.kind)) { /* Lazily create reportingDescriptor objects for and add to m_rules_arr. Set ruleId referencing them. */ @@ -569,10 +570,10 @@ sarif_builder::make_result_object (diagnostic_context *context, free (rule_id); } - if (diagnostic->metadata) + if (diagnostic.metadata) { /* "taxa" property (SARIF v2.1.0 section 3.27.8). */ - if (int cwe_id = diagnostic->metadata->get_cwe ()) + if (int cwe_id = diagnostic.metadata->get_cwe ()) { json::array *taxa_arr = new json::array (); json::object *cwe_id_obj @@ -581,11 +582,11 @@ sarif_builder::make_result_object (diagnostic_context *context, result_obj->set ("taxa", taxa_arr); } - diagnostic->metadata->maybe_add_sarif_properties (*result_obj); + diagnostic.metadata->maybe_add_sarif_properties (*result_obj); } /* "level" property (SARIF v2.1.0 section 3.27.10). */ - if (const char *sarif_level = maybe_get_sarif_level (diagnostic->kind)) + if (const char *sarif_level = maybe_get_sarif_level (diagnostic.kind)) result_obj->set_string ("level", sarif_level); /* "message" property (SARIF v2.1.0 section 3.27.11). */ @@ -599,7 +600,7 @@ sarif_builder::make_result_object (diagnostic_context *context, result_obj->set ("locations", locations_arr); /* "codeFlows" property (SARIF v2.1.0 section 3.27.18). */ - if (const diagnostic_path *path = diagnostic->richloc->get_path ()) + if (const diagnostic_path *path = diagnostic.richloc->get_path ()) { json::array *code_flows_arr = new json::array (); json::object *code_flow_obj = make_code_flow_object (*path); @@ -612,7 +613,7 @@ sarif_builder::make_result_object (diagnostic_context *context, group. */ /* "fixes" property (SARIF v2.1.0 section 3.27.30). */ - const rich_location *richloc = diagnostic->richloc; + const rich_location *richloc = diagnostic.richloc; if (richloc->get_num_fixit_hints ()) { json::array *fix_arr = new json::array (); @@ -630,7 +631,7 @@ sarif_builder::make_result_object (diagnostic_context *context, json::object * sarif_builder:: make_reporting_descriptor_object_for_warning (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info &diagnostic, diagnostic_t /*orig_diag_kind*/, const char *option_text) { @@ -643,7 +644,7 @@ make_reporting_descriptor_object_for_warning (diagnostic_context *context, it seems redundant compared to "id". */ /* "helpUri" property (SARIF v2.1.0 section 3.49.12). */ - if (char *option_url = context->make_option_url (diagnostic->option_index)) + if (char *option_url = context->make_option_url (diagnostic.option_index)) { reporting_desc->set_string ("helpUri", option_url); free (option_url); @@ -725,7 +726,7 @@ make_tool_component_reference_object_for_cwe () const - a "notification" object (SARIF v2.1.0 section 3.58.4). */ json::array * -sarif_builder::make_locations_arr (diagnostic_info *diagnostic) +sarif_builder::make_locations_arr (const diagnostic_info &diagnostic) { json::array *locations_arr = new json::array (); const logical_location *logical_loc = NULL; @@ -733,7 +734,7 @@ sarif_builder::make_locations_arr (diagnostic_info *diagnostic) logical_loc = client_data_hooks->get_current_logical_location (); json::object *location_obj - = make_location_object (*diagnostic->richloc, logical_loc); + = make_location_object (*diagnostic.richloc, logical_loc); locations_arr->append (location_obj); return locations_arr; } @@ -1704,12 +1705,12 @@ public: m_builder.end_group (); } void - on_begin_diagnostic (diagnostic_info *) final override + on_begin_diagnostic (const diagnostic_info &) final override { /* No-op, */ } void - on_end_diagnostic (diagnostic_info *diagnostic, + on_end_diagnostic (const diagnostic_info &diagnostic, diagnostic_t orig_diag_kind) final override { m_builder.end_diagnostic (&m_context, diagnostic, orig_diag_kind); diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc index 2e3d37b..5854c89 100644 --- a/gcc/diagnostic.cc +++ b/gcc/diagnostic.cc @@ -1077,7 +1077,7 @@ diagnostic_path::interprocedural_p () const void default_diagnostic_starter (diagnostic_context *context, - diagnostic_info *diagnostic) + const diagnostic_info *diagnostic) { diagnostic_report_current_module (context, diagnostic_location (diagnostic)); pp_set_prefix (context->printer, diagnostic_build_prefix (context, @@ -1095,7 +1095,7 @@ default_diagnostic_start_span_fn (diagnostic_context *context, void default_diagnostic_finalizer (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info *diagnostic, diagnostic_t) { char *saved_prefix = pp_take_prefix (context->printer); @@ -1602,7 +1602,7 @@ diagnostic_context::report_diagnostic (diagnostic_info *diagnostic) m_diagnostic_groups.m_emission_count++; pp_format (this->printer, &diagnostic->message, m_urlifier); - m_output_format->on_begin_diagnostic (diagnostic); + m_output_format->on_begin_diagnostic (*diagnostic); pp_output_formatted_text (this->printer); if (m_show_cwe) print_any_cwe (*diagnostic); @@ -1610,7 +1610,7 @@ diagnostic_context::report_diagnostic (diagnostic_info *diagnostic) print_any_rules (*diagnostic); if (m_show_option_requested) print_option_information (*diagnostic, orig_diag_kind); - m_output_format->on_end_diagnostic (diagnostic, orig_diag_kind); + m_output_format->on_end_diagnostic (*diagnostic, orig_diag_kind); switch (m_extra_output_kind) { default: @@ -2396,16 +2396,17 @@ diagnostic_text_output_format::~diagnostic_text_output_format () } void -diagnostic_text_output_format::on_begin_diagnostic (diagnostic_info *diagnostic) +diagnostic_text_output_format::on_begin_diagnostic (const diagnostic_info &diagnostic) { - (*diagnostic_starter (&m_context)) (&m_context, diagnostic); + (*diagnostic_starter (&m_context)) (&m_context, &diagnostic); } void -diagnostic_text_output_format::on_end_diagnostic (diagnostic_info *diagnostic, +diagnostic_text_output_format::on_end_diagnostic (const diagnostic_info &diagnostic, diagnostic_t orig_diag_kind) { - (*diagnostic_finalizer (&m_context)) (&m_context, diagnostic, orig_diag_kind); + (*diagnostic_finalizer (&m_context)) (&m_context, &diagnostic, + orig_diag_kind); } void diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index b57556f..4fc3143 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -171,13 +171,13 @@ struct diagnostic_info /* Forward declarations. */ typedef void (*diagnostic_starter_fn) (diagnostic_context *, - diagnostic_info *); + const diagnostic_info *); typedef void (*diagnostic_start_span_fn) (diagnostic_context *, expanded_location); typedef void (*diagnostic_finalizer_fn) (diagnostic_context *, - diagnostic_info *, + const diagnostic_info *, diagnostic_t); typedef int (*diagnostic_option_enabled_cb) (int, unsigned, void *); @@ -205,8 +205,8 @@ public: virtual void on_begin_group () = 0; virtual void on_end_group () = 0; - virtual void on_begin_diagnostic (diagnostic_info *) = 0; - virtual void on_end_diagnostic (diagnostic_info *, + virtual void on_begin_diagnostic (const diagnostic_info &) = 0; + virtual void on_end_diagnostic (const diagnostic_info &, diagnostic_t orig_diag_kind) = 0; virtual void on_diagram (const diagnostic_diagram &diagram) = 0; @@ -233,8 +233,8 @@ public: ~diagnostic_text_output_format (); void on_begin_group () override {} void on_end_group () override {} - void on_begin_diagnostic (diagnostic_info *) override; - void on_end_diagnostic (diagnostic_info *, + void on_begin_diagnostic (const diagnostic_info &) override; + void on_end_diagnostic (const diagnostic_info &, diagnostic_t orig_diag_kind) override; void on_diagram (const diagnostic_diagram &diagram) override; }; @@ -985,10 +985,11 @@ extern void diagnostic_append_note (diagnostic_context *, location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(3,4); #endif extern char *diagnostic_build_prefix (diagnostic_context *, const diagnostic_info *); -void default_diagnostic_starter (diagnostic_context *, diagnostic_info *); +void default_diagnostic_starter (diagnostic_context *, const diagnostic_info *); void default_diagnostic_start_span_fn (diagnostic_context *, expanded_location); -void default_diagnostic_finalizer (diagnostic_context *, diagnostic_info *, +void default_diagnostic_finalizer (diagnostic_context *, + const diagnostic_info *, diagnostic_t); void diagnostic_set_caret_max_width (diagnostic_context *context, int value); diff --git a/gcc/fortran/error.cc b/gcc/fortran/error.cc index 56d2e636..76113de 100644 --- a/gcc/fortran/error.cc +++ b/gcc/fortran/error.cc @@ -1207,7 +1207,7 @@ gfc_diagnostic_build_locus_prefix (diagnostic_context *context, */ static void gfc_diagnostic_starter (diagnostic_context *context, - diagnostic_info *diagnostic) + const diagnostic_info *diagnostic) { char * kind_prefix = gfc_diagnostic_build_kind_prefix (context, diagnostic); @@ -1283,7 +1283,7 @@ gfc_diagnostic_start_span (diagnostic_context *context, static void gfc_diagnostic_finalizer (diagnostic_context *context, - diagnostic_info *diagnostic ATTRIBUTE_UNUSED, + const diagnostic_info *diagnostic ATTRIBUTE_UNUSED, diagnostic_t orig_diag_kind ATTRIBUTE_UNUSED) { pp_destroy_prefix (context->printer); diff --git a/gcc/jit/dummy-frontend.cc b/gcc/jit/dummy-frontend.cc index 1ea6ad3..9f71bca 100644 --- a/gcc/jit/dummy-frontend.cc +++ b/gcc/jit/dummy-frontend.cc @@ -563,7 +563,7 @@ struct ggc_root_tab jit_root_tab[] = static void jit_begin_diagnostic (diagnostic_context */*context*/, - diagnostic_info */*diagnostic*/) + const diagnostic_info */*diagnostic*/) { gcc_assert (gcc::jit::active_playback_ctxt); JIT_LOG_SCOPE (gcc::jit::active_playback_ctxt->get_logger ()); @@ -576,7 +576,7 @@ jit_begin_diagnostic (diagnostic_context */*context*/, static void jit_end_diagnostic (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info *diagnostic, diagnostic_t) { gcc_assert (gcc::jit::active_playback_ctxt); @@ -584,7 +584,8 @@ jit_end_diagnostic (diagnostic_context *context, /* Delegate to the playback context (and thence to the recording context). */ - gcc::jit::active_playback_ctxt->add_diagnostic (context, diagnostic); + gcc_assert (diagnostic); + gcc::jit::active_playback_ctxt->add_diagnostic (context, *diagnostic); } /* Language hooks. */ diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc index 18cc4da..dddd537 100644 --- a/gcc/jit/jit-playback.cc +++ b/gcc/jit/jit-playback.cc @@ -3513,7 +3513,7 @@ add_error_va (location *loc, const char *fmt, va_list ap) void playback::context:: add_diagnostic (diagnostic_context *diag_context, - struct diagnostic_info *diagnostic) + const diagnostic_info &diagnostic) { /* At this point the text has been formatted into the pretty-printer's output buffer. */ @@ -3526,7 +3526,7 @@ add_diagnostic (diagnostic_context *diag_context, from the file/line/column since any playback location instances may have been garbage-collected away by now, so instead we create another recording::location directly. */ - location_t gcc_loc = diagnostic_location (diagnostic); + location_t gcc_loc = diagnostic_location (&diagnostic); recording::location *rec_loc = NULL; if (gcc_loc) { diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h index f9e29d0..b0166f8 100644 --- a/gcc/jit/jit-playback.h +++ b/gcc/jit/jit-playback.h @@ -248,7 +248,7 @@ public: void add_diagnostic (diagnostic_context *context, - struct diagnostic_info *diagnostic); + const diagnostic_info &diagnostic); void set_tree_location (tree t, location *loc); diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index 042fd01..7331677 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -50,7 +50,8 @@ extern const char *lhd_decl_printable_name (tree, int); extern const char *lhd_dwarf_name (tree, int); extern int lhd_types_compatible_p (tree, tree); extern void lhd_print_error_function (diagnostic_context *, - const char *, struct diagnostic_info *); + const char *, + const struct diagnostic_info *); extern void lhd_set_decl_assembler_name (tree decl); extern void lhd_overwrite_decl_assembler_name (tree decl, tree name); extern bool lhd_warn_unused_global_decl (const_tree); diff --git a/gcc/langhooks.cc b/gcc/langhooks.cc index cf047d9..bc3fd35 100644 --- a/gcc/langhooks.cc +++ b/gcc/langhooks.cc @@ -369,7 +369,7 @@ lhd_handle_option (size_t code ATTRIBUTE_UNUSED, an error. */ void lhd_print_error_function (diagnostic_context *context, const char *file, - diagnostic_info *diagnostic) + const diagnostic_info *diagnostic) { if (diagnostic_last_function_changed (context, diagnostic)) { diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 2785a00..bba64d1 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -516,7 +516,7 @@ struct lang_hooks /* Called by report_error_function to print out function name. */ void (*print_error_function) (diagnostic_context *, const char *, - struct diagnostic_info *); + const struct diagnostic_info *); /* Convert a character from the host's to the target's character set. The character should be in what C calls the "basic source diff --git a/gcc/testsuite/g++.dg/plugin/show_template_tree_color_plugin.c b/gcc/testsuite/g++.dg/plugin/show_template_tree_color_plugin.c index af568bf..e1af2cf 100644 --- a/gcc/testsuite/g++.dg/plugin/show_template_tree_color_plugin.c +++ b/gcc/testsuite/g++.dg/plugin/show_template_tree_color_plugin.c @@ -21,7 +21,7 @@ int plugin_is_GPL_compatible; void -noop_starter_fn (diagnostic_context *, diagnostic_info *) +noop_starter_fn (diagnostic_context *, const diagnostic_info *) { } diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c index ce0b322..e9d4b72 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c @@ -165,7 +165,7 @@ pass_test_groups::execute (function *fun) void test_diagnostic_starter (diagnostic_context *context, - diagnostic_info *diagnostic) + const diagnostic_info *diagnostic) { pp_set_prefix (context->printer, xstrdup ("PREFIX: ")); } diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c index 6cc661b..3bd8cab 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c @@ -129,7 +129,7 @@ static bool force_show_locus_color = false; static void custom_diagnostic_finalizer (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info *diagnostic, diagnostic_t) { bool old_show_color = pp_show_color (context->printer); diff --git a/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c b/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c index 09bac50d..d0a6b07 100644 --- a/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c +++ b/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c @@ -42,7 +42,7 @@ static diagnostic_finalizer_fn original_finalizer = NULL; static void verify_unpacked_ranges (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info *diagnostic, diagnostic_t orig_diag_kind) { /* Verify that the locations are ad-hoc, not packed. */ @@ -56,7 +56,7 @@ verify_unpacked_ranges (diagnostic_context *context, static void verify_no_columns (diagnostic_context *context, - diagnostic_info *diagnostic, + const diagnostic_info *diagnostic, diagnostic_t orig_diag_kind) { /* Verify that the locations have no columns. */ diff --git a/gcc/tree-diagnostic.cc b/gcc/tree-diagnostic.cc index de853bc..dae8a42 100644 --- a/gcc/tree-diagnostic.cc +++ b/gcc/tree-diagnostic.cc @@ -35,7 +35,7 @@ along with GCC; see the file COPYING3. If not see that caused an error. Called from all error and warning functions. */ void diagnostic_report_current_function (diagnostic_context *context, - diagnostic_info *diagnostic) + const diagnostic_info *diagnostic) { location_t loc = diagnostic_location (diagnostic); diagnostic_report_current_module (context, loc); @@ -44,7 +44,7 @@ diagnostic_report_current_function (diagnostic_context *context, static void default_tree_diagnostic_starter (diagnostic_context *context, - diagnostic_info *diagnostic) + const diagnostic_info *diagnostic) { diagnostic_report_current_function (context, diagnostic); pp_set_prefix (context->printer, diagnostic_build_prefix (context, @@ -241,7 +241,7 @@ maybe_unwind_expanded_macro_loc (diagnostic_context *context, template instantiation contexts. */ void virt_loc_aware_diagnostic_finalizer (diagnostic_context *context, - diagnostic_info *diagnostic) + const diagnostic_info *diagnostic) { maybe_unwind_expanded_macro_loc (context, diagnostic_location (diagnostic)); } diff --git a/gcc/tree-diagnostic.h b/gcc/tree-diagnostic.h index 9089f2d..a3ea18c 100644 --- a/gcc/tree-diagnostic.h +++ b/gcc/tree-diagnostic.h @@ -49,9 +49,9 @@ along with GCC; see the file COPYING3. If not see : current_function_decl) void diagnostic_report_current_function (diagnostic_context *, - diagnostic_info *); + const diagnostic_info *); void virt_loc_aware_diagnostic_finalizer (diagnostic_context *, - diagnostic_info *); + const diagnostic_info *); void tree_diagnostics_defaults (diagnostic_context *context); bool default_tree_printer (pretty_printer *, text_info *, const char *, diff --git a/libcc1/context.cc b/libcc1/context.cc index 3263c16..fbe468f 100644 --- a/libcc1/context.cc +++ b/libcc1/context.cc @@ -63,7 +63,7 @@ cc1_plugin::plugin_context *cc1_plugin::current_context; static void plugin_print_error_function (diagnostic_context *context, const char *file, - diagnostic_info *diagnostic) + const diagnostic_info *diagnostic) { if (current_function_decl != NULL_TREE && DECL_NAME (current_function_decl) != NULL_TREE |