aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2018-05-30 22:24:43 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2018-05-30 16:24:43 -0600
commit3ce4cdb2f7ea5dfe464e2d5ddfe6b29c7411b104 (patch)
tree2e32fd6836340af4986b31910a2a79d18e676a48 /gcc/builtins.c
parent1ba9c854bb7031d8fd7e135ad89a49f7861edb81 (diff)
downloadgcc-3ce4cdb2f7ea5dfe464e2d5ddfe6b29c7411b104.zip
gcc-3ce4cdb2f7ea5dfe464e2d5ddfe6b29c7411b104.tar.gz
gcc-3ce4cdb2f7ea5dfe464e2d5ddfe6b29c7411b104.tar.bz2
PR middle-end/85369 - no -Wstringop-overflow for a strcpy / stpcpy call with a nonstring pointer when providing movstr pattern
gcc/ChangeLog: PR middle-end/85369 * builtins.c (expand_builtin_stpcpy_1): New function. (expand_builtin_stpcpy): Call it, and call maybe_warn_nonstring_arg only if the former succeeds. From-SVN: r260976
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 841c1ef..9741939 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -3814,7 +3814,7 @@ expand_builtin_strcpy_args (tree dest, tree src, rtx target)
mode MODE if that's convenient). */
static rtx
-expand_builtin_stpcpy (tree exp, rtx target, machine_mode mode)
+expand_builtin_stpcpy_1 (tree exp, rtx target, machine_mode mode)
{
tree dst, src;
location_t loc = EXPR_LOCATION (exp);
@@ -3891,6 +3891,25 @@ expand_builtin_stpcpy (tree exp, rtx target, machine_mode mode)
}
}
+/* Expand a call EXP to the stpcpy builtin and diagnose uses of nonstring
+ arguments while being careful to avoid duplicate warnings (which could
+ be issued if the expander were to expand the call, resulting in it
+ being emitted in expand_call(). */
+
+static rtx
+expand_builtin_stpcpy (tree exp, rtx target, machine_mode mode)
+{
+ if (rtx ret = expand_builtin_stpcpy_1 (exp, target, mode))
+ {
+ /* The call has been successfully expanded. Check for nonstring
+ arguments and issue warnings as appropriate. */
+ maybe_warn_nonstring_arg (get_callee_fndecl (exp), exp);
+ return ret;
+ }
+
+ return NULL_RTX;
+}
+
/* Check a call EXP to the stpncpy built-in for validity.
Return NULL_RTX on both success and failure. */