]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Cleanup detection of code within generic instances
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 7 Sep 2022 15:24:40 +0000 (17:24 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 7 Nov 2022 08:36:32 +0000 (09:36 +0100)
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.

gcc/ada/sem_ch13.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_warn.adb
gcc/ada/sinput.adb

index 2eb1a69e764af78f3bac37731e7fce67d17146bf..5507353136b604488992c3102044dbb30182ac3f 100644 (file)
@@ -9930,7 +9930,7 @@ package body Sem_Ch13 is
 
             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
index 90af32091e9e5b2a5e257ec0034042a168853c49..76dc632506079d5d14594d25369b98429e4f87ec 100644 (file)
@@ -16720,9 +16720,9 @@ package body Sem_Ch3 is
                        (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));
index 1bfa8449ad76803e6608459767a6f6b6e60fc366..a1a59a8857b06f20610c6228861df7b71f9ea9d4 100644 (file)
@@ -1720,7 +1720,6 @@ package body Sem_Warn is
             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
index 8e80213e314b9d6d46fffff252eae5f444294064..c96049b26782faecde6ec64ce4aa20e5cc89ef93 100644 (file)
@@ -620,7 +620,6 @@ package body Sinput is
    -------------------------
 
    function Instantiation_Depth (S : Source_Ptr) return Nat is
-      Sind  : Source_File_Index;
       Sval  : Source_Ptr;
       Depth : Nat;
 
@@ -629,8 +628,7 @@ package body Sinput is
       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;