[multiple changes]

2010-06-17  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch10.adb (Is_Ancestor_Unit): Subsidiary to
	Install_Limited_Context_Clauses, to determine whether a limited_with in
	some parent of the current unit designates some other parent, in which
	case the limited_with clause must not be installed.
	(In_Context): Refine test.

2010-06-17  Gary Dismukes  <dismukes@adacore.com>

	* sem_util.adb (Collect_Primitive_Operations): In the of an untagged
	type with a dispatching equality operator that is overridden (for a
	tagged full type), don't include the overridden equality in the list of
	primitives. The overridden equality is detected by testing for an
	Aliased field that references the overriding equality.

2010-06-17  Robert Dewar  <dewar@adacore.com>

	* freeze.adb: Minor reformatting.

From-SVN: r160924
This commit is contained in:
Arnaud Charlet 2010-06-17 17:29:21 +02:00
parent 4519314ce8
commit 305379908d
4 changed files with 78 additions and 5 deletions

View File

@ -1,3 +1,23 @@
2010-06-17 Ed Schonberg <schonberg@adacore.com>
* sem_ch10.adb (Is_Ancestor_Unit): Subsidiary to
Install_Limited_Context_Clauses, to determine whether a limited_with in
some parent of the current unit designates some other parent, in which
case the limited_with clause must not be installed.
(In_Context): Refine test.
2010-06-17 Gary Dismukes <dismukes@adacore.com>
* sem_util.adb (Collect_Primitive_Operations): In the of an untagged
type with a dispatching equality operator that is overridden (for a
tagged full type), don't include the overridden equality in the list of
primitives. The overridden equality is detected by testing for an
Aliased field that references the overriding equality.
2010-06-17 Robert Dewar <dewar@adacore.com>
* freeze.adb: Minor reformatting.
2010-06-17 Joel Brobecker <brobecker@adacore.com brobecker>
* gnat_ugn.texi: Add a section introducing gdbserver.

View File

@ -5306,7 +5306,7 @@ package body Freeze is
return True;
end;
-- For the designated type of an access to subprogram. all types in
-- For the designated type of an access to subprogram, all types in
-- the profile must be fully defined.
elsif Ekind (T) = E_Subprogram_Type then

View File

@ -3373,6 +3373,11 @@ package body Sem_Ch10 is
-- units. The shadow entities are created when the inserted clause is
-- analyzed. Implements Ada 2005 (AI-50217).
function Is_Ancestor_Unit (U1 : Node_Id; U2 : Node_Id) return Boolean;
-- When compiling a unit Q descended from some parent unit P, a limited
-- with_clause in the context of P that names some other ancestor of Q
-- must not be installed because the ancestor is immediately visible.
---------------------
-- Check_Renamings --
---------------------
@ -3645,6 +3650,22 @@ package body Sem_Ch10 is
New_Nodes_OK := New_Nodes_OK - 1;
end Expand_Limited_With_Clause;
----------------------
-- Is_Ancestor_Unit --
----------------------
function Is_Ancestor_Unit (U1 : Node_Id; U2 : Node_Id) return Boolean is
E1 : constant Entity_Id := Defining_Entity (Unit (U1));
E2 : Entity_Id;
begin
if Nkind_In (Unit (U2), N_Package_Body, N_Subprogram_Body) then
E2 := Defining_Entity (Unit (Library_Unit (U2)));
return Is_Ancestor_Package (E1, E2);
else
return False;
end if;
end Is_Ancestor_Unit;
-- Start of processing for Install_Limited_Context_Clauses
begin
@ -3678,6 +3699,9 @@ package body Sem_Ch10 is
if Library_Unit (Item) /= Cunit (Current_Sem_Unit)
and then not Limited_View_Installed (Item)
and then
not Is_Ancestor_Unit
(Library_Unit (Item), Cunit (Current_Sem_Unit))
then
if not Private_Present (Item)
or else Private_Present (N)
@ -4013,7 +4037,8 @@ package body Sem_Ch10 is
function In_Context return Boolean;
-- Scan context of current unit, to check whether there is
-- a with_clause on the same unit as a private with-clause
-- on a parent, in which case child unit is visible.
-- on a parent, in which case child unit is visible. If the
-- unit is a grand-child, the same applies to its parent.
----------------
-- In_Context --
@ -4027,10 +4052,15 @@ package body Sem_Ch10 is
if Nkind (Clause) = N_With_Clause
and then Comes_From_Source (Clause)
and then Is_Entity_Name (Name (Clause))
and then Entity (Name (Clause)) = Id
and then not Private_Present (Clause)
then
return True;
if Entity (Name (Clause)) = Id
or else
(Nkind (Name (Clause)) = N_Expanded_Name
and then Entity (Prefix (Name (Clause))) = Id)
then
return True;
end if;
end if;
Next (Clause);

View File

@ -1670,7 +1670,30 @@ package body Sem_Util is
and then (not Formal_Derived
or else Present (Alias (Id)))
then
Append_Elmt (Id, Op_List);
-- In the special case of an equality operator aliased to
-- an overriding dispatching equality belonging to the same
-- type, we don't include it in the list of primitives.
-- This avoids inheriting multiple equality operators when
-- deriving from untagged private types whose full type is
-- tagged, which can otherwise cause ambiguities. Note that
-- this should only happen for this kind of untagged parent
-- type, since normally dispatching operations are inherited
-- using the type's Primitive_Operations list.
if Chars (Id) = Name_Op_Eq
and then Is_Dispatching_Operation (Id)
and then Present (Alias (Id))
and then Is_Overriding_Operation (Alias (Id))
and then Base_Type (Etype (First_Entity (Id))) =
Base_Type (Etype (First_Entity (Alias (Id))))
then
null;
-- Include the subprogram in the list of primitives
else
Append_Elmt (Id, Op_List);
end if;
end if;
end if;