To check if a node is located in a generic instance we can either look
at Instantiation_Location or at the Instantiation_Depth, but just
looking at the location is simpler and more efficient.
Cleanup related to improved detection of references to uninitialized
objects; semantics is unaffected.
gcc/ada/
* sem_ch13.adb (Add_Call): Just look at Instantiation_Depth.
* sem_ch3.adb (Derive_Subprograms): Likewise.
* sem_warn.adb (Check_References): Remove redundant filtering with
Instantiation_Depth that follows filtering with
Instantiation_Location.
* sinput.adb (Instantiation_Depth): Reuse Instantiation_Location.
if Opt.List_Inherited_Aspects
and then not Is_Generic_Actual_Type (Typ)
- and then Instantiation_Depth (Sloc (Typ)) = 0
+ and then Instantiation_Location (Sloc (Typ)) = No_Location
and then not Is_Internal_Name (Chars (T))
and then not Is_Internal_Name (Chars (Typ))
then
(Is_Generic_Unit
(Scope (Find_Dispatching_Type (Alias_Subp)))
or else
- Instantiation_Depth
- (Sloc (Find_Dispatching_Type (Alias_Subp))) > 0);
-
+ Instantiation_Location
+ (Sloc (Find_Dispatching_Type (Alias_Subp)))
+ /= No_Location);
declare
Iface_Prim_Loc : constant Source_Ptr :=
Original_Location (Sloc (Alias_Subp));
elsif Is_Generic_Subprogram (E1)
and then not Is_Instantiated (E1)
and then not Publicly_Referenceable (E1)
- and then Instantiation_Depth (Sloc (E1)) = 0
and then Warn_On_Redundant_Constructs
then
if not Warnings_Off_E1 and then not Has_Junk_Name (E1) then
-------------------------
function Instantiation_Depth (S : Source_Ptr) return Nat is
- Sind : Source_File_Index;
Sval : Source_Ptr;
Depth : Nat;
Depth := 0;
loop
- Sind := Get_Source_File_Index (Sval);
- Sval := Instantiation (Sind);
+ Sval := Instantiation_Location (Sval);
exit when Sval = No_Location;
Depth := Depth + 1;
end loop;