aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2010-06-17 17:29:21 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2010-06-17 17:29:21 +0200
commit305379908d3e3d0e17703c8fbce977c92fbc390d (patch)
tree7124793bd2b8e0849febbc62dbdc8595dd91a9b7
parent4519314ce8c904c6f9703996a8ecf7b3fcff5198 (diff)
downloadgcc-305379908d3e3d0e17703c8fbce977c92fbc390d.zip
gcc-305379908d3e3d0e17703c8fbce977c92fbc390d.tar.gz
gcc-305379908d3e3d0e17703c8fbce977c92fbc390d.tar.bz2
[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
-rw-r--r--gcc/ada/ChangeLog20
-rw-r--r--gcc/ada/freeze.adb2
-rw-r--r--gcc/ada/sem_ch10.adb36
-rw-r--r--gcc/ada/sem_util.adb25
4 files changed, 78 insertions, 5 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index d70d736..278b183 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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.
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 8900060..f976832 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -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
diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb
index 29d33b7..6b61a87 100644
--- a/gcc/ada/sem_ch10.adb
+++ b/gcc/ada/sem_ch10.adb
@@ -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);
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index dcd6848..06676ea 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -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;