diff mbox series

[COMMITTED,5/6] ada: Etype missing for raise expression

Message ID 20240808142948.807190-5-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,1/6] ada: Finalization_Size raises Constraint_Error | expand

Commit Message

Marc Poulhiès Aug. 8, 2024, 2:29 p.m. UTC
From: Steve Baird <baird@adacore.com>

If the primitive equality operator of the component type of an array type is
abstract, then a call to that abstract function raises Program_Error (when
such a call is legal). The FE generates a raise expression to implement this.
That raise expression is an expression so it should have a valid Etype.

gcc/ada/

	* exp_ch4.adb (Build_Eq_Call): In the abstract callee case, copy
	the Etype of the callee onto the Make_Raise_Program_Error result.

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

---
 gcc/ada/exp_ch4.adb | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 18ec7125cc1..106305f4636 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -443,8 +443,11 @@  package body Exp_Ch4 is
    begin
       if Present (Eq) then
          if Is_Abstract_Subprogram (Eq) then
-            return Make_Raise_Program_Error (Loc,
-               Reason =>  PE_Explicit_Raise);
+            return Result : constant Node_Id :=
+              Make_Raise_Program_Error (Loc, Reason =>  PE_Explicit_Raise)
+            do
+               Set_Etype (Result, Etype (Eq));
+            end return;
 
          else
             return