aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-fold.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2017-05-14 17:50:28 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2017-05-14 11:50:28 -0600
commita104bd88592d85d4117f7beb9a886099263b70b1 (patch)
tree50e03b802f151fb4d37e1777a2b4b1d2a036f87e /gcc/gimple-fold.c
parentc6c0251911ac280500d939cdeae87536727e5971 (diff)
downloadgcc-a104bd88592d85d4117f7beb9a886099263b70b1.zip
gcc-a104bd88592d85d4117f7beb9a886099263b70b1.tar.gz
gcc-a104bd88592d85d4117f7beb9a886099263b70b1.tar.bz2
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
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r--gcc/gimple-fold.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index aca842b..921e120 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -2670,11 +2670,9 @@ gimple_fold_builtin_sprintf_chk (gimple_stmt_iterator *gsi,
ORIG may be null if this is a 2-argument call. We don't attempt to
simplify calls with more than 3 arguments.
- Return NULL_TREE if no simplification was possible, otherwise return the
- simplified form of the call as a tree. If IGNORED is true, it means that
- the caller does not use the returned value of the function. */
+ Return true if simplification was possible, otherwise false. */
-static bool
+bool
gimple_fold_builtin_sprintf (gimple_stmt_iterator *gsi)
{
gimple *stmt = gsi_stmt (*gsi);
@@ -2795,11 +2793,9 @@ gimple_fold_builtin_sprintf (gimple_stmt_iterator *gsi)
FMT, and ORIG. ORIG may be null if this is a 3-argument call. We don't
attempt to simplify calls with more than 4 arguments.
- Return NULL_TREE if no simplification was possible, otherwise return the
- simplified form of the call as a tree. If IGNORED is true, it means that
- the caller does not use the returned value of the function. */
+ Return true if simplification was possible, otherwise false. */
-static bool
+bool
gimple_fold_builtin_snprintf (gimple_stmt_iterator *gsi)
{
gcall *stmt = as_a <gcall *> (gsi_stmt (*gsi));
@@ -3384,10 +3380,7 @@ gimple_fold_builtin (gimple_stmt_iterator *gsi)
case BUILT_IN_SNPRINTF_CHK:
case BUILT_IN_VSNPRINTF_CHK:
return gimple_fold_builtin_snprintf_chk (gsi, fcode);
- case BUILT_IN_SNPRINTF:
- return gimple_fold_builtin_snprintf (gsi);
- case BUILT_IN_SPRINTF:
- return gimple_fold_builtin_sprintf (gsi);
+
case BUILT_IN_FPRINTF:
case BUILT_IN_FPRINTF_UNLOCKED:
case BUILT_IN_VFPRINTF: