From 7029d96f5a2e98500707ca9110e5ca569e062d13 Mon Sep 17 00:00:00 2001 From: Ed Schonberg Date: Mon, 1 Jul 2019 13:37:37 +0000 Subject: [Ada] More permissive use of GNAT attribute Enum_Rep This patch allows the prefix of the attribute Enum_Rep to be an attribute referece (such as Enum_Type'First). A recent patch had restricted the prefix to be an object of a discrete type, which is incompatible with orevious usage. 2019-07-01 Ed Schonberg gcc/ada/ * sem_attr.adb (Analyze_Attribute, case Enum_Rep): Allow prefix of attribute to be an attribute reference of a discrete type. gcc/testsuite/ * gnat.dg/enum_rep.adb, gnat.dg/enum_rep.ads: New testcase. From-SVN: r272881 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/sem_attr.adb | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'gcc/ada') diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index a342b98..63ed0d8 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-07-01 Ed Schonberg + + * 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 * sem_ch12.adb (Analyze_Subprogram_Instantiation): Move up diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index e966bf1..bdc76c3 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -3833,14 +3833,16 @@ package body Sem_Attr is 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"); -- cgit v1.1