+2018-08-16 David Malcolm <dmalcolm@redhat.com>
+
+ * diagnostic.c (default_diagnostic_start_span_fn): Call pp_string
+ to emit the span, rather than setting it as the prefix.
+
2018-08-16 David Malcolm <dmalcolm@redhat.com>
* diagnostic-show-locus.c (layout::start_annotation_line): Add
default_diagnostic_start_span_fn (diagnostic_context *context,
expanded_location exploc)
{
- pp_set_prefix (context->printer,
- diagnostic_get_location_text (context, exploc));
- pp_string (context->printer, "");
+ char *text = diagnostic_get_location_text (context, exploc);
+ pp_string (context->printer, text);
+ free (text);
pp_newline (context->printer);
}
+2018-08-16 David Malcolm <dmalcolm@redhat.com>
+
+ * gcc.dg/missing-header-fixit-3.c: New test.
+
2018-08-16 David Malcolm <dmalcolm@redhat.com>
* gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c
--- /dev/null
+/* Example of a fix-it hint that adds a #include directive,
+ adding them to the top of the file, given that there is no
+ pre-existing #include. */
+
+/* { dg-options "-fdiagnostics-show-caret -fdiagnostics-show-line-numbers" } */
+
+void test (int i, int j)
+{
+ printf ("%i of %i\n", i, j); /* { dg-warning "implicit declaration" } */
+ /* { dg-message "include '<stdio.h>' or provide a declaration of 'printf'" "" { target *-*-* } .-1 } */
+#if 0
+/* { dg-begin-multiline-output "" }
+9 | printf ("%i of %i\n", i, j);
+ | ^~~~~~
+ { dg-end-multiline-output "" } */
+/* { dg-regexp ".*missing-header-fixit-3.c:1:1:" } */
+/* { dg-begin-multiline-output "" }
++ |+#include <stdio.h>
+1 | /* Example of a fix-it hint that adds a #include directive,
+ { dg-end-multiline-output "" } */
+/* { dg-regexp ".*missing-header-fixit-3.c:9:3:" } */
+/* { dg-begin-multiline-output "" }
+9 | printf ("%i of %i\n", i, j);
+ | ^~~~~~
+ { dg-end-multiline-output "" } */
+#endif
+}