public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] ada: Fix minor address arithmetic issues in System.Dwarf_Lines
@ 2023-05-23  8:08 Marc Poulhiès
  0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-05-23  8:08 UTC (permalink / raw)
  To: gcc-patches; +Cc: Eric Botcazou

From: Eric Botcazou <ebotcazou@adacore.com>

Offset calculations should use the operator of System.Storage_Elements.

gcc/ada/

	* libgnat/s-dwalin.adb (Enable_Cache): Use the subtract operator of
	System.Storage_Elements to compute the offset.
	(Symbolic_Address): Likewise.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/libgnat/s-dwalin.adb | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/ada/libgnat/s-dwalin.adb b/gcc/ada/libgnat/s-dwalin.adb
index d38bc058e3b..d35d03a8a2f 100644
--- a/gcc/ada/libgnat/s-dwalin.adb
+++ b/gcc/ada/libgnat/s-dwalin.adb
@@ -1542,7 +1542,7 @@ package body System.Dwarf_Lines is
                exit when Ar_Start = Null_Address and Ar_Len = 0;
 
                Len   := uint32 (Ar_Len);
-               Start := uint32 (Address'(Ar_Start - C.Low));
+               Start := uint32 (Storage_Count'(Ar_Start - C.Low));
 
                --  Search START in the array
 
@@ -1762,7 +1762,7 @@ package body System.Dwarf_Lines is
 
       if C.Cache /= null then
          declare
-            Addr_Off : constant uint32 := uint32 (Address'(Addr - C.Low));
+            Off : constant uint32 := uint32 (Storage_Count'(Addr - C.Low));
 
             First, Last, Mid : Natural;
          begin
@@ -1772,17 +1772,17 @@ package body System.Dwarf_Lines is
 
             while First <= Last loop
                Mid := First + (Last - First) / 2;
-               if Addr_Off < C.Cache (Mid).First then
+               if Off < C.Cache (Mid).First then
                   Last := Mid - 1;
-               elsif Addr_Off >= C.Cache (Mid).First + C.Cache (Mid).Size then
+               elsif Off >= C.Cache (Mid).First + C.Cache (Mid).Size then
                   First := Mid + 1;
                else
                   exit;
                end if;
             end loop;
 
-            if Addr_Off >= C.Cache (Mid).First
-              and then Addr_Off < C.Cache (Mid).First + C.Cache (Mid).Size
+            if Off >= C.Cache (Mid).First
+              and then Off < C.Cache (Mid).First + C.Cache (Mid).Size
             then
                Line_Offset := Offset (C.Cache (Mid).Line);
                S := Read_Symbol (C.Obj.all, Offset (C.Cache (Mid).Sym));
-- 
2.40.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-23  8:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-23  8:08 [COMMITTED] ada: Fix minor address arithmetic issues in System.Dwarf_Lines Marc Poulhiès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).