aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/out-of-bounds-diagram-1-emoji.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/warning-emoji.c29
-rw-r--r--gcc/tree-diagnostic-path.cc30
3 files changed, 57 insertions, 4 deletions
diff --git a/gcc/testsuite/gcc.dg/analyzer/out-of-bounds-diagram-1-emoji.c b/gcc/testsuite/gcc.dg/analyzer/out-of-bounds-diagram-1-emoji.c
index 1c61252..7b4ecf0 100644
--- a/gcc/testsuite/gcc.dg/analyzer/out-of-bounds-diagram-1-emoji.c
+++ b/gcc/testsuite/gcc.dg/analyzer/out-of-bounds-diagram-1-emoji.c
@@ -29,7 +29,7 @@ void int_arr_write_element_after_end_off_by_one(int32_t x)
| arr[10] = x;
| ~~~~~~~~^~~
| |
- | (2) out-of-bounds write from byte 40 till byte 43 but 'arr' ends at byte 40
+ | (2) ⚠️ out-of-bounds write from byte 40 till byte 43 but 'arr' ends at byte 40
|
{ dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/analyzer/warning-emoji.c b/gcc/testsuite/gcc.dg/analyzer/warning-emoji.c
new file mode 100644
index 0000000..47e5fb0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/warning-emoji.c
@@ -0,0 +1,29 @@
+/* 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 "" } */
diff --git a/gcc/tree-diagnostic-path.cc b/gcc/tree-diagnostic-path.cc
index 33389ef..bc90aaf 100644
--- a/gcc/tree-diagnostic-path.cc
+++ b/gcc/tree-diagnostic-path.cc
@@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic-event-id.h"
#include "selftest.h"
#include "selftest-diagnostic.h"
+#include "text-art/theme.h"
/* Anonymous namespace for path-printing code. */
@@ -60,13 +61,36 @@ class path_label : public range_label
/* 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;
}