summaryrefslogtreecommitdiff
path: root/gcc/diagnostic.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/diagnostic.c')
-rw-r--r--gcc/diagnostic.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 47b4c79ebcc..585028ec211 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see
#include "backtrace.h"
#include "diagnostic.h"
#include "diagnostic-color.h"
+#include "edit-context.h"
#include "selftest.h"
#ifdef HAVE_TERMIOS_H
@@ -174,6 +175,7 @@ diagnostic_initialize (diagnostic_context *context, int n_opts)
context->colorize_source_p = false;
context->show_ruler_p = false;
context->parseable_fixits_p = false;
+ context->edit_context_ptr = NULL;
}
/* Maybe initialize the color support. We require clients to do this
@@ -235,6 +237,12 @@ diagnostic_finish (diagnostic_context *context)
context->printer->~pretty_printer ();
XDELETE (context->printer);
context->printer = NULL;
+
+ if (context->edit_context_ptr)
+ {
+ delete context->edit_context_ptr;
+ context->edit_context_ptr = NULL;
+ }
}
/* Initialize DIAGNOSTIC, where the message MSG has already been
@@ -943,6 +951,9 @@ diagnostic_report_diagnostic (diagnostic_context *context,
diagnostic->message.format_spec = saved_format_spec;
diagnostic->x_data = NULL;
+ if (context->edit_context_ptr)
+ context->edit_context_ptr->add_fixits (diagnostic->richloc);
+
context->lock--;
return true;
@@ -1493,7 +1504,7 @@ test_print_parseable_fixits_insert ()
linemap_line_start (line_table, 5, 100);
linemap_add (line_table, LC_LEAVE, false, NULL, 0);
location_t where = linemap_position_for_column (line_table, 10);
- richloc.add_fixit_insert (where, "added content");
+ richloc.add_fixit_insert_before (where, "added content");
print_parseable_fixits (&pp, &richloc);
ASSERT_STREQ ("fix-it:\"test.c\":{5:10-5:10}:\"added content\"\n",