From 731261c3344bcf635a503d4360995a9ca7caa552 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Tue, 12 May 2015 10:54:42 +0200 Subject: [PATCH] [multiple changes] 2015-05-12 Ed Schonberg * sem_ch3.adb (Build_Derived_Enumeration_Type): The anonymous base created for a derived enumeration type is not a first subtype, even though it is defined through a full type declaration. * sem_ch13.adb (Analyze_Aspects_At_Freeze_Point): Do not process aspects for the anonymous base type constructed for a derived scalar type, because they will be set when the first subtype is frozen. (Inherit_Aspects_At_Freeze_Point): Fix typos on handling of Default_Value and Default_Component_Value, that prevented the proper inheritance of these aspects. 2015-05-12 Gary Dismukes * exp_ch6.adb, exp_unst.adb: Minor typo fixes. From-SVN: r223045 --- gcc/ada/ChangeLog | 17 +++++++++++++++++ gcc/ada/exp_ch6.adb | 2 +- gcc/ada/exp_unst.adb | 6 +++--- gcc/ada/sem_ch13.adb | 23 ++++++++++++++++++++--- gcc/ada/sem_ch3.adb | 5 +++++ 5 files changed, 46 insertions(+), 7 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 10af3d88788..ce6cd7a4aaa 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,20 @@ +2015-05-12 Ed Schonberg + + * sem_ch3.adb (Build_Derived_Enumeration_Type): The anonymous base + created for a derived enumeration type is not a first subtype, + even though it is defined through a full type declaration. + * sem_ch13.adb (Analyze_Aspects_At_Freeze_Point): Do not process + aspects for the anonymous base type constructed for a derived + scalar type, because they will be set when the first subtype + is frozen. + (Inherit_Aspects_At_Freeze_Point): Fix typos on handling of + Default_Value and Default_Component_Value, that prevented the + proper inheritance of these aspects. + +2015-05-12 Gary Dismukes + + * exp_ch6.adb, exp_unst.adb: Minor typo fixes. + 2015-05-12 Robert Dewar * sem_ch3.adb: Minor reformatting. diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 8677562f435..73ee513f6b5 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -87,7 +87,7 @@ package body Exp_Ch6 is -- we are in Unnest_Subprogram_Mode, then we record the subprogram entity -- and the body in this table, to later be passed to Unnest_Subprogram. - -- We need this delaying mechanism, because we have to wait untiil all + -- We need this delaying mechanism, because we have to wait until all -- instantiated bodies have been inserted before doing the unnesting. type Unest_Entry is record diff --git a/gcc/ada/exp_unst.adb b/gcc/ada/exp_unst.adb index e80002d3361..4a598f94261 100644 --- a/gcc/ada/exp_unst.adb +++ b/gcc/ada/exp_unst.adb @@ -95,7 +95,7 @@ package body Exp_Unst is -- This flag is set True if there is a call path from the outer level -- subprogram to this subprogram. If Reachable is False, it means that -- the subprogram is declared but not actually referenced. We remove - -- such suprograms from the tree, which simplifies our task, because + -- such subprograms from the tree, which simplifies our task, because -- we don't have to worry about e.g. uplevel references from such an -- unreferenced subpogram, which might require (useless) activation -- records to be created. This is computed by setting the outer level @@ -118,7 +118,7 @@ package body Exp_Unst is Declares_AREC : Boolean; -- This is set True for a subprogram which include the declarations - -- for a local activation record to bew passed on downward calls. It + -- for a local activation record to be passed on downward calls. It -- is set True for the target level of an uplevel reference, and for -- all intervening nested subprograms. For example, if a subprogram X -- at level 5 makes an uplevel reference to an entity declared in a @@ -225,7 +225,7 @@ package body Exp_Unst is Callee : Entity_Id; -- The entity for the subprogram containing the referenced entity. Note -- that the level of Callee must be less than the level of Caller, since - -- this is uplevel reference. + -- this is an uplevel reference. end record; package Urefs is new Table.Table ( diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 6f68e9afbfb..8e4eb0be93e 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -1130,7 +1130,20 @@ package body Sem_Ch13 is when Aspect_Default_Value | Aspect_Default_Component_Value => - Analyze_Aspect_Default_Value (ASN); + + -- Do not inherit aspect for anonymous base type of a + -- scalar or array type, because they apply to the first + -- subtype of the type, and will be processed when that + -- first subtype is frozen. + + if Is_Derived_Type (E) + and then not Comes_From_Source (E) + and then E /= First_Subtype (E) + then + null; + else + Analyze_Aspect_Default_Value (ASN); + end if; -- Ditto for iterator aspects, because the corresponding -- attributes may not have been analyzed yet. @@ -10910,9 +10923,12 @@ package body Sem_Ch13 is -- Default_Component_Value + -- Verify that there is no rep_item declared for the type, and there + -- is one coming from an ancestor. + if Is_Array_Type (Typ) and then Is_Base_Type (Typ) - and then Has_Rep_Item (Typ, Name_Default_Component_Value, False) + and then not Has_Rep_Item (Typ, Name_Default_Component_Value, False) and then Has_Rep_Item (Typ, Name_Default_Component_Value) then Set_Default_Aspect_Component_Value (Typ, @@ -10924,9 +10940,10 @@ package body Sem_Ch13 is if Is_Scalar_Type (Typ) and then Is_Base_Type (Typ) - and then Has_Rep_Item (Typ, Name_Default_Value, False) + and then not Has_Rep_Item (Typ, Name_Default_Value, False) and then Has_Rep_Item (Typ, Name_Default_Value) then + Set_Has_Default_Aspect (Typ); Set_Default_Aspect_Value (Typ, Default_Aspect_Value (Entity (Get_Rep_Item (Typ, Name_Default_Value)))); diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 7b87c2dbfc1..08ad303f0a5 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -6553,6 +6553,11 @@ package body Sem_Ch3 is Insert_Before (N, Type_Decl); Analyze (Type_Decl); + -- The anonymous base now has a full declaration, but this base + -- is not a first subtype. + + Set_Is_First_Subtype (Implicit_Base, False); + -- After the implicit base is analyzed its Etype needs to be changed -- to reflect the fact that it is derived from the parent type which -- was ignored during analysis. We also set the size at this point. -- 2.30.2