aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2020-01-31 07:52:25 -0500
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-05 08:17:38 -0400
commit61fa3fd79ff9bf41651ca99f2f13902e91ca736d (patch)
tree6b18995fd9ffca10f04276a9d71ba7089f390d73 /gcc/ada
parent79d09a491c9ca17e2159d73e0e9855d64d6fa7cf (diff)
downloadgcc-61fa3fd79ff9bf41651ca99f2f13902e91ca736d.zip
gcc-61fa3fd79ff9bf41651ca99f2f13902e91ca736d.tar.gz
gcc-61fa3fd79ff9bf41651ca99f2f13902e91ca736d.tar.bz2
[Ada] AI12-0237 Getting the representation of an enumeration value
2020-06-05 Arnaud Charlet <charlet@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.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/sem_attr.adb15
-rw-r--r--gcc/ada/sem_attr.ads30
2 files changed, 13 insertions, 32 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index 160a206..f4e38a0 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 b62b4ff..16b902e 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 --
-----------------------