[Ada] Spurious use_type clause warning

This patch corrects an error in the compiler whereby a spurious
redundant use_type_clause warning gets issued when the clause appears in
the context_clause of a package preceding a with_clause for a package
with an identical use_clause in its specification.

gcc/ada/

	* einfo.ads: Modify documentation for In_Use flag to include
	scope stack manipulation.
	* sem_ch8.adb (Use_One_Type): Add condition to return when
	attempting to detect redundant use_type_clauses in child units
	in certain cases.
This commit is contained in:
Justin Squirek
2022-06-15 01:53:49 +00:00
committed by Pierre-Marie de Rodat
parent 433cefcd02
commit 729d2e2a80
2 changed files with 18 additions and 3 deletions
+4
View File
@@ -2309,6 +2309,10 @@ package Einfo is
-- the corresponding entity. Reset at end of corresponding declarative
-- part. The flag on a type is also used to determine the visibility of
-- the primitive operators of the type.
--
-- Note that manipulation of scopes on the scope stack will also cause
-- the flag to be set/unset since the setting of scopes affects
-- visibility.
-- Is_Abstract_Subprogram
-- Defined in all subprograms and entries. Set for abstract subprograms.
+14 -3
View File
@@ -10758,15 +10758,26 @@ package body Sem_Ch8 is
return;
end if;
-- There is a redundant use_type_clause in a child unit.
-- Determine which of the units is more deeply nested. If a
-- If there is a redundant use_type_clause in a child unit
-- determine which of the units is more deeply nested. If a
-- unit is a package instance, retrieve the entity and its
-- scope from the instance spec.
Ent1 := Entity_Of_Unit (Unit1);
Ent2 := Entity_Of_Unit (Unit2);
if Scope (Ent2) = Standard_Standard then
-- When the scope of both units' entities are
-- Standard_Standard then neither Unit1 or Unit2 are child
-- units - so return in that case.
if Scope (Ent1) = Standard_Standard
and then Scope (Ent2) = Standard_Standard
then
return;
-- Otherwise, determine if one of the units is not a child
elsif Scope (Ent2) = Standard_Standard then
Error_Msg_Sloc := Sloc (Clause2);
Err_No := Clause1;