]> gcc.gnu.org Git - gcc.git/commitdiff
lib-xref-alfa.adb (Generate_Dereference): Use Get_Code_Unit instead of Get_Source_Uni...
authorYannick Moy <moy@adacore.com>
Fri, 30 Mar 2012 09:24:09 +0000 (09:24 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 30 Mar 2012 09:24:09 +0000 (11:24 +0200)
2012-03-30  Yannick Moy  <moy@adacore.com>

* lib-xref-alfa.adb (Generate_Dereference): Use Get_Code_Unit
instead of Get_Source_Unit to get file for reference.
(Traverse_Compilation_Unit): Do not add scopes for generic units.
* lib-xref.adb (Generate_Reference): Use Get_Code_Unit instead
of Get_Source_Unit to get file for reference.
* sem_ch12.adb (Analyze_Package_Instantiation): Enable
instantiation in Alfa mode.

From-SVN: r186002

gcc/ada/ChangeLog
gcc/ada/lib-xref-alfa.adb
gcc/ada/lib-xref.adb
gcc/ada/sem_ch12.adb

index 450239a6b0182cec94f4f3cf84325afedc902540..0be106c724c369048bc5e6ea3961e3336cbab15e 100644 (file)
@@ -1,3 +1,13 @@
+2012-03-30  Yannick Moy  <moy@adacore.com>
+
+       * lib-xref-alfa.adb (Generate_Dereference): Use Get_Code_Unit
+       instead of Get_Source_Unit to get file for reference.
+       (Traverse_Compilation_Unit): Do not add scopes for generic units.
+       * lib-xref.adb (Generate_Reference): Use Get_Code_Unit instead
+       of Get_Source_Unit to get file for reference.
+       * sem_ch12.adb (Analyze_Package_Instantiation): Enable
+       instantiation in Alfa mode.
+
 2012-03-30  Hristian Kirtchev  <kirtchev@adacore.com>
 
        * exp_ch7.adb (Process_Declarations): Replace
index f454463e7c3cd2ca718b3a0f2c880382b70280d8..5903879ba07ef5c6bf452e77f63bc25f9102bf4e 100644 (file)
@@ -1051,15 +1051,13 @@ package body Alfa is
 
       Loc       : constant Source_Ptr := Sloc (N);
       Index     : Nat;
-      Ref       : Source_Ptr;
       Ref_Scope : Entity_Id;
 
    --  Start of processing for Generate_Dereference
 
    begin
-      Ref := Original_Location (Loc);
 
-      if Ref > No_Location then
+      if Loc > No_Location then
          Drefs.Increment_Last;
          Index := Drefs.Last;
 
@@ -1075,21 +1073,21 @@ package body Alfa is
             Ref_Scope := Enclosing_Subprogram_Or_Package (N);
 
             Deref.Ent := Heap;
-            Deref.Loc := Ref;
+            Deref.Loc := Loc;
             Deref.Typ := Typ;
 
             --  It is as if the special "Heap" was defined in every scope where
             --  it is referenced.
 
-            Deref.Eun := Get_Source_Unit (Ref);
-            Deref.Lun := Get_Source_Unit (Ref);
+            Deref.Eun := Get_Code_Unit (Loc);
+            Deref.Lun := Get_Code_Unit (Loc);
 
             Deref.Ref_Scope := Ref_Scope;
             Deref.Ent_Scope := Ref_Scope;
 
             Deref_Entry.Def := No_Location;
 
-            Deref_Entry.Ent_Scope_File := Get_Source_Unit (Ref_Scope);
+            Deref_Entry.Ent_Scope_File := Get_Code_Unit (N);
          end;
       end if;
    end Generate_Dereference;
@@ -1125,6 +1123,14 @@ package body Alfa is
          Lu := Proper_Body (Lu);
       end if;
 
+      --  Do not add scopes for generic units
+
+      if Nkind (Lu) = N_Package_Body
+        and then Ekind (Corresponding_Spec (Lu)) in Generic_Unit_Kind
+      then
+         return;
+      end if;
+
       --  Call Process on all declarations
 
       if Nkind (Lu) in N_Declaration
index d02420b216ad729aa0f0a79103453114ef389c74..a328bea9d01ef2dc0074b9231c06dbaa99bad081 100644 (file)
@@ -378,7 +378,6 @@ package body Lib.Xref is
       Def            : Source_Ptr;
       Ent            : Entity_Id;
       Ent_Scope      : Entity_Id;
-      Ent_Scope_File : Unit_Number_Type;
       Formal         : Entity_Id;
       Kind           : Entity_Kind;
       Nod            : Node_Id;
@@ -633,6 +632,16 @@ package body Lib.Xref is
            or else Typ = 'i'
            or else Typ = 'k'
            or else (Typ = 'b' and then Is_Generic_Instance (E))
+
+            --  Allow the generation of references to reads, writes and calls
+            --  in Alfa mode when the related context comes from an instance.
+
+           or else
+             (Alfa_Mode
+                and then In_Extended_Main_Code_Unit (N)
+                and then (Typ = 'm'
+                            or else Typ = 'r'
+                            or else Typ = 's'))
          then
             null;
          else
@@ -880,11 +889,12 @@ package body Lib.Xref is
 
          --  Ignore references from within an instance. The only exceptions to
          --  this are default subprograms, for which we generate an implicit
-         --  reference.
+         --  reference and compilations in Alfa_Mode.
 
          and then
            (Instantiation_Location (Sloc (N)) = No_Location
-              or else Typ = 'i')
+              or else Typ = 'i'
+              or else Alfa_Mode)
 
          --  Ignore dummy references
 
@@ -995,9 +1005,6 @@ package body Lib.Xref is
 
          --  Record reference to entity
 
-         Ref := Original_Location (Sloc (Nod));
-         Def := Original_Location (Sloc (Ent));
-
          if Actual_Typ = 'p'
            and then Is_Subprogram (Nod)
            and then Present (Overridden_Operation (Nod))
@@ -1006,6 +1013,9 @@ package body Lib.Xref is
          end if;
 
          if Alfa_Mode then
+            Ref := Sloc (Nod);
+            Def := Sloc (Ent);
+
             Ref_Scope := Alfa.Enclosing_Subprogram_Or_Package (Nod);
             Ent_Scope := Alfa.Enclosing_Subprogram_Or_Package (Ent);
 
@@ -1018,22 +1028,30 @@ package body Lib.Xref is
                return;
             end if;
 
-            Ent_Scope_File := Get_Source_Unit (Ent_Scope);
+            Add_Entry
+              ((Ent      => Ent,
+                Loc       => Ref,
+                Typ       => Actual_Typ,
+                Eun       => Get_Code_Unit (Def),
+                Lun       => Get_Code_Unit (Ref),
+                Ref_Scope => Ref_Scope,
+                Ent_Scope => Ent_Scope),
+               Ent_Scope_File => Get_Code_Unit (Ent));
+
          else
-            Ref_Scope := Empty;
-            Ent_Scope := Empty;
-            Ent_Scope_File := No_Unit;
+            Ref := Original_Location (Sloc (Nod));
+            Def := Original_Location (Sloc (Ent));
+
+            Add_Entry
+              ((Ent      => Ent,
+                Loc       => Ref,
+                Typ       => Actual_Typ,
+                Eun       => Get_Source_Unit (Def),
+                Lun       => Get_Source_Unit (Ref),
+                Ref_Scope => Empty,
+                Ent_Scope => Empty),
+               Ent_Scope_File => No_Unit);
          end if;
-
-         Add_Entry
-           ((Ent => Ent,
-             Loc => Ref,
-             Typ => Actual_Typ,
-             Eun => Get_Source_Unit (Def),
-             Lun => Get_Source_Unit (Ref),
-             Ref_Scope => Ref_Scope,
-             Ent_Scope => Ent_Scope),
-            Ent_Scope_File => Ent_Scope_File);
       end if;
    end Generate_Reference;
 
index 054772964ef6a3f3ccea43ba595de4cb2999fbf4..159594fe6ddcc80d9a66786892f6f1ca6f230b21 100644 (file)
@@ -3704,7 +3704,6 @@ package body Sem_Ch12 is
                            or else Might_Inline_Subp)
                 and then not Is_Actual_Pack
                 and then not Inline_Now
-                and then not Alfa_Mode
                 and then (Operating_Mode = Generate_Code
                            or else (Operating_Mode = Check_Semantics
                                      and then ASIS_Mode));
This page took 0.079486 seconds and 5 git commands to generate.