From: Arnaud Charlet Date: Fri, 31 Jan 2020 12:52:25 +0000 (-0500) Subject: [Ada] AI12-0237 Getting the representation of an enumeration value X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=61fa3fd79ff9bf41651ca99f2f13902e91ca736d;p=gcc.git [Ada] AI12-0237 Getting the representation of an enumeration value 2020-06-05 Arnaud Charlet 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. --- diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 160a2062671..f4e38a0daed 100644 --- a/gcc/ada/sem_attr.adb +++ b/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; diff --git a/gcc/ada/sem_attr.ads b/gcc/ada/sem_attr.ads index b62b4ffc392..16b902e1c72 100644 --- a/gcc/ada/sem_attr.ads +++ b/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 -- -----------------------