summaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch12.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-02 09:17:46 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-02 09:17:46 +0000
commit992ec8bcb63d0bc997d1d012339cf871c346078f (patch)
treee10f4754a39287ad20096cfb93f40edf8cf10f77 /gcc/ada/sem_ch12.adb
parent7ef6449a8e66fff3c9c967bbbe121db720e46458 (diff)
downloadgcc-992ec8bcb63d0bc997d1d012339cf871c346078f.tar.gz
2011-08-02 Yannick Moy <moy@adacore.com>
* errout.adb, errout.ads (Check_Formal_Restriction): move procedure from here... * restrict.adb, restrict.ads (Check_Formal_Restriction): ...to here * sem_aggr.adb, sem_ch5.adb, sem_util.adb: Add with/use clauses to make Check_Formal_Restriction visible 2011-08-02 Ed Schonberg <schonberg@adacore.com> * sem_ch12.adb (Check_Generic_Actuals): handle properly actual in-parameters when type of the generic formal is private in the generic spec and non-private in the body. 2011-08-02 Claire Dross <dross@adacore.com> * a-cfdlli.adb, a-cfdlli.ads, a-cfhase.adb, a-cfhase.ads, a-cfhama.adb, a-cfhama.ads, a-cforse.adb, a-cforse.ads, a-cforma.adb, a-cforma.ads, a-cofove.adb, a-cofove.ads: New files implementing formal containers. * impunit.adb, Makefile.rtl: Take new files into account. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177102 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sem_ch12.adb')
-rw-r--r--gcc/ada/sem_ch12.adb58
1 files changed, 58 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
index e688485fb59..08a08d8f68e 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -4966,6 +4966,7 @@ package body Sem_Ch12 is
else
Check_Private_View (Subtype_Indication (Parent (E)));
end if;
+
Set_Is_Generic_Actual_Type (E, True);
Set_Is_Hidden (E, False);
Set_Is_Potentially_Use_Visible (E,
@@ -5054,6 +5055,63 @@ package body Sem_Ch12 is
Set_Is_Hidden (E, False);
end if;
+ if Ekind (E) = E_Constant then
+
+ -- If the type of the actual is a private type declared in the
+ -- enclosing scope of the generic unit, the body of the generic
+ -- sees the full view of the type (because it has to appear in
+ -- the corresponding package body). If the type is private now,
+ -- exchange views to restore the proper visiblity in the instance.
+
+ declare
+ Typ : constant Entity_Id := Base_Type (Etype (E));
+ -- The type of the actual
+
+ Gen_Id : Entity_Id;
+ -- The generic unit
+
+ Parent_Scope : Entity_Id;
+ -- The enclosing scope of the generic unit
+
+ begin
+ if Is_Wrapper_Package (Instance) then
+ Gen_Id :=
+ Generic_Parent
+ (Specification
+ (Unit_Declaration_Node
+ (Related_Instance (Instance))));
+ else
+ Gen_Id :=
+ Generic_Parent
+ (Specification (Unit_Declaration_Node (Instance)));
+ end if;
+
+ Parent_Scope := Scope (Gen_Id);
+
+ -- The exchange is only needed if the generic is defined
+ -- within a package which is not a common ancestor of the
+ -- scope of the instance, and is not already in scope.
+
+ if Is_Private_Type (Typ)
+ and then Scope (Typ) = Parent_Scope
+ and then Scope (Instance) /= Parent_Scope
+ and then Ekind (Parent_Scope) = E_Package
+ and then not Is_Child_Unit (Gen_Id)
+ then
+ Switch_View (Typ);
+
+ -- If the type of the entity is a subtype, it may also
+ -- have to be made visible, together with the base type
+ -- of its full view, after exchange.
+
+ if Is_Private_Type (Etype (E)) then
+ Switch_View (Etype (E));
+ Switch_View (Base_Type (Etype (E)));
+ end if;
+ end if;
+ end;
+ end if;
+
Next_Entity (E);
end loop;
end Check_Generic_Actuals;