summaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch3.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-12 13:53:46 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-12 13:53:46 +0000
commitae8e839215525d8b3ae74e66620ec64cee0aebcf (patch)
tree6ad2ca58ff5864ec425cb212773f1f9daf273009 /gcc/ada/sem_ch3.adb
parent1e07d5b95ed33b6409b5419873dbf32aa4536d53 (diff)
downloadgcc-ae8e839215525d8b3ae74e66620ec64cee0aebcf.tar.gz
2016-10-12 Ed Schonberg <schonberg@adacore.com>
* lib-writ.adb (Write_ALI): Removal of unused file entries from dependency list must be performed before the list is sorted, so that the dependency number of other files is properly set-up for use in tools that relate entity information to the unit in which they are declared. 2016-10-12 Hristian Kirtchev <kirtchev@adacore.com> * exp_aggr.adb (Initialize_Ctrl_Array_Component): Create a copy of the initialization expression to avoid sharing it between multiple components. 2016-10-12 Yannick Moy <moy@adacore.com> * einfo.adb, einfo.ads (Has_Partial_Visible_Refinement): New flag in abtract states. (Has_Non_Null_Visible_Refinement): Return true for patial refinement. (Partial_Refinement_Constituents): New function returns the full or partial refinement constituents depending on scope. * sem_ch3.adb (Analyze_Declarations): Remove partial visible refinements when exiting the scope of a package spec or body and those partial refinements are not in scope afterwards. * sem_ch7.adb, sem_ch7.ads (Install_Partial_Declarations): Mark abstract states of parent units with partial refinement so that it is visible. * sem_prag.adb (Analyze_Part_Of_In_Decl_Part): Mark enclosing abstract state if any as having partial refinement in that scope. (Analyze_Refined_Global_In_Decl_Part): Check constituent usage based on full or partial refinement depending on scope. 2016-10-12 Ed Schonberg <schonberg@adacore.com> * exp_ch4.adb (Expand_N_Type_Conversion): If the target type has an invariant aspect, insert invariant call at the proper place in the code rather than rewriting the expression as an expression with actions, to prevent spurious semantic errors on the rewritten conversion when it is the object in a renaming. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241048 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sem_ch3.adb')
-rw-r--r--gcc/ada/sem_ch3.adb41
1 files changed, 40 insertions, 1 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 3b9435f92f7..a97d0172100 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -2178,10 +2178,17 @@ package body Sem_Ch3 is
-- case, add a proper spec if the body lacks one. The spec is inserted
-- before Body_Decl and immediately analyzed.
+ procedure Remove_Partial_Visible_Refinements (Spec_Id : Entity_Id);
+ -- Spec_Id is the entity of a package that may define abstract states,
+ -- and in the case of a child unit, whose ancestors may define abstract
+ -- states. If the states have partial visible refinement, remove the
+ -- partial visibility of each constituent at the end of the package
+ -- spec and body declarations.
+
procedure Remove_Visible_Refinements (Spec_Id : Entity_Id);
-- Spec_Id is the entity of a package that may define abstract states.
-- If the states have visible refinement, remove the visibility of each
- -- constituent at the end of the package body declarations.
+ -- constituent at the end of the package body declaration.
-----------------
-- Adjust_Decl --
@@ -2335,6 +2342,29 @@ package body Sem_Ch3 is
Insert_Before_And_Analyze (Body_Decl, Decl);
end Handle_Late_Controlled_Primitive;
+ ----------------------------------------
+ -- Remove_Partial_Visible_Refinements --
+ ----------------------------------------
+
+ procedure Remove_Partial_Visible_Refinements (Spec_Id : Entity_Id) is
+ State_Elmt : Elmt_Id;
+ begin
+ if Present (Abstract_States (Spec_Id)) then
+ State_Elmt := First_Elmt (Abstract_States (Spec_Id));
+ while Present (State_Elmt) loop
+ Set_Has_Partial_Visible_Refinement (Node (State_Elmt), False);
+ Next_Elmt (State_Elmt);
+ end loop;
+ end if;
+
+ -- For a child unit, also hide the partial state refinement from
+ -- ancestor packages.
+
+ if Is_Child_Unit (Spec_Id) then
+ Remove_Partial_Visible_Refinements (Scope (Spec_Id));
+ end if;
+ end Remove_Partial_Visible_Refinements;
+
--------------------------------
-- Remove_Visible_Refinements --
--------------------------------
@@ -2576,6 +2606,15 @@ package body Sem_Ch3 is
-- restore the original state conditions.
Remove_Visible_Refinements (Corresponding_Spec (Context));
+ Remove_Partial_Visible_Refinements (Corresponding_Spec (Context));
+
+ elsif Nkind (Context) = N_Package_Declaration then
+
+ -- Partial state refinements are visible up to the end of the
+ -- package spec declarations. Hide the partial state refinements
+ -- from visibility to restore the original state conditions.
+
+ Remove_Partial_Visible_Refinements (Corresponding_Spec (Context));
end if;
-- Verify that all abstract states found in any package declared in