From cf3fc0e8ac5a9b65bb213f979a4030e43243a5fc Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Wed, 3 Jan 2018 23:41:32 +0000 Subject: 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 --- gcc/gimple-ssa-warn-restrict.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'gcc/gimple-ssa-warn-restrict.c') diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c index 97d2af7..066be1a 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. */ -- cgit v1.1