aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-sprintf.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-04-09 12:26:13 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2019-04-09 12:26:13 +0200
commita73468e8c724fa76eccdf33835e9705a37e21381 (patch)
treec3c993e2eb3474b5c54bb81a3cc2a3e1f059865d /gcc/gimple-ssa-sprintf.c
parent1c67e69c0dea67fab1ef32e8b78bf24cc1b3f06a (diff)
downloadgcc-a73468e8c724fa76eccdf33835e9705a37e21381.zip
gcc-a73468e8c724fa76eccdf33835e9705a37e21381.tar.gz
gcc-a73468e8c724fa76eccdf33835e9705a37e21381.tar.bz2
re PR middle-end/89998 (ICE: verify_gimple failed in printf-return-value)
PR tree-optimization/89998 * gimple-ssa-sprintf.c (try_substitute_return_value): Use lhs type instead of integer_type_node if possible, don't add ranges if return type is not compatible with int. * gimple-fold.c (gimple_fold_builtin_sprintf, gimple_fold_builtin_snprintf): Use lhs type instead of hardcoded integer_type_node. * gcc.c-torture/compile/pr89998-1.c: New test. * gcc.c-torture/compile/pr89998-2.c: New test. From-SVN: r270224
Diffstat (limited to 'gcc/gimple-ssa-sprintf.c')
-rw-r--r--gcc/gimple-ssa-sprintf.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index ced1c4c..de60241 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -3692,10 +3692,10 @@ try_substitute_return_value (gimple_stmt_iterator *gsi,
are badly declared. */
&& !stmt_ends_bb_p (info.callstmt))
{
- tree cst = build_int_cst (integer_type_node, retval[0]);
+ tree cst = build_int_cst (lhs ? TREE_TYPE (lhs) : integer_type_node,
+ retval[0]);
- if (lhs == NULL_TREE
- && info.nowrite)
+ if (lhs == NULL_TREE && info.nowrite)
{
/* Remove the call to the bounded function with a zero size
(e.g., snprintf(0, 0, "%i", 123)) if there is no lhs. */
@@ -3736,7 +3736,7 @@ try_substitute_return_value (gimple_stmt_iterator *gsi,
}
}
}
- else if (lhs)
+ else if (lhs && types_compatible_p (TREE_TYPE (lhs), integer_type_node))
{
bool setrange = false;