Fix a bug (which shows up as an assertion failure in gigi) having to
do with the tree generated by the FE for a record-valued case-statement
choice that has a subcomponent of an enumeration type.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

        * exp_ch5.adb
        (Expand_N_Case_Statement.Expand_General_Case_Statement.Pattern_Match):
        When generating an equality test for a statically known discrete
        value, only generate the numeric value if the discrete type is
        not an enumeration type.  If it is an enumeration type, then
        call Get_Enum_Lit_From_Pos instead.
diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb
--- a/gcc/ada/exp_ch5.adb
+++ b/gcc/ada/exp_ch5.adb
@@ -3384,9 +3384,17 @@ package body Exp_Ch5 is
               and then Is_Discrete_Type (Etype (Pattern))
               and then Compile_Time_Known_Value (Pattern)
             then
-               return Make_Op_Eq (Loc,
-                        Object,
-                        Make_Integer_Literal (Loc, Expr_Value (Pattern)));
+               declare
+                  Val : Node_Id;
+               begin
+                  if Is_Enumeration_Type (Etype (Pattern)) then
+                     Val := Get_Enum_Lit_From_Pos
+                              (Etype (Pattern), Expr_Value (Pattern), Loc);
+                  else
+                     Val := Make_Integer_Literal (Loc, Expr_Value (Pattern));
+                  end if;
+                  return Make_Op_Eq (Loc, Object, Val);
+               end;
             end if;
 
             case Nkind (Pattern) is


Reply via email to