PR middle-end/77671 - missing -Wformat-overflow warning on sprintf overflow with %s
authorMartin Sebor <msebor@redhat.com>
Sun, 14 May 2017 17:50:28 +0000 (17:50 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Sun, 14 May 2017 17:50:28 +0000 (11:50 -0600)
commita104bd88592d85d4117f7beb9a886099263b70b1
tree50e03b802f151fb4d37e1777a2b4b1d2a036f87e
parentc6c0251911ac280500d939cdeae87536727e5971
PR middle-end/77671 - missing -Wformat-overflow warning on sprintf overflow with %s

gcc/ChangeLog:

PR middle-end/77671
* gimple-fold.c (gimple_fold_builtin_sprintf): Make extern.
(gimple_fold_builtin_snprintf): Same.
* gimple-fold.h (gimple_fold_builtin_sprintf): Declare.
(gimple_fold_builtin_snprintf): Same.
* gimple-ssa-sprintf.c (get_format_string): Correct the detection
of character types.
(is_call_safe): New function.
(try_substitute_return_value): Call it.
(try_simplify_call): New function.
(pass_sprintf_length::handle_gimple_call): Call it.

gcc/testsuite/ChangeLog:

PR middle-end/77671
* gcc.dg/tree-ssa/builtin-sprintf-7.c: New test.
* gcc.dg/tree-ssa/builtin-sprintf-8.c: New test.
* gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Adjust.
* gcc.dg/tree-ssa/builtin-sprintf-warn-2.c: Adjust.
* gcc.dg/tree-ssa/builtin-sprintf-warn-3.c: Adjust.

From-SVN: r248035
gcc/ChangeLog
gcc/gimple-fold.c
gcc/gimple-fold.h
gcc/gimple-ssa-sprintf.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-7.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-8.c [new file with mode: 0644]
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