summaryrefslogtreecommitdiff
path: root/gcc/ada/sem_util.adb
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-03 12:01:29 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-03 12:01:29 +0000
commit2e6c46d4d695bf1d929024fc5744afcb8c2122b8 (patch)
treeffb7f9e20d6446825785e99b6d21b6f8c4b38a2d /gcc/ada/sem_util.adb
parent6293fc53566dc4397c0b59026a46accbbd16f622 (diff)
downloadgcc-2e6c46d4d695bf1d929024fc5744afcb8c2122b8.tar.gz
2012-10-03 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 192029 using svnmerge.py git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@192032 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sem_util.adb')
-rw-r--r--gcc/ada/sem_util.adb57
1 files changed, 57 insertions, 0 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index f557033d416..2e68039262f 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -279,6 +279,63 @@ package body Sem_Util is
return Alignment (E) * System_Storage_Unit;
end Alignment_In_Bits;
+ ---------------------------------
+ -- Append_Inherited_Subprogram --
+ ---------------------------------
+
+ procedure Append_Inherited_Subprogram (S : Entity_Id) is
+ Par : constant Entity_Id := Alias (S);
+ -- The parent subprogram
+
+ Scop : constant Entity_Id := Scope (Par);
+ -- The scope of definition of the parent subprogram
+
+ Typ : constant Entity_Id := Defining_Entity (Parent (S));
+ -- The derived type of which S is a primitive operation
+
+ Decl : Node_Id;
+ Next_E : Entity_Id;
+
+ begin
+ if Ekind (Current_Scope) = E_Package
+ and then In_Private_Part (Current_Scope)
+ and then Has_Private_Declaration (Typ)
+ and then Is_Tagged_Type (Typ)
+ and then Scop = Current_Scope
+ then
+ -- The inherited operation is available at the earliest place after
+ -- the derived type declaration ( RM 7.3.1 (6/1)). This is only
+ -- relevant for type extensions. If the parent operation appears
+ -- after the type extension, the operation is not visible.
+
+ Decl := First
+ (Visible_Declarations
+ (Specification (Unit_Declaration_Node (Current_Scope))));
+ while Present (Decl) loop
+ if Nkind (Decl) = N_Private_Extension_Declaration
+ and then Defining_Entity (Decl) = Typ
+ then
+ if Sloc (Decl) > Sloc (Par) then
+ Next_E := Next_Entity (Par);
+ Set_Next_Entity (Par, S);
+ Set_Next_Entity (S, Next_E);
+ return;
+
+ else
+ exit;
+ end if;
+ end if;
+
+ Next (Decl);
+ end loop;
+ end if;
+
+ -- If partial view is not a type extension, or it appears before the
+ -- subprogram declaration, insert normally at end of entity list.
+
+ Append_Entity (S, Current_Scope);
+ end Append_Inherited_Subprogram;
+
-----------------------------------------
-- Apply_Compile_Time_Constraint_Error --
-----------------------------------------