Commit cdc8c54c by Bob Duff Committed by Arnaud Charlet

sem_ch8.adb (Note_Redundant_Use): Suppress unhelpful warning about redundant use clauses.

2006-02-13  Bob Duff  <duff@adacore.com>

	* sem_ch8.adb (Note_Redundant_Use): Suppress unhelpful warning about
	redundant use clauses.
	In particular, if the scope of two use clauses overlaps, but one is not
	entirely included in the other, we should not warn.  This can happen
	with nested packages.
	(Analyze_Subprogram_Renaming): Protect the compiler against previously
	reported errors. The bug was reported when the compiler was built
	with assertions enabled.
	(Find_Type): If the node is a 'Class reference and the prefix is a
	synchronized type without a corresponding record, return the type
	itself.

From-SVN: r111093
parent fe45e59e
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -438,7 +438,7 @@ package body Sem_Ch8 is ...@@ -438,7 +438,7 @@ package body Sem_Ch8 is
function Has_Private_With (E : Entity_Id) return Boolean; function Has_Private_With (E : Entity_Id) return Boolean;
-- Ada 2005 (AI-262): Determines if the current compilation unit has a -- Ada 2005 (AI-262): Determines if the current compilation unit has a
-- private with on E -- private with on E.
procedure Find_Expanded_Name (N : Node_Id); procedure Find_Expanded_Name (N : Node_Id);
-- Selected component is known to be expanded name. Verify legality -- Selected component is known to be expanded name. Verify legality
...@@ -1762,9 +1762,11 @@ package body Sem_Ch8 is ...@@ -1762,9 +1762,11 @@ package body Sem_Ch8 is
-- Ada 2005 AI 404: if the new subprogram is dispatching, verify that -- Ada 2005 AI 404: if the new subprogram is dispatching, verify that
-- controlling access parameters are known non-null for the renamed -- controlling access parameters are known non-null for the renamed
-- subprogram. Test also applies to a subprogram instantiation that -- subprogram. Test also applies to a subprogram instantiation that
-- is dispatching. -- is dispatching. Test is skipped if some previous error was detected
-- that set Old_S to Any_Id.
if Ada_Version >= Ada_05 if Ada_Version >= Ada_05
and then Old_S /= Any_Id
and then not Is_Dispatching_Operation (Old_S) and then not Is_Dispatching_Operation (Old_S)
and then Is_Dispatching_Operation (New_S) and then Is_Dispatching_Operation (New_S)
then then
...@@ -4663,7 +4665,7 @@ package body Sem_Ch8 is ...@@ -4663,7 +4665,7 @@ package body Sem_Ch8 is
-- of incomplete types, because the type must still -- of incomplete types, because the type must still
-- appear untagged to outside units. -- appear untagged to outside units.
if not Present (Class_Wide_Type (T)) then if No (Class_Wide_Type (T)) then
Make_Class_Wide_Type (T); Make_Class_Wide_Type (T);
end if; end if;
...@@ -4685,8 +4687,18 @@ package body Sem_Ch8 is ...@@ -4685,8 +4687,18 @@ package body Sem_Ch8 is
else else
if Is_Concurrent_Type (T) then if Is_Concurrent_Type (T) then
if No (Corresponding_Record_Type (Entity (Prefix (N)))) then
-- Previous error. Use current type, which at least
-- provides some operations.
C := Entity (Prefix (N));
else
C := Class_Wide_Type C := Class_Wide_Type
(Corresponding_Record_Type (Entity (Prefix (N)))); (Corresponding_Record_Type (Entity (Prefix (N))));
end if;
else else
C := Class_Wide_Type (Entity (Prefix (N))); C := Class_Wide_Type (Entity (Prefix (N)));
end if; end if;
...@@ -5415,7 +5427,22 @@ package body Sem_Ch8 is ...@@ -5415,7 +5427,22 @@ package body Sem_Ch8 is
if not Is_Compilation_Unit (Current_Scope) then if not Is_Compilation_Unit (Current_Scope) then
-- If the use_clause is in an inner scope, it is made redundant -- If the use_clause is in an inner scope, it is made redundant
-- by some clause in the current context. -- by some clause in the current context, with one exception:
-- If we're compiling a nested package body, and the use_clause
-- comes from the corresponding spec, the clause is not necessarily
-- fully redundant, so we should not warn. If a warning was
-- warranted, it would have been given when the spec was processed.
if Nkind (Parent (Decl)) = N_Package_Specification then
declare
Package_Spec_Entity : constant Entity_Id :=
Defining_Unit_Name (Parent (Decl));
begin
if In_Package_Body (Package_Spec_Entity) then
return;
end if;
end;
end if;
Redundant := Clause; Redundant := Clause;
Prev_Use := Cur_Use; Prev_Use := Cur_Use;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment