From 6c1bfc9e60e1f1e23746f6140611bbd463c4a9b5 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Mon, 15 Jun 2020 03:51:52 -0400 Subject: [PATCH] [Ada] AI12-0383 Renaming values gcc/ada/ * sem_ch8.adb (Analyze_Object_Renaming): Allow values in Ada 2020 mode. --- gcc/ada/sem_ch8.adb | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index da965afdf8f..b0d91e25a68 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -918,7 +918,8 @@ package body Sem_Ch8 is if No (Etype (Nam)) or else Etype (Nam) = Standard_Void_Type then - Error_Msg_N ("object name expected in renaming", Nam); + Error_Msg_N + ("object name or value expected in renaming", Nam); Set_Ekind (Id, E_Variable); Set_Etype (Id, Any_Type); @@ -965,7 +966,8 @@ package body Sem_Ch8 is -- as overloaded procedures named in the object renaming). if No (It.Typ) then - Error_Msg_N ("object name expected in renaming", Nam); + Error_Msg_N + ("object name or value expected in renaming", Nam); Set_Ekind (Id, E_Variable); Set_Etype (Id, Any_Type); @@ -996,6 +998,12 @@ package body Sem_Ch8 is T := It1.Typ; end; end if; + + if Etype (Nam) = Standard_Exception_Type then + Error_Msg_N + ("exception requires a subtype mark in renaming", Nam); + return; + end if; end if; -- The object renaming declaration may become Ghost if it renames a @@ -1396,8 +1404,19 @@ package body Sem_Ch8 is and then Nkind (Original_Node (Nam)) /= N_Attribute_Reference then null; - else - Error_Msg_N ("expect object name in renaming", Nam); + + -- A named number can only be renamed without a subtype mark + + elsif Nkind (Nam) in N_Real_Literal | N_Integer_Literal + and then Present (Subtype_Mark (N)) + and then Present (Original_Entity (Nam)) + then + Error_Msg_N ("incompatible types in renaming", Nam); + + -- AI12-0383: Names that denote values can be renamed + + elsif Ada_Version < Ada_2020 then + Error_Msg_N ("value in renaming requires -gnat2020", Nam); end if; Set_Etype (Id, T2); -- 2.30.2