From 0f1bc0d5c0b7b77f3ec0704f9f999cceef13adea Mon Sep 17 00:00:00 2001 From: Eric Botcazou <ebotcazou@adacore.com> Date: Fri, 20 Dec 2024 16:49:50 +0100 Subject: [PATCH] ada: Do not raise exceptions from Exp_Aggr.Packed_Array_Aggregate_Handled An exception is now raised during bootstrap and this causes compatibility issues with older compilers. gcc/ada/ChangeLog: * exp_aggr.adb (Packed_Array_Aggregate_Handled): Remove declaration and handler for Not_Handled local exception. Check the return value of Get_Component_Val instead. (Get_Component_Val): Return No_Uint instead of raising Not_Handled. --- gcc/ada/exp_aggr.adb | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 428115f81ba6..378168fe40b9 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -8962,9 +8962,6 @@ package body Exp_Aggr is Typ : constant Entity_Id := Etype (N); Ctyp : constant Entity_Id := Component_Type (Typ); - Not_Handled : exception; - -- Exception raised if this aggregate cannot be handled - begin -- Handle one- or two dimensional bit packed array @@ -8997,7 +8994,7 @@ package body Exp_Aggr is -- Given a expression value N of the component type Ctyp, returns a -- value of Csiz (component size) bits representing this value. If -- the value is nonstatic or any other reason exists why the value - -- cannot be returned, then Not_Handled is raised. + -- cannot be returned, then No_Uint is returned. ----------------------- -- Get_Component_Val -- @@ -9020,7 +9017,7 @@ package body Exp_Aggr is if not Compile_Time_Known_Value (N) or else Nkind (N) = N_String_Literal then - raise Not_Handled; + return No_Uint; end if; Val := Expr_Rep_Value (N); @@ -9098,6 +9095,9 @@ package body Exp_Aggr is -- justified modular type processing), so we do not have to -- worry about that here. + Val : Uint; + -- Temporary value + Lit : Node_Id; -- Integer literal for resulting constructed value @@ -9146,16 +9146,23 @@ package body Exp_Aggr is if Len = 0 then Aggregate_Val := Uint_0; + else Expr := First (Expressions (N)); - Aggregate_Val := Get_Component_Val (Expr) * Uint_2 ** Shift; + Val := Get_Component_Val (Expr); + if No (Val) then + return False; + end if; + Aggregate_Val := Val * Uint_2 ** Shift; for J in 2 .. Len loop Shift := Shift + Incr; Next (Expr); - Aggregate_Val := - Aggregate_Val + - Get_Component_Val (Expr) * Uint_2 ** Shift; + Val := Get_Component_Val (Expr); + if No (Val) then + return False; + end if; + Aggregate_Val := Aggregate_Val + Val * Uint_2 ** Shift; end loop; end if; @@ -9182,10 +9189,6 @@ package body Exp_Aggr is end; end; end; - - exception - when Not_Handled => - return False; end Packed_Array_Aggregate_Handled; ---------------------------- -- GitLab