aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2020-10-14 15:19:39 -0600
committerMartin Sebor <msebor@redhat.com>2020-10-14 15:36:24 -0600
commit14d83c6f584c321989b43526dc9437de4381aa47 (patch)
tree51e8512a715afcef812ff500efd1bac8d7c0b808 /gcc/builtins.c
parent34efa5c2a84a8c7c7beb855dec24a321eebcbd6b (diff)
downloadgcc-14d83c6f584c321989b43526dc9437de4381aa47.zip
gcc-14d83c6f584c321989b43526dc9437de4381aa47.tar.gz
gcc-14d83c6f584c321989b43526dc9437de4381aa47.tar.bz2
PR middle-end/97391 - bogus -Warray-bounds accessing a multidimensional array parameter
gcc/ChangeLog: PR middle-end/97391 * builtins.c (gimple_parm_array_size): Peel off one less layer of array types. gcc/testsuite/ChangeLog: PR middle-end/97391 * gcc.dg/Warray-bounds-68.c: New test.
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 3f799e5..72627b5 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -4493,12 +4493,9 @@ gimple_parm_array_size (tree ptr, wide_int rng[2],
rng[0] = wi::zero (prec);
rng[1] = wi::uhwi (access->minsize, prec);
- /* If the PTR argument points to an array multiply MINSIZE by the size
- of array element type. Otherwise, multiply it by the size of what
- the pointer points to. */
+ /* Multiply the array bound encoded in the attribute by the size
+ of what the pointer argument to which it decays points to. */
tree eltype = TREE_TYPE (TREE_TYPE (ptr));
- if (TREE_CODE (eltype) == ARRAY_TYPE)
- eltype = TREE_TYPE (eltype);
tree size = TYPE_SIZE_UNIT (eltype);
if (!size || TREE_CODE (size) != INTEGER_CST)
return NULL_TREE;