public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] middle-end/97855 - fix diagnostic with default pretty printer
@ 2021-03-01  8:39 Richard Biener
  2021-03-02 16:52 ` Jeff Law
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Biener @ 2021-03-01  8:39 UTC (permalink / raw)
  To: gcc-patches; +Cc: dmalcolm, jakub

The default diagnostic tree printer relies on dump_generic_node which
for some reason manages to clobber the diagnostic pretty-printer state
so we see garbled diagnostics like

/home/rguenther/src/trunk/gcc/calls.c: In function 'expand_call':
D.6750.coeffs[0]'/home/rguenther/src/trunk/gcc/dojump.c:118:28: warning:  may be used uninitialized in this function [-Wmaybe-uninitialized]

when the diagnostic is emitted by the LTO fronted.  The following
approach using a temporary pretty-printer for the dump_generic_node
call fixes this for some unknown reason and we issue

/home/rguenther/src/trunk/gcc/calls.c: In function 'expand_call':
/home/rguenther/src/trunk/gcc/dojump.c:118:28: warning: 'MEM[(struct poly_int *)&save].D.6750.coeffs[0]' may be used uninitialized in this function [-Wmaybe-uninitialized]

[LTO] Bootstrapped and tested on x86_64-unknown-linux-gnu, OK for trunk?

Thanks,
Richard.

2021-02-26  Richard Biener  <rguenther@suse.de>

	PR middle-end/97855
	* tree-diagnostic.c (default_tree_printer): Use a temporary
	pretty-printer when formatting a tree via dump_generic_node.
---
 gcc/tree-diagnostic.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-diagnostic.c b/gcc/tree-diagnostic.c
index 95b8ef30070..f124e627aad 100644
--- a/gcc/tree-diagnostic.c
+++ b/gcc/tree-diagnostic.c
@@ -300,7 +300,11 @@ default_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
       pp_string (pp, n);
     }
   else
-    dump_generic_node (pp, t, 0, TDF_SLIM, 0);
+    {
+      pretty_printer buffer;
+      dump_generic_node (&buffer, t, 0, TDF_SLIM, 0);
+      pp_string (pp, pp_formatted_text (&buffer));
+    }
 
   return true;
 }
-- 
2.26.2

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-03-04 14:21 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01  8:39 [PATCH] middle-end/97855 - fix diagnostic with default pretty printer Richard Biener
2021-03-02 16:52 ` Jeff Law
2021-03-02 20:36   ` Martin Sebor
2021-03-03  7:48     ` Richard Biener
2021-03-03 15:00       ` David Malcolm
2021-03-03 15:23         ` Richard Biener
2021-03-03 15:52           ` Jakub Jelinek
2021-03-03 17:45           ` David Malcolm
2021-03-03 18:02             ` Jakub Jelinek
2021-03-04  8:39           ` Richard Biener
2021-03-04 12:24             ` Richard Biener
2021-03-04 14:20             ` David Malcolm
2021-03-04 14:21               ` David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).