From: Richard Biener Date: Wed, 6 Apr 2022 08:40:06 +0000 (+0200) Subject: ipa/105166 - avoid modref queries with mismatching types X-Git-Tag: upstream/12.2.0~678 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4be08315124281f4e9359bc7e5279a99bdbdd053;p=platform%2Fupstream%2Fgcc.git ipa/105166 - avoid modref queries with mismatching types We should avoid mismatched argument values (integers for pointers) when doing modref queries. This is the third place to guard. 2022-04-06 Richard Biener PR ipa/105166 * ipa-modref-tree.cc (modref_access_node::get_ao_ref ): Bail out for non-pointer arguments. * gcc.dg/torture/pr105166.c: New testcase. --- diff --git a/gcc/ipa-modref-tree.cc b/gcc/ipa-modref-tree.cc index d0ec2fb..f19af8c 100644 --- a/gcc/ipa-modref-tree.cc +++ b/gcc/ipa-modref-tree.cc @@ -678,7 +678,9 @@ modref_access_node::get_ao_ref (const gcall *stmt, ao_ref *ref) const { tree arg; - if (!parm_offset_known || !(arg = get_call_arg (stmt))) + if (!parm_offset_known + || !(arg = get_call_arg (stmt)) + || !POINTER_TYPE_P (TREE_TYPE (arg))) return false; poly_offset_int off = (poly_offset_int)offset + ((poly_offset_int)parm_offset << LOG2_BITS_PER_UNIT); diff --git a/gcc/testsuite/gcc.dg/torture/pr105166.c b/gcc/testsuite/gcc.dg/torture/pr105166.c new file mode 100644 index 0000000..60e8b73 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr105166.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +int bar (foo, a) + int (**foo) (); + int a; +{ + (foo)[1] = bar; + foo[1] (1); +}