summaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-sprintf.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2017-01-03 07:20:04 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2017-01-03 07:20:04 +0000
commit418624fa006fc343b05f8e596fab7b7214c03c06 (patch)
tree4fa7ba8f61eb91be1857c52eae3cadc7f87666c4 /gcc/gimple-ssa-sprintf.c
parent8ecf773ba34e40a7c2a3e30a0f687ee7c8e1df48 (diff)
downloadgcc-418624fa006fc343b05f8e596fab7b7214c03c06.tar.gz
PR middle-end/78901
* gimple-ssa-sprintf.c (try_substitute_return_value): Don't change possibly throwing calls. * g++.dg/opt/pr78901.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@244013 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple-ssa-sprintf.c')
-rw-r--r--gcc/gimple-ssa-sprintf.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index 907a06479ee..ecd2267ae93 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -2696,9 +2696,15 @@ try_substitute_return_value (gimple_stmt_iterator *gsi,
the output overflows the destination object (but leave it enabled
when the function is bounded because then the behavior is well-
defined). */
- if (lhs && res.bounded && res.under4k
+ if (lhs
+ && res.bounded
+ && res.under4k
&& (info.bounded || res.number_chars <= info.objsize)
- && res.number_chars - 1 <= target_int_max ())
+ && res.number_chars - 1 <= target_int_max ()
+ /* Not prepared to handle possibly throwing calls here; they shouldn't
+ appear in non-artificial testcases, except when the __*_chk routines
+ are badly declared. */
+ && !stmt_ends_bb_p (info.callstmt))
{
tree cst = build_int_cst (integer_type_node, res.number_chars - 1);