diff options
author | David Malcolm <dmalcolm@redhat.com> | 2018-11-08 15:31:13 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2018-11-08 15:31:13 +0000 |
commit | 204839e7c41678c3f93975fe4356492040fcf411 (patch) | |
tree | 165ff5ba4d3971a53895f9ffd34e233e26a72cc2 /gcc/pretty-print.h | |
parent | d8010ee4560a947f690891f919db177b03581f9a (diff) | |
download | gcc-204839e7c41678c3f93975fe4356492040fcf411.zip gcc-204839e7c41678c3f93975fe4356492040fcf411.tar.gz gcc-204839e7c41678c3f93975fe4356492040fcf411.tar.bz2 |
Support %f in pp_format
Numerous formatted messages from the inliner use %f, mostly as %f, but
occasionally with length modifiers.
This patch implements the simplest case of "%f" for pp_format (with no
modifier support) to make it easier to port these messages from fprintf
to dump_printf_loc.
The selftest has an assertion that %f on 1.0 is printed as "1.000000".
This comes from the host's sprintf, and I believe this is guaranteed by
POSIX: "If the precision is missing, it shall be taken as 6". If this is
an issue I can drop the selftest.
gcc/c-family/ChangeLog:
* c-format.c (gcc_dump_printf_char_table): Add entry for %f.
gcc/ChangeLog:
* pretty-print.c (pp_format): Handle %f.
(selftest::test_pp_format): Add test of %f.
* pretty-print.h (pp_double): New macro.
gcc/testsuite/ChangeLog:
* gcc.dg/format/gcc_diag-10.c: Add coverage for %f.
From-SVN: r265919
Diffstat (limited to 'gcc/pretty-print.h')
-rw-r--r-- | gcc/pretty-print.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/pretty-print.h b/gcc/pretty-print.h index 2decc51..a6e60f1 100644 --- a/gcc/pretty-print.h +++ b/gcc/pretty-print.h @@ -330,6 +330,7 @@ pp_get_prefix (const pretty_printer *pp) { return pp->prefix; } pp_string (PP, pp_buffer (PP)->digit_buffer); \ } \ while (0) +#define pp_double(PP, F) pp_scalar (PP, "%f", F) #define pp_pointer(PP, P) pp_scalar (PP, "%p", P) #define pp_identifier(PP, ID) pp_string (PP, (pp_translate_identifiers (PP) \ |