--- /dev/null
+/* Verify that the final event in an analyzer path gets a "warning" emoji
+ when -fdiagnostics-text-art-charset=emoji (and
+ -fdiagnostics-path-format=inline-events). */
+
+/* { dg-additional-options "-fdiagnostics-show-line-numbers" } */
+/* { dg-additional-options "-fdiagnostics-show-caret" } */
+/* { dg-additional-options "-fdiagnostics-path-format=inline-events" } */
+/* { dg-additional-options "-fdiagnostics-text-art-charset=emoji" } */
+/* { dg-enable-nn-line-numbers "" } */
+
+void test (void *p)
+{
+ __builtin_free (p);
+ __builtin_free (p); /* { dg-warning "double-'free'" } */
+}
+
+/* { dg-begin-multiline-output "" }
+ NN | __builtin_free (p);
+ | ^~~~~~~~~~~~~~~~~~
+ 'test': events 1-2
+ NN | __builtin_free (p);
+ | ^~~~~~~~~~~~~~~~~~
+ | |
+ | (1) first 'free' here
+ NN | __builtin_free (p);
+ | ~~~~~~~~~~~~~~~~~~
+ | |
+ | (2) ⚠️ second 'free' here; first 'free' was at (1)
+ { dg-end-multiline-output "" } */
#include "diagnostic-event-id.h"
#include "selftest.h"
#include "selftest-diagnostic.h"
+#include "text-art/theme.h"
/* Anonymous namespace for path-printing code. */
/* Get the description of the event, perhaps with colorization:
normally, we don't colorize within a range_label, but this
is special-cased for diagnostic paths. */
- bool colorize = pp_show_color (global_dc->printer);
+ const bool colorize = pp_show_color (global_dc->printer);
label_text event_text (event.get_desc (colorize));
gcc_assert (event_text.get ());
+
+ const diagnostic_event::meaning meaning (event.get_meaning ());
+
pretty_printer pp;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = colorize;
diagnostic_event_id_t event_id (event_idx);
- pp_printf (&pp, "%@ %s", &event_id, event_text.get ());
+
+ pp_printf (&pp, "%@", &event_id);
+ pp_space (&pp);
+
+ if (meaning.m_verb == diagnostic_event::VERB_danger)
+ if (text_art::theme *theme = global_dc->get_diagram_theme ())
+ if (theme->emojis_p ())
+ {
+ pp_unicode_character (&pp, 0x26A0); /* U+26A0 WARNING SIGN. */
+ /* Append U+FE0F VARIATION SELECTOR-16 to select the emoji
+ variation of the char. */
+ pp_unicode_character (&pp, 0xFE0F);
+ /* U+26A0 WARNING SIGN has East_Asian_Width == Neutral, but in its
+ emoji variant is printed (by vte at least) with a 2nd half
+ overlapping the next char. Hence we add two spaces here: a space
+ to be covered by this overlap, plus another space of padding. */
+ pp_string (&pp, " ");
+ }
+
+ pp_printf (&pp, "%s", event_text.get ());
+
label_text result = label_text::take (xstrdup (pp_formatted_text (&pp)));
return result;
}