public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/100695] New: Format decoder, quoting in 'dump_printf' etc.
@ 2021-05-20 8:11 tschwinge at gcc dot gnu.org
2021-06-09 17:48 ` [Bug other/100695] " jakub at gcc dot gnu.org
2022-07-01 8:12 ` burnus at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: tschwinge at gcc dot gnu.org @ 2021-05-20 8:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100695
Bug ID: 100695
Summary: Format decoder, quoting in 'dump_printf' etc.
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: other
Assignee: unassigned at gcc dot gnu.org
Reporter: tschwinge at gcc dot gnu.org
CC: dmalcolm at gcc dot gnu.org
Target Milestone: ---
For user-visible '-fopt-info' diagnostics ('dump_printf' etc.), I'm trying to
pretty-print a TREE DECL, using the '%T' format code. As in other compiler
diagnostics, I'd like the output to be quoted, so I tried using '%qT' but that
prints the same as '%T' (unexpected?). Using '%<%T%>' prints the desired
output -- but GCC bootstrap doesn't like that one:
[...]/gcc/omp-low.c:10171:33: error: ‘T’ conversion used within a quoted
sequence [-Werror=format=]
10171 | "variable %<%T%> ", decl);
| ^
I'll work around that, but something seems inconsistent here?
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug other/100695] Format decoder, quoting in 'dump_printf' etc.
2021-05-20 8:11 [Bug other/100695] New: Format decoder, quoting in 'dump_printf' etc tschwinge at gcc dot gnu.org
@ 2021-06-09 17:48 ` jakub at gcc dot gnu.org
2022-07-01 8:12 ` burnus at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-06-09 17:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100695
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org,
| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
As an example, can be reproduced e.g. on
./cc1 -quiet -fopt-info-omp-note --param=openacc-privatization=noisy -fopenacc
-O2 .../gcc/testsuite/c-c++-common/goacc/privatization-1-routine_gang-loop.c
when that omp-low.c %<%T%> is changed to %qT.
>From what I see, the quotes for %< are emitted using:
case '<':
{
obstack_grow (&buffer->chunk_obstack,
open_quote, strlen (open_quote));
const char *colorstr
= colorize_start (pp_show_color (pp), "quote");
obstack_grow (&buffer->chunk_obstack, colorstr, strlen (colorstr));
but for %qX using:
if (quote)
pp_begin_quote (pp, pp_show_color (pp));
and similarly for the closing quote.
In the case of dump_print_*, the characters go into chunk_obstack, while e.g.
what '%T' provides goes to the stashed items or where.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug other/100695] Format decoder, quoting in 'dump_printf' etc.
2021-05-20 8:11 [Bug other/100695] New: Format decoder, quoting in 'dump_printf' etc tschwinge at gcc dot gnu.org
2021-06-09 17:48 ` [Bug other/100695] " jakub at gcc dot gnu.org
@ 2022-07-01 8:12 ` burnus at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-07-01 8:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100695
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Created attachment 53233
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53233&action=edit
Patch which does not work (segfault during self test) – but maybe it gives an
idea how to solve the issue
I think there are multiple issues:
(a) '%T' does not accept %qT but there is still an error for using %<%T%>
(b) Using %qT should be accepted. This implies both the addition of "q" to
c-family/c-format.cc's gcc_dump_printf_char_table
to permit it.
(c) Using %qT kind of works - but does not actually print the quotes.
(cf. comment 1)
That's because of how it is processed. In pretty-print.cc pp_format:
if (quote)
pp_begin_quote (pp, pp_show_color (pp));
...
ok = pp_format_decoder (pp) (pp, text, p,
precision, wide, plus, hash, "e,
formatters[argno]);
...
if (quote)
pp_end_quote (pp, pp_show_color (pp));
This works well, if the item - is processed directly.
For instance, tree-diagnostic.cc's default_tree_printer just does:
case 'E':
...
pp_identifier (pp, IDENTIFIER_POINTER (t));
return true;
However, in dumpfile.cc's dump_pretty_printer::decode_format there is no direct
output but the %qT processing is deferred (spec = 'T', buffer_ptr = "qT"):
dump_pretty_printer::decode_format (text_info *text, const char *spec,
const char **buffer_ptr)
{
/* Various format codes that imply making an optinfo_item and stashed it
for later use (to capture metadata, rather than plain text). */
...
case 'T':
{
tree t = va_arg (*text->args_ptr, tree);
/* Make an item for the tree, and stash it. */
optinfo_item *item = make_item_for_dump_generic_expr (t, TDF_SLIM);
stash_item (buffer_ptr, item);
return true;
And the 'stash_item' effectively undoes the quote. For %<...%>, those are
processed separately, such that 'decode_format' only processes '%T' and the
quotes are retained.
Thus, one way would be to 'obstack_grow' - or something like that to "split"
'q' ... 'T' in %qT. Or to handle somehow the
pp_buffer(pp)
in dump_pretty_printer::decode_format
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-01 8:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-20 8:11 [Bug other/100695] New: Format decoder, quoting in 'dump_printf' etc tschwinge at gcc dot gnu.org
2021-06-09 17:48 ` [Bug other/100695] " jakub at gcc dot gnu.org
2022-07-01 8:12 ` burnus at gcc dot gnu.org
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).