]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
diagnostics: handle pp_token::kind::event_id in experimental-html sink [PR116792]
authorDavid Malcolm <dmalcolm@redhat.com>
Mon, 23 Jun 2025 15:06:33 +0000 (11:06 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Mon, 23 Jun 2025 15:06:33 +0000 (11:06 -0400)
gcc/ChangeLog:
PR other/116792
* diagnostic-format-html.cc (html_token_printer::print_tokens):
Handle pp_token::kind::event_id.
(selftest::test_token_printer): Add coverage of printing an event
id.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/diagnostic-format-html.cc

index 45d088150dd6b6cc9ed105135ba049d61d472c59..5668b50a91aeb3f60d25377526faf16b3b6a7ec7 100644 (file)
@@ -799,6 +799,16 @@ public:
        case pp_token::kind::end_url:
          m_xp.pop_tag ("a");
          break;
+
+       case pp_token::kind::event_id:
+         {
+           pp_token_event_id *sub = as_a <pp_token_event_id *> (iter);
+           gcc_assert (sub->m_event_id.known_p ());
+           m_xp.add_text ("(");
+           m_xp.add_text (std::to_string (sub->m_event_id.one_based ()));
+           m_xp.add_text (")");
+         }
+         break;
        }
   }
 
@@ -1375,6 +1385,15 @@ test_token_printer ()
        "&apos;"
        "</div>\n");
   }
+
+  {
+    token_printer_test t;
+    diagnostic_event_id_t event_id (0);
+    pp_printf (&t.m_pp, "foo %@ bar", &event_id);
+    ASSERT_XML_PRINT_EQ
+      (t.m_top_element,
+       "<div>foo (1) bar</div>\n");
+  }
 }
 
 /* A subclass of html_output_format for writing selftests.