Comments
Patch
===================================================================
@@ -3361,24 +3361,25 @@ package body Sem_Ch8 is
Id : Entity_Id;
Elmt : Elmt_Id;
- function Is_Primitive_Operator
+ function Is_Primitive_Operator_In_Use
(Op : Entity_Id;
F : Entity_Id) return Boolean;
-- Check whether Op is a primitive operator of a use-visible type
- ---------------------------
- -- Is_Primitive_Operator --
- ---------------------------
+ ----------------------------------
+ -- Is_Primitive_Operator_In_Use --
+ ----------------------------------
- function Is_Primitive_Operator
+ function Is_Primitive_Operator_In_Use
(Op : Entity_Id;
F : Entity_Id) return Boolean
is
T : constant Entity_Id := Etype (F);
begin
- return In_Use (T)
+ return (In_Use (T)
+ or else Present (Current_Use_Clause (Base_Type (T))))
and then Scope (T) = Scope (Op);
- end Is_Primitive_Operator;
+ end Is_Primitive_Operator_In_Use;
-- Start of processing for End_Use_Package
@@ -3409,11 +3410,12 @@ package body Sem_Ch8 is
if Nkind (Id) = N_Defining_Operator_Symbol
and then
- (Is_Primitive_Operator (Id, First_Formal (Id))
+ (Is_Primitive_Operator_In_Use
+ (Id, First_Formal (Id))
or else
(Present (Next_Formal (First_Formal (Id)))
and then
- Is_Primitive_Operator
+ Is_Primitive_Operator_In_Use
(Id, Next_Formal (First_Formal (Id)))))
then
null;
When leaving the scope of a use_package clause, there may be operators declared in the package that remain use visible because a prior use_type clause is still active. The following must compile quietly: with System.Storage_Elements; procedure P is use type System.Storage_Elements.Storage_Offset; procedure P1 (X : in out System.Address) is use System.Storage_Elements; begin X := X + 1; end P1; procedure P2 (X : in out System.Address) is begin X := X + 1; end P2; begin null; end P; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-10-18 Ed Schonberg <schonberg@adacore.com> * sem_ch8.adb (Is_Primitive_Operator_In_Use): Renamed from Is_Primitive_Operator. When ending the scope of a use package scope, a primitive operator remains in use if the base type has a current use (type) clause.