To detect overlapping slices acting as actual parameters we rely on the
Get_Index_Bounds routine. We were calling it with a type entity, while
its description says that it parameter "must be a range, subtype
indication, or the name of a scalar subtype."

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

        * sem_util.adb (Denotes_Same_Object): Call Get_Index_Bounds with
        the range of a slice object, not its type.
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -7482,8 +7482,8 @@ package body Sem_Util is
             Lo1, Lo2, Hi1, Hi2 : Node_Id;
 
          begin
-            Get_Index_Bounds (Etype (Obj1), Lo1, Hi1);
-            Get_Index_Bounds (Etype (Obj2), Lo2, Hi2);
+            Get_Index_Bounds (Discrete_Range (Obj1), Lo1, Hi1);
+            Get_Index_Bounds (Discrete_Range (Obj2), Lo2, Hi2);
 
             --  Check whether bounds are statically identical. There is no
             --  attempt to detect partial overlap of slices.


Reply via email to