]> git.ipfire.org Git - thirdparty/gcc.git/commit
pointer-query: Fix ICE with non-pointer param [PR105635]
authorJakub Jelinek <jakub@redhat.com>
Thu, 19 May 2022 09:56:21 +0000 (11:56 +0200)
committerJakub Jelinek <jakub@redhat.com>
Mon, 30 May 2022 03:36:31 +0000 (05:36 +0200)
commit7b88f9b8881b7653b5a834da1b2b8fda463e61c0
tree939e1ed878e03486e15dcd7bf2b45d9b7dffc0f7
parent864dcf71c87a6afdc534073ee53aea684f7bb985
pointer-query: Fix ICE with non-pointer param [PR105635]

The gimple_parm_array_size function comment talks about pointe parameters
but doesn't actually verify it, it checks whether an attribute is present
on the function and then just uses TREE_TYPE (TREE_TYPE (var)) which
assumes a pointer type (or in theory could work for ARRAY_TYPE but
c-family languages which only have that attribute will never have ARRAY_TYPE
parameters; and for VECTOR_TYPE/COMPLEX_TYPE it would mean something quite
different).

So, this patch punts early if var doesn't have pointer/reference type.

2022-05-19  Jakub Jelinek  <jakub@redhat.com>

PR c/105635
* pointer-query.cc (gimple_parm_array_size): Return NULL if var
doesn't have pointer or reference type.

* gcc.dg/pr105635.c: New test.

(cherry picked from commit 3b4daa0b3c3d8eb2ac3b40ad6898f314ed4d7919)
gcc/pointer-query.cc
gcc/testsuite/gcc.dg/pr105635.c [new file with mode: 0644]