waccess: Fix up pass_waccess::check_alloc_size_call [PR102009]
authorJakub Jelinek <jakub@redhat.com>
Tue, 16 Nov 2021 09:18:25 +0000 (10:18 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 16 Nov 2021 09:18:25 +0000 (10:18 +0100)
commiteacdfaf7ca07367ede1a0c50aa997953958dabae
treeddb70ff6527184ae6dcc08258433b1f05d7cd08d
parent473b5e87346edf9885abc28b7de68e3cd7059746
waccess: Fix up pass_waccess::check_alloc_size_call [PR102009]

This function punts if the builtins have no arguments, but as can be seen
on the testcase, even if it has some arguments but alloc_size attribute's
arguments point to arguments that aren't passed, we get a warning earlier
from the FE but should punt rather than ICE on it.
Other users of alloc_size attribute e.g. in
tree-object-size.c (alloc_object_size) punt similarly and similarly
even in the same TU maybe_warn_nonstring_arg correctly verifies calls have
enough arguments.

2021-11-16  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/102009
* gimple-ssa-warn-access.cc (pass_waccess::check_alloc_size_call):
Punt if any of alloc_size arguments is out of bounds vs. number of
call arguments.

* gcc.dg/pr102009.c: New test.
gcc/gimple-ssa-warn-access.cc
gcc/testsuite/gcc.dg/pr102009.c [new file with mode: 0644]