summaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-sprintf.c
diff options
context:
space:
mode:
authormsebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4>2016-11-23 16:44:16 +0000
committermsebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4>2016-11-23 16:44:16 +0000
commit88a2ded0b6466bdd5513750bd73a7b5c788de6aa (patch)
tree3634901e3c572047408b87979874512cb0988c4c /gcc/gimple-ssa-sprintf.c
parentb4f7eabaf55907545d33587fdea9d6366b4237c3 (diff)
downloadgcc-88a2ded0b6466bdd5513750bd73a7b5c788de6aa.tar.gz
PR middle-end/78461 - [7 Regression] ICE: in operator+=
gcc/testsuite/ChangeLog: PR middle-end/78461 * gcc.dg/tree-ssa/builtin-sprintf-4.c: New test. * gcc.dg/tree-ssa/builtin-sprintf-warn-2.c: Adjust warning text. gcc/ChangeLog: PR middle-end/78461 * gimple-ssa-sprintf.c (format_string): Correct the maxima and set the minimum number of bytes for an unknown string to zero. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242769 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple-ssa-sprintf.c')
-rw-r--r--gcc/gimple-ssa-sprintf.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index 3138ad3624f..ead8b0ed5a0 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -1533,18 +1533,15 @@ format_string (const conversion_spec &spec, tree arg)
fmtresult res;
/* The maximum number of bytes for an unknown wide character argument
- to a "%lc" directive adjusted for precision but not field width. */
+ to a "%lc" directive adjusted for precision but not field width.
+ 6 is the longest UTF-8 sequence for a single wide character. */
const unsigned HOST_WIDE_INT max_bytes_for_unknown_wc
- = (1 == warn_format_length ? 0 <= prec ? prec : 0
- : 2 == warn_format_length ? 0 <= prec ? prec : 1
- : 0 <= prec ? prec : 6 /* Longest UTF-8 sequence. */);
+ = (0 <= prec ? prec : 1 < warn_format_length ? 6 : 1);
/* The maximum number of bytes for an unknown string argument to either
a "%s" or "%ls" directive adjusted for precision but not field width. */
const unsigned HOST_WIDE_INT max_bytes_for_unknown_str
- = (1 == warn_format_length ? 0 <= prec ? prec : 0
- : 2 == warn_format_length ? 0 <= prec ? prec : 1
- : HOST_WIDE_INT_MAX);
+ = (0 <= prec ? prec : 1 < warn_format_length);
/* The result is bounded unless overriddden for a non-constant string
of an unknown length. */
@@ -1648,7 +1645,7 @@ format_string (const conversion_spec &spec, tree arg)
if (0 <= prec)
{
if (slen.range.min >= target_int_max ())
- slen.range.min = max_bytes_for_unknown_str;
+ slen.range.min = 0;
else if ((unsigned)prec < slen.range.min)
slen.range.min = prec;