tree-optimization/104970: Limit size computation for access attribute
commitc1d233e3334df07cfb4f732ace4d93d3cbc28bca
authorSiddhesh Poyarekar <siddhesh@gotplt.org>
Wed, 23 Mar 2022 17:39:02 +0000 (23 23:09 +0530)
committerSiddhesh Poyarekar <siddhesh@gotplt.org>
Thu, 24 Mar 2022 09:34:31 +0000 (24 15:04 +0530)
tree6d2c3aaf2ed389628746e5f07109011c32cbc1ba
parent72124f487ccb5c8065dd5f7b8fba254600b7e611
tree-optimization/104970: Limit size computation for access attribute

Limit object size computation only to the simple case where access
attribute has been explicitly specified.  The object passed to
__builtin_dynamic_object_size could either be a pointer or a VLA whose
size has been described using access attribute.

Further, return a valid size only if the object is a void * pointer or
points to (or is a VLA of) a type that has a constant size.

gcc/ChangeLog:

PR tree-optimization/104970
* tree-object-size.cc (parm_object_size): Restrict size
computation scenarios to explicit access attributes.

gcc/testsuite/ChangeLog:

PR tree-optimization/104970
* gcc.dg/builtin-dynamic-object-size-0.c (test_parmsz_simple2,
test_parmsz_simple3, test_parmsz_extern, test_parmsz_internal,
test_parmsz_internal2, test_parmsz_internal3): New tests.
(main): Use them.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c
gcc/tree-object-size.cc