Replace an access type parameter, which is unusual in the GNAT sources
and more difficult to understand, with a parameter of mode out. Code
cleanup only; behaviour is unaffected.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_eval.ads (Compile_Time_Compare): Change parameter Diff
from access to mode out.
* sem_eval.adb (Compile_Time_Compare): Adapt body and callers.
* sem_attr.adb (Eval_Attribute): Adapt callers.
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -9138,12 +9138,12 @@ package body Sem_Attr is
-- comparable, and we can figure out the difference between them.
declare
- Diff : aliased Uint;
+ Diff : Uint;
begin
case
Compile_Time_Compare
- (Lo_Bound, Hi_Bound, Diff'Access, Assume_Valid => False)
+ (Lo_Bound, Hi_Bound, Diff, Assume_Valid => False)
is
when EQ =>
Fold_Uint (N, Uint_1, Static);
@@ -9631,7 +9631,7 @@ package body Sem_Attr is
------------------
when Attribute_Range_Length => Range_Length : declare
- Diff : aliased Uint;
+ Diff : Uint;
begin
Set_Bounds;
@@ -9651,7 +9651,7 @@ package body Sem_Attr is
-- comparable, and we can figure out the difference between them.
case Compile_Time_Compare
- (Lo_Bound, Hi_Bound, Diff'Access, Assume_Valid => False)
+ (Lo_Bound, Hi_Bound, Diff, Assume_Valid => False)
is
when EQ =>
Fold_Uint (N, Uint_1, Static);
diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb
--- a/gcc/ada/sem_eval.adb
+++ b/gcc/ada/sem_eval.adb
@@ -864,21 +864,21 @@ package body Sem_Eval is
(L, R : Node_Id;
Assume_Valid : Boolean) return Compare_Result
is
- Discard : aliased Uint;
+ Discard : Uint;
begin
- return Compile_Time_Compare (L, R, Discard'Access, Assume_Valid);
+ return Compile_Time_Compare (L, R, Discard, Assume_Valid);
end Compile_Time_Compare;
function Compile_Time_Compare
(L, R : Node_Id;
- Diff : access Uint;
+ Diff : out Uint;
Assume_Valid : Boolean;
Rec : Boolean := False) return Compare_Result
is
Ltyp : Entity_Id := Etype (L);
Rtyp : Entity_Id := Etype (R);
- Discard : aliased Uint;
+ Discard : Uint;
procedure Compare_Decompose
(N : Node_Id;
@@ -1197,7 +1197,7 @@ package body Sem_Eval is
-- Start of processing for Compile_Time_Compare
begin
- Diff.all := No_Uint;
+ Diff := No_Uint;
-- In preanalysis mode, always return Unknown unless the expression
-- is static. It is too early to be thinking we know the result of a
@@ -1354,12 +1354,12 @@ package body Sem_Eval is
Hi : constant Uint := Expr_Value (R);
begin
if Lo < Hi then
- Diff.all := Hi - Lo;
+ Diff := Hi - Lo;
return LT;
elsif Lo = Hi then
return EQ;
else
- Diff.all := Lo - Hi;
+ Diff := Lo - Hi;
return GT;
end if;
end;
@@ -1463,10 +1463,10 @@ package body Sem_Eval is
and then not Is_Modular_Integer_Type (Rtyp)
then
if Loffs < Roffs then
- Diff.all := Roffs - Loffs;
+ Diff := Roffs - Loffs;
return LT;
else
- Diff.all := Loffs - Roffs;
+ Diff := Loffs - Roffs;
return GT;
end if;
end if;
@@ -1492,14 +1492,14 @@ package body Sem_Eval is
if LHi < RLo then
if Single and Assume_Valid then
- Diff.all := RLo - LLo;
+ Diff := RLo - LLo;
end if;
return LT;
elsif RHi < LLo then
if Single and Assume_Valid then
- Diff.all := LLo - RLo;
+ Diff := LLo - RLo;
end if;
return GT;
@@ -1562,7 +1562,7 @@ package body Sem_Eval is
if not Is_Generic_Type (Rtyp) then
case Compile_Time_Compare (L, Type_Low_Bound (Rtyp),
- Discard'Access,
+ Discard,
Assume_Valid, Rec => True)
is
when LT => return LT;
@@ -1572,7 +1572,7 @@ package body Sem_Eval is
end case;
case Compile_Time_Compare (L, Type_High_Bound (Rtyp),
- Discard'Access,
+ Discard,
Assume_Valid, Rec => True)
is
when GT => return GT;
@@ -1584,7 +1584,7 @@ package body Sem_Eval is
if not Is_Generic_Type (Ltyp) then
case Compile_Time_Compare (Type_Low_Bound (Ltyp), R,
- Discard'Access,
+ Discard,
Assume_Valid, Rec => True)
is
when GT => return GT;
@@ -1594,7 +1594,7 @@ package body Sem_Eval is
end case;
case Compile_Time_Compare (Type_High_Bound (Ltyp), R,
- Discard'Access,
+ Discard,
Assume_Valid, Rec => True)
is
when LT => return LT;
diff --git a/gcc/ada/sem_eval.ads b/gcc/ada/sem_eval.ads
--- a/gcc/ada/sem_eval.ads
+++ b/gcc/ada/sem_eval.ads
@@ -194,16 +194,16 @@ package Sem_Eval is
function Compile_Time_Compare
(L, R : Node_Id;
- Diff : access Uint;
+ Diff : out Uint;
Assume_Valid : Boolean;
Rec : Boolean := False) return Compare_Result;
-- This version of Compile_Time_Compare returns extra information if the
-- result is GT or LT. In these cases, if the magnitude of the difference
-- can be determined at compile time, this (positive) magnitude is returned
- -- in Diff.all. If the magnitude of the difference cannot be determined
- -- then Diff.all contains No_Uint on return. Rec is a parameter that is set
- -- True for a recursive call from within Compile_Time_Compare to avoid some
- -- infinite recursion cases. It should never be set by a client.
+ -- in Diff. If the magnitude of the difference cannot be determined then
+ -- Diff contains No_Uint on return. Rec is a parameter that is set True for
+ -- a recursive call from within Compile_Time_Compare to avoid some infinite
+ -- recursion cases. It should never be set by a client.
function Compile_Time_Known_Bounds (T : Entity_Id) return Boolean;
-- If T is an array whose index bounds are all known at compile time, then