https://gcc.gnu.org/g:d64bfa3a7484b42b28fd5d02f45c65b7cc86b86f

commit r15-10309-gd64bfa3a7484b42b28fd5d02f45c65b7cc86b86f
Author: Gary Dismukes <dismu...@adacore.com>
Date:   Fri Jul 25 20:56:32 2025 +0000

    ada: Compiler crash on container aggregate with constant element choice
    
    The compiler fails when compiling a container aggregate with
    an element association with a key choice that denotes a constant
    object.  The code for getting the value of the choice was only
    accounting for the possibility of integer and enumeration literals,
    and is corrected to handle static expressions generally.
    
    gcc/ada/ChangeLog:
    
            * exp_aggr.adb (Build_Container_Aggr_Code.To_Int): Replace existing
            conditional expression with call to Expr_Value.

Diff:
---
 gcc/ada/exp_aggr.adb | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index 29db1cd2fb12..f0cf8393c7e1 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -7013,13 +7013,11 @@ package body Exp_Aggr is
       -- To_Int --
       ------------
 
-      --  The bounds of the discrete range are integers or enumeration literals
+      --  The bounds of the discrete range are static discrete values
 
       function To_Int (Expr : N_Subexpr_Id) return Int is
       begin
-         return UI_To_Int ((if Nkind (Expr) = N_Integer_Literal
-                            then Intval (Expr)
-                            else Enumeration_Pos (Entity (Expr))));
+         return UI_To_Int (Expr_Value (Expr));
       end To_Int;
 
       --  Local variables

Reply via email to