+2019-07-01 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_attr.adb (Analyze_Attribute, case Enum_Rep): Allow prefix
+ of attribute to be an attribute reference of a discrete type.
+
2019-07-01 Eric Botcazou <ebotcazou@adacore.com>
* sem_ch12.adb (Analyze_Subprogram_Instantiation): Move up
Check_Discrete_Type;
Resolve (E1, P_Base_Type);
- -- X'Enum_Rep case. X must be an object or enumeration literal, and
- -- it must be of a discrete type.
+ -- X'Enum_Rep case. X must be an object or enumeration literal
+ -- (including an attribute reference), and it must be of a
+ -- discrete type.
elsif not
((Is_Object_Reference (P)
or else
(Is_Entity_Name (P)
- and then Ekind (Entity (P)) = E_Enumeration_Literal))
+ and then Ekind (Entity (P)) = E_Enumeration_Literal)
+ or else Nkind (P) = N_Attribute_Reference)
and then Is_Discrete_Type (Etype (P)))
then
Error_Attr_P ("prefix of % attribute must be discrete object");
+2019-07-01 Ed Schonberg <schonberg@adacore.com>
+
+ * gnat.dg/enum_rep.adb, gnat.dg/enum_rep.ads: New testcase.
+
2019-07-01 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/derived_type6.adb, gnat.dg/derived_type6.ads: New
--- /dev/null
+-- { dg-do compile }
+
+package body Enum_Rep is
+ procedure Foo is null;
+end;
--- /dev/null
+with Interfaces;
+
+package Enum_Rep is
+
+ type My_Type is range 00 .. 100;
+
+ subtype My_Subtype2 is Interfaces.Unsigned_32
+ range My_Type'First'Enum_Rep .. My_Type'Last'Enum_Rep;
+
+ My_Type_First : constant My_Type := My_Type'First;
+ My_Type_Last : constant My_Type := My_Type'Last;
+
+ subtype My_Subtype is Interfaces.Unsigned_32
+ range My_Type_First'Enum_Rep .. My_Type_Last'Enum_Rep;
+
+ subtype My_Subtype1 is Interfaces.Unsigned_32
+ range My_Type'Enum_Rep (My_Type'First) ..
+ My_Type'Enum_Rep (MY_Type'Last);
+
+ procedure Foo;
+
+end;