Attributes Enum_Rep/Enum_Val are now standard in Ada 202x, so adjust
their handling accordingly.

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

2020-06-05  Arnaud Charlet  <char...@adacore.com>

gcc/ada/

        * sem_attr.ads (Attribute_Impl_Def): Remove Enum_Rep/Val.
        * sem_attr.adb (Attribute_20): New, move Enum_Rep/Val here.
        (Analyze_Attribute): Take Attribute_20 into account.
--- gcc/ada/sem_attr.adb
+++ gcc/ada/sem_attr.adb
@@ -164,6 +164,15 @@ package body Sem_Attr is
       Attribute_Max_Alignment_For_Allocation => True,
       others                                 => False);
 
+   --  The following array is the list of attributes defined in the Ada 2020
+   --  RM which are not defined in Ada 2012. These are recognized in Ada
+   --  95/2005/2012 modes, but are considered to be implementation defined.
+
+   Attribute_20 : constant Attribute_Class_Array := Attribute_Class_Array'(
+      Attribute_Enum_Rep                     |
+      Attribute_Enum_Val                     => True,
+      others                                 => False);
+
    --  The following array contains all attributes that imply a modification
    --  of their prefixes or result in an access value. Such prefixes can be
    --  considered as lvalues.
@@ -2867,12 +2876,14 @@ package body Sem_Attr is
       end if;
 
       --  Deal with Ada 2005 attributes that are implementation attributes
-      --  because they appear in a version of Ada before Ada 2005, and
-      --  similarly for Ada 2012 attributes appearing in an earlier version.
+      --  because they appear in a version of Ada before Ada 2005, ditto for
+      --  Ada 2012 and Ada 2020 attributes appearing in an earlier version.
 
       if (Attribute_05 (Attr_Id) and then Ada_Version < Ada_2005)
             or else
          (Attribute_12 (Attr_Id) and then Ada_Version < Ada_2012)
+            or else
+         (Attribute_20 (Attr_Id) and then Ada_Version < Ada_2020)
       then
          Check_Restriction (No_Implementation_Attributes, N);
       end if;

--- gcc/ada/sem_attr.ads
+++ gcc/ada/sem_attr.ads
@@ -212,36 +212,6 @@ package Sem_Attr is
       --  value indicating whether or not the body of the designated library
       --  unit has been elaborated yet.
 
-      --------------
-      -- Enum_Rep --
-      --------------
-
-      Attribute_Enum_Rep => True,
-      --  For every enumeration subtype S, S'Enum_Rep denotes a function
-      --  with the following specification:
-      --
-      --    function S'Enum_Rep (Arg : S'Base) return universal_integer;
-      --
-      --  The function returns the representation value for the given
-      --  enumeration value. This will be equal to the 'Pos value in the
-      --  absence of an enumeration representation clause. This is a static
-      --  attribute (i.e. the result is static if the argument is static).
-
-      --------------
-      -- Enum_Val --
-      --------------
-
-      Attribute_Enum_Val => True,
-      --  For every enumeration subtype S, S'Enum_Val denotes a function with
-      --  the following specification:
-      --
-      --    function S'Enum_Val (Arg : universal_integer) return S'Base;
-      --
-      --  This function performs the inverse transformation to Enum_Rep. Given
-      --  a representation value for the type, it returns the corresponding
-      --  enumeration value. Constraint_Error is raised if no value of the
-      --  enumeration type corresponds to the given integer value.
-
       -----------------------
       -- Finalization_Size --
       -----------------------

Reply via email to