diff mbox series

[Ada] Fix detection of slices that denote the same object

Message ID 20210617143311.GA9911@adacore.com
State New
Headers show
Series [Ada] Fix detection of slices that denote the same object | expand

Commit Message

Pierre-Marie de Rodat June 17, 2021, 2:33 p.m. UTC
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 mbox series

Patch

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.