PR middle-end/78703 -fprintf-return-value floating point handling incorrect in locale...
authorMartin Sebor <msebor@redhat.com>
Thu, 26 Jan 2017 21:14:18 +0000 (21:14 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Thu, 26 Jan 2017 21:14:18 +0000 (14:14 -0700)
commit5d93da1d112c93b38b6c68e3c51e20daefc01423
tree8ffb711a698c635dac9a4bda3e672fa8a950f45e
parentc86996727f9c4ea4e2aed092d631a2cf99110c5d
PR middle-end/78703 -fprintf-return-value floating point handling incorrect in locales with a mulltibyte decimal point

gcc/ChangeLog:
PR middle-end/78703
* gimple-ssa-sprintf.c (struct result_range): Add likely and
unlikely counters.
(struct format_result): Replace number_chars, number_chars_min,
and number_chars_max with a single member of struct result_range.
Remove bounded.
(format_result::operator+=): Adjust.
(struct fmtresult): Remove bounded.  Handle likely and unlikely
counters.
(fmtresult::adjust_for_width_or_precision): New function.
(fmtresult:type_max_digits): New function.
(bytes_remaining): Handle likely and unlikely counters.
(min_bytes_remaining): Remove.
(format_percent): Simplify.
(format_integer, format_floating): Set likely and unlikely counters.
(get_string_length, format_character, format_string): Same.
(format_plain, should_warn_p): New function.
(maybe_warn): Call should_warn_p.  Update diagnostic messages
and handle those for all directives, including plain strings.
(format_directive): Handle likely and unlikely counters.
Remove unnecessary quoting from diagnostics.  Add an informational
note.
(add_bytes): Remove.
(pass_sprintf_length::compute_format_length): Simplify.
(try_substitute_return_value): Handle likely and unlikely counters.

gcc/testsuite/ChangeLog:

PR middle-end/78703
* gcc.dg/format/pr78569.c: Adjust.
* gcc.dg/tree-ssa/builtin-snprintf-warn-2.c: Same.
* gcc.dg/tree-ssa/builtin-sprintf-2.c: Same.
* gcc.dg/tree-ssa/builtin-sprintf-5.c: Same.
* gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Same.
* gcc.dg/tree-ssa/builtin-sprintf-warn-2.c: Same.
* gcc.dg/tree-ssa/builtin-sprintf-warn-3.c: Same.
* gcc.dg/tree-ssa/builtin-sprintf-warn-4.c: Same.
* gcc.dg/tree-ssa/builtin-sprintf-warn-6.c: Same.
* gcc.dg/tree-ssa/builtin-sprintf-warn-7.c: Same.
* gcc.dg/tree-ssa/builtin-sprintf-warn-9.c: Same.
* gcc.dg/tree-ssa/builtin-sprintf.c: Same.

From-SVN: r244953
15 files changed:
gcc/ChangeLog
gcc/gimple-ssa-sprintf.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/format/pr78569.c
gcc/testsuite/gcc.dg/tree-ssa/builtin-snprintf-warn-2.c
gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c
gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-5.c
gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c
gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-2.c
gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-3.c
gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-4.c
gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-6.c
gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-7.c
gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-9.c
gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf.c