From 331226fd87c2010928329ef35b6d4f680d9234d1 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 11 Dec 2024 10:21:35 -0500 Subject: [PATCH] diagnostics: tweak output for nested messages [PR116253] MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When printing nested messages with -fdiagnostics-set-output=text:experimental-nesting=yes avoid printing a line such as the "cc1plus:" in the following: • note: set ‘-fconcepts-diagnostics-depth=’ to at least 2 for more detail cc1plus: for "special" locations such as UNKNOWN_LOCATION. gcc/ChangeLog: PR other/116253 * diagnostic-format-text.cc (on_report_diagnostic): When showing locations for nested messages on new lines, don't print UNKNOWN_LOCATION or BUILTINS_LOCATION. Signed-off-by: David Malcolm --- gcc/diagnostic-format-text.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/diagnostic-format-text.cc b/gcc/diagnostic-format-text.cc index d85c88083485..2f26582fa2be 100644 --- a/gcc/diagnostic-format-text.cc +++ b/gcc/diagnostic-format-text.cc @@ -226,11 +226,12 @@ on_report_diagnostic (const diagnostic_info &diagnostic, const int nesting_level = get_context ().get_diagnostic_nesting_level (); if (nesting_level > 0) { + location_t loc = diagnostic_location (&diagnostic); pp_set_prefix (pp, nullptr); char *indent_prefix = build_indent_prefix (false); /* Only print changes of location. */ - if (diagnostic_location (&diagnostic) - != get_context ().m_last_location) + if (loc != get_context ().m_last_location + && loc > BUILTINS_LOCATION) { const expanded_location s = diagnostic_expand_location (&diagnostic); -- 2.47.2