diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-12-14 12:01:17 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-12-14 12:01:17 +0100 |
commit | aa215959c5f6c6ec2e877d976f305eb8c9e08f2c (patch) | |
tree | 43598faf2cd837cd2eac5bdcc2a1bd2d9092b792 /gcc/gimple-ssa-sprintf.c | |
parent | 8332c5ee8c5f3bf91eb97666793e9589f2578a05 (diff) | |
download | gcc-aa215959c5f6c6ec2e877d976f305eb8c9e08f2c.zip gcc-aa215959c5f6c6ec2e877d976f305eb8c9e08f2c.tar.gz gcc-aa215959c5f6c6ec2e877d976f305eb8c9e08f2c.tar.bz2 |
re PR tree-optimization/83198 (ICE in format_floating, at gimple-ssa-sprintf.c:1900)
PR tree-optimization/83198
* gimple-ssa-sprintf.c (format_floating): Set type solely based on
dir.modifier, regardless of TREE_TYPE (arg). Assume non-REAL_CST
value if arg is a REAL_CST with incompatible type.
* gcc.dg/pr83198.c: New test.
* gcc.dg/tree-ssa/pr83198.c: New test.
From-SVN: r255626
Diffstat (limited to 'gcc/gimple-ssa-sprintf.c')
-rw-r--r-- | gcc/gimple-ssa-sprintf.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c index 35ceb2c..75935be 100644 --- a/gcc/gimple-ssa-sprintf.c +++ b/gcc/gimple-ssa-sprintf.c @@ -1885,6 +1885,8 @@ static fmtresult format_floating (const directive &dir, tree arg) { HOST_WIDE_INT prec[] = { dir.prec[0], dir.prec[1] }; + tree type = (dir.modifier == FMT_LEN_L || dir.modifier == FMT_LEN_ll + ? long_double_type_node : double_type_node); /* For an indeterminate precision the lower bound must be assumed to be zero. */ @@ -1892,10 +1894,6 @@ format_floating (const directive &dir, tree arg) { /* Get the number of fractional decimal digits needed to represent the argument without a loss of accuracy. */ - tree type = arg ? TREE_TYPE (arg) : - (dir.modifier == FMT_LEN_L || dir.modifier == FMT_LEN_ll - ? long_double_type_node : double_type_node); - unsigned fmtprec = REAL_MODE_FORMAT (TYPE_MODE (type))->p; @@ -1946,7 +1944,9 @@ format_floating (const directive &dir, tree arg) } } - if (!arg || TREE_CODE (arg) != REAL_CST) + if (!arg + || TREE_CODE (arg) != REAL_CST + || !useless_type_conversion_p (type, TREE_TYPE (arg))) return format_floating (dir, prec); /* The minimum and maximum number of bytes produced by the directive. */ |