]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Find overlying with slices
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 25 Nov 2025 10:29:28 +0000 (11:29 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 9 Jan 2026 10:57:12 +0000 (11:57 +0100)
A recent change removed rewriting of address of a slice into address of first
component of a slice. Now we need to explicitly detect overlying with slices.
Together, both changes cause warnings to be emitted when slice of a constant
object is overlaid by a variable.

gcc/ada/ChangeLog:

* sem_util.adb (Find_Overlaid_Entity): Detect overlying with slice.

gcc/ada/sem_util.adb

index 843bfb4a54be231a769d8e34165142b72edda014..ad7c0e647f09b132b5f8159e3cf955f7215f86d5 100644 (file)
@@ -9251,7 +9251,10 @@ package body Sem_Util is
 
          --  Check for components
 
-         elsif Nkind (Expr) in N_Selected_Component | N_Indexed_Component then
+         elsif Nkind (Expr) in N_Indexed_Component
+                             | N_Selected_Component
+                             | N_Slice
+         then
             Expr := Prefix (Expr);
             Off  := True;