aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-warn-restrict.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2019-04-04 21:59:49 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2019-04-04 15:59:49 -0600
commit9a0cbb60d28042893135cee60ad28a48a7e2235d (patch)
tree5ad4a9c490283deb44de2794ef29ca75d5fe31db /gcc/gimple-ssa-warn-restrict.c
parentc2457887ea0c4796b43625149a8d083266efba86 (diff)
downloadgcc-9a0cbb60d28042893135cee60ad28a48a7e2235d.zip
gcc-9a0cbb60d28042893135cee60ad28a48a7e2235d.tar.gz
gcc-9a0cbb60d28042893135cee60ad28a48a7e2235d.tar.bz2
PR middle-end/89934 - ICE on a call with fewer arguments to strncpy declared without prototype
gcc/ChangeLog: PR middle-end/89934 * gimple-ssa-warn-restrict.c (builtin_access::builtin_access): Bail out if the number of arguments is less than expected. gcc/testsuite/ChangeLog: PR middle-end/89934 * gcc.dg/Wrestrict-19.c: New test. * gcc.dg/Wrestrict-5.c: Add comment. Remove unused code. From-SVN: r270152
Diffstat (limited to 'gcc/gimple-ssa-warn-restrict.c')
-rw-r--r--gcc/gimple-ssa-warn-restrict.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c
index 4ebe99f..0c571ef 100644
--- a/gcc/gimple-ssa-warn-restrict.c
+++ b/gcc/gimple-ssa-warn-restrict.c
@@ -730,6 +730,10 @@ builtin_access::builtin_access (gimple *call, builtin_memref &dst,
offset_int bounds[2] = { maxobjsize, maxobjsize };
if (dstref->strbounded_p)
{
+ unsigned nargs = gimple_call_num_args (call);
+ if (nargs <= sizeargno)
+ return;
+
tree size = gimple_call_arg (call, sizeargno);
tree range[2];
if (get_size_range (size, range, true))