From f2a35a2fe4a6fef35de549c3aaff120e110cceb8 Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Tue, 20 Aug 2019 09:49:23 +0000 Subject: [PATCH] [Ada] Fix a folding issue with System'To_Address 2019-08-20 Bob Duff gcc/ada/ * sem_eval.adb (Expr_Value): Implement the case of an unchecked conversion of a static expression. From-SVN: r274726 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/sem_eval.adb | 14 +++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 8ab2eddd646..e9a8e79a0db 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-08-20 Bob Duff + + * sem_eval.adb (Expr_Value): Implement the case of an unchecked + conversion of a static expression. + 2019-08-20 Bob Duff * sem_ch13.adb (Is_Null_Array): New function, used to detect the diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb index 78740b956ee..430b8bd5234 100644 --- a/gcc/ada/sem_eval.adb +++ b/gcc/ada/sem_eval.adb @@ -4281,10 +4281,9 @@ package body Sem_Eval is pragma Assert (Is_Access_Type (Underlying_Type (Etype (N)))); Val := Uint_0; - -- Otherwise must be character literal + -- Character literal - else - pragma Assert (Kind = N_Character_Literal); + elsif Kind = N_Character_Literal then Ent := Entity (N); -- Since Character literals of type Standard.Character don't @@ -4298,6 +4297,15 @@ package body Sem_Eval is else Val := Enumeration_Pos (Ent); end if; + + -- Unchecked conversion, which can come from System'To_Address (X) + -- where X is a static integer expression. Recursively evaluate X. + + elsif Kind = N_Unchecked_Type_Conversion then + Val := Expr_Value (Expression (N)); + + else + raise Program_Error; end if; -- Come here with Val set to value to be returned, set cache -- 2.30.2