diff options
author | Thomas Quinot <quinot@adacore.com> | 2018-09-26 09:20:05 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-09-26 09:20:05 +0000 |
commit | def15641da84fb82adfeb946c6d714683148e6e3 (patch) | |
tree | 03afa6c40302957d55a36ab4791afc3234c1e4ef /gcc/ada | |
parent | 0ebf09ed046391377af708ab2471403d3affdddd (diff) | |
download | gcc-def15641da84fb82adfeb946c6d714683148e6e3.zip gcc-def15641da84fb82adfeb946c6d714683148e6e3.tar.gz gcc-def15641da84fb82adfeb946c6d714683148e6e3.tar.bz2 |
[Ada] Fix inheritance of representation items defined as aspects
When a representation item is defined by a pragma or attribute
definition clause, the entity it applies to is that of the Name of the
representation item. But when it is defined by an aspect definition, the
entity is directly denoted by the Entity attribute of the represenation
item. The circuitry that inherits representation items for derived types
or subtypes must account for these two possible cases.
2018-09-26 Thomas Quinot <quinot@adacore.com>
gcc/ada/
* sem_ch13.adb (Inherit_Aspects_At_Freeze_Point): For a
representation item that is an N_Aspect_Definition, retrieve the
entity it applies to using the Entity attribute.
gcc/testsuite/
* gnat.dg/sso13.adb: New testcase.
From-SVN: r264636
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/sem_ch13.adb | 24 |
2 files changed, 28 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index f460963..38354ec 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2018-09-26 Thomas Quinot <quinot@adacore.com> + + * sem_ch13.adb (Inherit_Aspects_At_Freeze_Point): For a + representation item that is an N_Aspect_Definition, retrieve the + entity it applies to using the Entity attribute. + 2018-09-26 Justin Squirek <squirek@adacore.com> * sem_ch8.adb (Analyze_Subprogram_Renaming): Add extra condition diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 00854c9..b999be6 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -11446,6 +11446,26 @@ package body Sem_Ch13 is -- specification node whose correponding pragma (if any) is present in -- the Rep Item chain of the entity it has been specified to. + function Rep_Item_Entity (Rep_Item : Node_Id) return Entity_Id; + -- Return the entity for which Rep_Item is specified + + --------------------- + -- Rep_Item_Entity -- + --------------------- + + function Rep_Item_Entity (Rep_Item : Node_Id) return Entity_Id is + begin + if Nkind (Rep_Item) = N_Aspect_Specification then + return Entity (Rep_Item); + + else + pragma Assert (Nkind_In (Rep_Item, + N_Pragma, + N_Attribute_Definition_Clause)); + return Entity (Name (Rep_Item)); + end if; + end Rep_Item_Entity; + -------------------------------------------------- -- Is_Pragma_Or_Corr_Pragma_Present_In_Rep_Item -- -------------------------------------------------- @@ -11650,8 +11670,8 @@ package body Sem_Ch13 is and then Has_Rep_Item (Typ, Name_Bit_Order) then Set_Reverse_Bit_Order (Bas_Typ, - Reverse_Bit_Order (Entity (Name - (Get_Rep_Item (Typ, Name_Bit_Order))))); + Reverse_Bit_Order (Rep_Item_Entity + (Get_Rep_Item (Typ, Name_Bit_Order)))); end if; end if; |