[Ada] Fix detection of slices that denote the same object
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 9 Mar 2021 21:22:19 +0000 (22:22 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 17 Jun 2021 14:32:13 +0000 (10:32 -0400)
gcc/ada/

* sem_util.adb (Denotes_Same_Object): Call Get_Index_Bounds with
the range of a slice object, not its type.

gcc/ada/sem_util.adb

index 6481d86..c9d97a9 100644 (file)
@@ -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.