aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2020-06-15 03:51:52 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-07-27 04:05:19 -0400
commit6c1bfc9e60e1f1e23746f6140611bbd463c4a9b5 (patch)
tree079c49bdce459a27da37929998b818b6df1b7f4a /gcc/ada
parent7b6fbc9ff3dfc84186d067a2cb4d97d64f3b3e62 (diff)
downloadgcc-6c1bfc9e60e1f1e23746f6140611bbd463c4a9b5.zip
gcc-6c1bfc9e60e1f1e23746f6140611bbd463c4a9b5.tar.gz
gcc-6c1bfc9e60e1f1e23746f6140611bbd463c4a9b5.tar.bz2
[Ada] AI12-0383 Renaming values
gcc/ada/ * sem_ch8.adb (Analyze_Object_Renaming): Allow values in Ada 2020 mode.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/sem_ch8.adb27
1 files changed, 23 insertions, 4 deletions
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index da965af..b0d91e2 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);