summaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-warn-restrict.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2018-01-03 23:41:32 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2018-01-03 16:41:32 -0700
commitcf3fc0e8ac5a9b65bb213f979a4030e43243a5fc (patch)
tree1798e91130802e29c9e570a63e5f6dc7d6080c69 /gcc/gimple-ssa-warn-restrict.c
parent2438cb6a1dd5f983314b21988b915699c01a2e28 (diff)
PR tree-optimization/83655 - ICE on an invalid call to memcpy declared with no prototype
gcc/testsuite/ChangeLog: PR tree-optimization/83655 * gcc.dg/Wrestrict-5.c: New test. * c-c++-common/builtins.c: New test. gcc/ChangeLog: PR tree-optimization/83655 * gimple-ssa-warn-restrict.c (wrestrict_dom_walker::check_call): Avoid checking calls with invalid arguments. From-SVN: r256218
Diffstat (limited to 'gcc/gimple-ssa-warn-restrict.c')
-rw-r--r--gcc/gimple-ssa-warn-restrict.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c
index 97d2af75531..066be1a0438 100644
--- a/gcc/gimple-ssa-warn-restrict.c
+++ b/gcc/gimple-ssa-warn-restrict.c
@@ -1693,7 +1693,18 @@ wrestrict_dom_walker::check_call (gcall *call)
/* DST and SRC can be null for a call with an insufficient number
of arguments to a built-in function declared without a protype. */
- if (!dst || !src || check_bounds_or_overlap (call, dst, src, dstwr, NULL_TREE))
+ if (!dst || !src)
+ return;
+
+ /* DST, SRC, or DSTWR can also have the wrong type in a call to
+ a function declared without a prototype. Avoid checking such
+ invalid calls. */
+ if (TREE_CODE (TREE_TYPE (dst)) != POINTER_TYPE
+ || TREE_CODE (TREE_TYPE (src)) != POINTER_TYPE
+ || (dstwr && !INTEGRAL_TYPE_P (TREE_TYPE (dstwr))))
+ return;
+
+ if (check_bounds_or_overlap (call, dst, src, dstwr, NULL_TREE))
return;
/* Avoid diagnosing the call again. */