middle-end/106457 - improve array_at_struct_end_p for array objects

Message ID 20220728123553.7CEED385AE68@sourceware.org
State Committed
Commit ff26f0ba68fe6e870f315d0601b596f889b89680
Headers
Series middle-end/106457 - improve array_at_struct_end_p for array objects |

Commit Message

Richard Biener July 28, 2022, 12:35 p.m. UTC
  Array references to array objects are never at struct end.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	PR middle-end/106457
	* tree.cc (array_at_struct_end_p): Handle array objects
	specially.
---
 gcc/tree.cc | 4 ++++
 1 file changed, 4 insertions(+)
  

Patch

diff --git a/gcc/tree.cc b/gcc/tree.cc
index 84000dd8b69..fed1434d141 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -12778,6 +12778,10 @@  array_at_struct_end_p (tree ref)
       && DECL_SIZE_UNIT (ref)
       && TREE_CODE (DECL_SIZE_UNIT (ref)) == INTEGER_CST)
     {
+      /* If the object itself is the array it is not at struct end.  */
+      if (DECL_P (ref_to_array))
+	return false;
+
       /* Check whether the array domain covers all of the available
          padding.  */
       poly_int64 offset;