tree-optimization/105726 - adjust array bound heuristic
authorRichard Biener <rguenther@suse.de>
Wed, 25 May 2022 09:49:03 +0000 (11:49 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 27 May 2022 09:42:31 +0000 (11:42 +0200)
commite7c482b08076bb299742883c4ffd65b31e33200c
tree976b5fa154ef456031e361eb4f0645d9c4050da9
parente2f014fcefcd2ad56b31995329820bbd99072eae
tree-optimization/105726 - adjust array bound heuristic

There's heuristic to detect ptr[1].a[...] out of bound accesses
reasoning that if ptr points to an array of aggregates a trailing
incomplete array has to have size zero.  The following more
thoroughly constrains the cases this applies to avoid false
positive diagnostics.

2022-05-25  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105726
* gimple-ssa-warn-restrict.cc (builtin_memref::set_base_and_offset):
Constrain array-of-flexarray case more.

* g++.dg/warn/Warray-bounds-27.C: New testcase.
gcc/gimple-ssa-warn-restrict.cc
gcc/testsuite/g++.dg/warn/Warray-bounds-27.C [new file with mode: 0644]