---------------------
procedure End_Use_Package (N : Node_Id) is
- Pack : Entity_Id;
- Pack_Name : Node_Id;
- Id : Entity_Id;
- Elmt : Elmt_Id;
-
function Type_In_Use (T : Entity_Id; P : Entity_Id) return Boolean;
-- Check whether type T is declared in P and appears in an active
-- use_type clause.
return Scope (BT) = P and then (In_Use (T) or else In_Use (BT));
end Type_In_Use;
+ -- Local variables
+
+ Elmt : Elmt_Id;
+ Id : Entity_Id;
+ Pack : Entity_Id;
+ Pack_Name : Node_Id;
+ Scop : Entity_Id;
+
-- Start of processing for End_Use_Package
begin
-- Preserve use-visibility of operators that are primitive
-- operators of a type that is use-visible through an active
- -- use_type_clause.
+ -- use_type_clause. Note that we compare with the scope of
+ -- the operator and not Pack itself, lest Pack be a renaming.
+
+ Scop := Scope (Id);
if Nkind (Id) = N_Defining_Operator_Symbol
and then
- (Type_In_Use (Etype (Id), Pack)
- or else Type_In_Use (Etype (First_Formal (Id)), Pack)
+ (Type_In_Use (Etype (Id), Scop)
+ or else Type_In_Use (Etype (First_Formal (Id)), Scop)
or else
(Present (Next_Formal (First_Formal (Id)))
and then
Type_In_Use
- (Etype (Next_Formal (First_Formal (Id))), Pack)))
+ (Etype (Next_Formal (First_Formal (Id))), Scop)))
then
null;
else
--- /dev/null
+-- { dg-do compile }
+
+procedure Use_Type4 is
+
+ package P1 is
+ type T is new Integer;
+ function "and" (L, R : in Integer) return T;
+ end P1;
+
+ package body P1 is
+ function "and" (L, R : in Integer) return T is
+ begin
+ return T (L * R);
+ end "and";
+ end P1;
+
+ use type P1.T;
+
+ package Renaming renames P1;
+
+ package P2 is
+ use Renaming;
+ end P2;
+
+ G : P1.T := Integer'(1) and Integer'(2);
+
+begin
+ null;
+end;