aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2017-05-14 16:06:41 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2017-05-14 10:06:41 -0600
commitc6c0251911ac280500d939cdeae87536727e5971 (patch)
treeff47219f310b04fdb7a37f135586d1f14bfd0c82 /gcc/builtins.c
parentd6d4d7701a4c40f4c46904292456b76502e1ae63 (diff)
downloadgcc-c6c0251911ac280500d939cdeae87536727e5971.zip
gcc-c6c0251911ac280500d939cdeae87536727e5971.tar.gz
gcc-c6c0251911ac280500d939cdeae87536727e5971.tar.bz2
PR middle-end/80669 - Bad -Wstringop-overflow warnings for stpncpy
gcc/ChangeLog: PR middle-end/80669 * builtins.c (expand_builtin_stpncpy): Simplify. gcc/testsuite/ChangeLog: PR middle-end/80669 * gcc.dg/builtin-stpncpy.c: New test. From-SVN: r248034
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 936fcee..4f6c9c4 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -3788,31 +3788,18 @@ expand_builtin_stpncpy (tree exp, rtx)
|| !warn_stringop_overflow)
return NULL_RTX;
+ /* The source and destination of the call. */
tree dest = CALL_EXPR_ARG (exp, 0);
tree src = CALL_EXPR_ARG (exp, 1);
- /* The number of bytes to write (not the maximum). */
+ /* The exact number of bytes to write (not the maximum). */
tree len = CALL_EXPR_ARG (exp, 2);
- /* The length of the source sequence. */
- tree slen = c_strlen (src, 1);
-
- /* Try to determine the range of lengths that the source expression
- refers to. */
- tree lenrange[2];
- if (slen)
- lenrange[0] = lenrange[1] = slen;
- else
- {
- get_range_strlen (src, lenrange);
- slen = lenrange[0];
- }
+ /* The size of the destination object. */
tree destsize = compute_objsize (dest, warn_stringop_overflow - 1);
- /* The number of bytes to write is LEN but check_sizes will also
- check SLEN if LEN's value isn't known. */
check_sizes (OPT_Wstringop_overflow_,
- exp, len, /*maxlen=*/NULL_TREE, slen, destsize);
+ exp, len, /*maxlen=*/NULL_TREE, src, destsize);
return NULL_RTX;
}