From a104bd88592d85d4117f7beb9a886099263b70b1 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Sun, 14 May 2017 17:50:28 +0000 Subject: 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/gimple-fold.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'gcc/gimple-fold.c') 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 (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: -- cgit v1.1