aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/diagnostic-show-locus.cc2
-rw-r--r--gcc/diagnostic.cc6
-rw-r--r--gcc/diagnostic.h37
-rw-r--r--gcc/fortran/error.cc2
-rw-r--r--gcc/selftest-diagnostic.cc2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c2
-rw-r--r--gcc/tree-diagnostic-path.cc2
7 files changed, 39 insertions, 14 deletions
diff --git a/gcc/diagnostic-show-locus.cc b/gcc/diagnostic-show-locus.cc
index 169f59c..563d282 100644
--- a/gcc/diagnostic-show-locus.cc
+++ b/gcc/diagnostic-show-locus.cc
@@ -2904,7 +2904,7 @@ diagnostic_context::show_locus (const rich_location &richloc,
{
expanded_location exploc
= layout.get_expanded_location (line_span);
- m_text_callbacks.start_span (this, exploc);
+ m_text_callbacks.m_start_span (this, exploc);
}
}
/* Iterate over the lines within this span (using linenum_arith_t to
diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
index 24212b9..ccca2d2 100644
--- a/gcc/diagnostic.cc
+++ b/gcc/diagnostic.cc
@@ -235,9 +235,9 @@ diagnostic_context::initialize (int n_opts)
m_warn_system_headers = false;
m_max_errors = 0;
m_internal_error = nullptr;
- m_text_callbacks.begin_diagnostic = default_diagnostic_starter;
- m_text_callbacks.start_span = default_diagnostic_start_span_fn;
- m_text_callbacks.end_diagnostic = default_diagnostic_finalizer;
+ m_text_callbacks.m_begin_diagnostic = default_diagnostic_starter;
+ m_text_callbacks.m_start_span = default_diagnostic_start_span_fn;
+ m_text_callbacks.m_end_diagnostic = default_diagnostic_finalizer;
m_option_enabled = nullptr;
m_option_state = nullptr;
m_option_name = nullptr;
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index 2489855..57c5ed4 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -352,6 +352,14 @@ struct diagnostic_source_printing_options
class diagnostic_context
{
public:
+ /* Give access to m_text_callbacks. */
+ friend diagnostic_starter_fn &
+ diagnostic_starter (diagnostic_context *context);
+ friend diagnostic_start_span_fn &
+ diagnostic_start_span (diagnostic_context *context);
+ friend diagnostic_finalizer_fn &
+ diagnostic_finalizer (diagnostic_context *context);
+
typedef void (*ice_handler_callback_t) (diagnostic_context *);
typedef void (*set_locations_callback_t) (diagnostic_context *,
diagnostic_info *);
@@ -574,7 +582,6 @@ private:
/* Maximum number of errors to report. */
int m_max_errors;
-public:
/* Client-supplied callbacks for use in text output. */
struct {
/* This function is called before any message is printed out. It is
@@ -584,17 +591,18 @@ public:
from "/home/gdr/src/nifty_printer.h:56:
...
*/
- diagnostic_starter_fn begin_diagnostic;
+ diagnostic_starter_fn m_begin_diagnostic;
/* This function is called by diagnostic_show_locus in between
disjoint spans of source code, so that the context can print
something to indicate that a new span of source code has begun. */
- diagnostic_start_span_fn start_span;
+ diagnostic_start_span_fn m_start_span;
/* This function is called after the diagnostic message is printed. */
- diagnostic_finalizer_fn end_diagnostic;
+ diagnostic_finalizer_fn m_end_diagnostic;
} m_text_callbacks;
+public:
/* Client hook to report an internal error. */
void (*m_internal_error) (diagnostic_context *, const char *, va_list *);
@@ -734,11 +742,28 @@ diagnostic_inhibit_notes (diagnostic_context * context)
/* Client supplied function to announce a diagnostic
(for text-based diagnostic output). */
-#define diagnostic_starter(DC) (DC)->m_text_callbacks.begin_diagnostic
+inline diagnostic_starter_fn &
+diagnostic_starter (diagnostic_context *context)
+{
+ return context->m_text_callbacks.m_begin_diagnostic;
+}
+
+/* Client supplied function called between disjoint spans of source code,
+ so that the context can print
+ something to indicate that a new span of source code has begun. */
+inline diagnostic_start_span_fn &
+diagnostic_start_span (diagnostic_context *context)
+{
+ return context->m_text_callbacks.m_start_span;
+}
/* Client supplied function called after a diagnostic message is
displayed (for text-based diagnostic output). */
-#define diagnostic_finalizer(DC) (DC)->m_text_callbacks.end_diagnostic
+inline diagnostic_finalizer_fn &
+diagnostic_finalizer (diagnostic_context *context)
+{
+ return context->m_text_callbacks.m_end_diagnostic;
+}
/* Extension hooks for client. */
#define diagnostic_context_auxiliary_data(DC) (DC)->m_client_aux_data
diff --git a/gcc/fortran/error.cc b/gcc/fortran/error.cc
index ca31775..2ac51e9 100644
--- a/gcc/fortran/error.cc
+++ b/gcc/fortran/error.cc
@@ -1637,7 +1637,7 @@ void
gfc_diagnostics_init (void)
{
diagnostic_starter (global_dc) = gfc_diagnostic_starter;
- global_dc->m_text_callbacks.start_span = gfc_diagnostic_start_span;
+ diagnostic_start_span (global_dc) = gfc_diagnostic_start_span;
diagnostic_finalizer (global_dc) = gfc_diagnostic_finalizer;
diagnostic_format_decoder (global_dc) = gfc_format_decoder;
global_dc->m_source_printing.caret_chars[0] = '1';
diff --git a/gcc/selftest-diagnostic.cc b/gcc/selftest-diagnostic.cc
index 37e98ed..f9a1852 100644
--- a/gcc/selftest-diagnostic.cc
+++ b/gcc/selftest-diagnostic.cc
@@ -39,7 +39,7 @@ test_diagnostic_context::test_diagnostic_context ()
m_source_printing.enabled = true;
m_source_printing.show_labels_p = true;
m_show_column = true;
- m_text_callbacks.start_span = start_span_cb;
+ diagnostic_start_span (this) = start_span_cb;
m_source_printing.min_margin_width = 6;
m_source_printing.max_width = 80;
}
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c
index e8903ba..ce0b322 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c
@@ -224,7 +224,7 @@ plugin_init (struct plugin_name_args *plugin_info,
return 1;
diagnostic_starter (global_dc) = test_diagnostic_starter;
- global_dc->m_text_callbacks.start_span = test_diagnostic_start_span_fn;
+ diagnostic_start_span (global_dc) = test_diagnostic_start_span_fn;
global_dc->set_output_format (new test_output_format (*global_dc));
pass_info.pass = new pass_test_groups (g);
diff --git a/gcc/tree-diagnostic-path.cc b/gcc/tree-diagnostic-path.cc
index d2345c8..3cd9c21 100644
--- a/gcc/tree-diagnostic-path.cc
+++ b/gcc/tree-diagnostic-path.cc
@@ -206,7 +206,7 @@ struct event_range
= linemap_client_expand_location_to_spelling_point
(line_table, initial_loc, LOCATION_ASPECT_CARET);
if (exploc.file != LOCATION_FILE (dc->m_last_location))
- dc->m_text_callbacks.start_span (dc, exploc);
+ diagnostic_start_span (dc) (dc, exploc);
}
/* If we have an UNKNOWN_LOCATION (or BUILTINS_LOCATION) as the