aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2022-11-21 19:08:17 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2022-11-21 19:08:17 -0500
commit12a4785c9120beeef42f1bded52cc2674e206f57 (patch)
tree63a0b25cca584a6ec2f52c116b0eb385db0551e2
parent358dab90186b30a5d287710f13625c327210218d (diff)
downloadgcc-12a4785c9120beeef42f1bded52cc2674e206f57.zip
gcc-12a4785c9120beeef42f1bded52cc2674e206f57.tar.gz
gcc-12a4785c9120beeef42f1bded52cc2674e206f57.tar.bz2
analyzer: fix ICE on 'bind' with non-pointer arg [P107783]
gcc/analyzer/ChangeLog: PR analyzer/107783 * region-model-impl-calls.cc (kf_accept::matches_call_types_p): Require that args 1 and 2 be pointers. (kf_bind::matches_call_types_p): Require that arg 1 be a pointer. * region-model.h (call_details::arg_is_pointer_p): New gcc/testsuite/ChangeLog: PR analyzer/107783 * gcc.dg/analyzer/fd-bind-pr107783.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
-rw-r--r--gcc/analyzer/region-model-impl-calls.cc6
-rw-r--r--gcc/analyzer/region-model.h4
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/fd-bind-pr107783.c5
3 files changed, 13 insertions, 2 deletions
diff --git a/gcc/analyzer/region-model-impl-calls.cc b/gcc/analyzer/region-model-impl-calls.cc
index a71eb3d..8a44c97 100644
--- a/gcc/analyzer/region-model-impl-calls.cc
+++ b/gcc/analyzer/region-model-impl-calls.cc
@@ -595,7 +595,9 @@ class kf_accept : public known_function
bool matches_call_types_p (const call_details &cd) const final override
{
- return cd.num_args () == 3;
+ return (cd.num_args () == 3
+ && cd.arg_is_pointer_p (1)
+ && cd.arg_is_pointer_p (2));
}
void impl_call_post (const call_details &cd) const final override
@@ -633,7 +635,7 @@ public:
bool matches_call_types_p (const call_details &cd) const final override
{
- return cd.num_args () == 3;
+ return (cd.num_args () == 3 && cd.arg_is_pointer_p (1));
}
void impl_call_post (const call_details &cd) const final override
diff --git a/gcc/analyzer/region-model.h b/gcc/analyzer/region-model.h
index c828d73..244780e 100644
--- a/gcc/analyzer/region-model.h
+++ b/gcc/analyzer/region-model.h
@@ -256,6 +256,10 @@ public:
bool maybe_set_lhs (const svalue *result) const;
unsigned num_args () const;
+ bool arg_is_pointer_p (unsigned idx) const
+ {
+ return POINTER_TYPE_P (get_arg_type (idx));
+ }
const gcall *get_call_stmt () const { return m_call; }
location_t get_location () const;
diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-bind-pr107783.c b/gcc/testsuite/gcc.dg/analyzer/fd-bind-pr107783.c
new file mode 100644
index 0000000..3630417
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/fd-bind-pr107783.c
@@ -0,0 +1,5 @@
+int
+foo (void)
+{
+ return bind (0, 0, 0); /* { dg-warning "implicit declaration of function 'bind'" } */
+}