[multiple changes]
[gcc.git] / gcc / ada / ali.adb
index e00bc4646c3ab904b230527d9dfb090a484595a4..a004956cbfc56929c09c4efdc13bd3da03e5f7f7 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2008, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -119,14 +119,15 @@ package body ALI is
    --------------
 
    function Scan_ALI
-     (F             : File_Name_Type;
-      T             : Text_Buffer_Ptr;
-      Ignore_ED     : Boolean;
-      Err           : Boolean;
-      Read_Xref     : Boolean := False;
-      Read_Lines    : String  := "";
-      Ignore_Lines  : String  := "X";
-      Ignore_Errors : Boolean := False) return ALI_Id
+     (F                : File_Name_Type;
+      T                : Text_Buffer_Ptr;
+      Ignore_ED        : Boolean;
+      Err              : Boolean;
+      Read_Xref        : Boolean := False;
+      Read_Lines       : String  := "";
+      Ignore_Lines     : String  := "X";
+      Ignore_Errors    : Boolean := False;
+      Directly_Scanned : Boolean := False) return ALI_Id
    is
       P         : Text_Ptr := T'First;
       Line      : Logical_Line_Number := 1;
@@ -190,7 +191,7 @@ package body ALI is
 
       function Get_Name
         (Ignore_Spaces  : Boolean := False;
-         Ignore_Special : Boolean := False)return Name_Id;
+         Ignore_Special : Boolean := False) return Name_Id;
       --  Skip blanks, then scan out a name (name is left in Name_Buffer with
       --  length in Name_Len, as well as being returned in Name_Id form).
       --  If Lower is set to True then the Name_Buffer will be converted to
@@ -204,7 +205,7 @@ package body ALI is
       --
       --    If Ignore_Special is False (normal case), the scan is terminated by
       --    a typeref bracket or an equal sign except for the special case of
-      --    an operator name starting with a double quite which is terminated
+      --    an operator name starting with a double quote which is terminated
       --    by another double quote.
       --
       --  It is an error to set both Ignore_Spaces and Ignore_Special to True.
@@ -482,10 +483,9 @@ package body ALI is
          end if;
 
          loop
-            Name_Len := Name_Len + 1;
-            Name_Buffer (Name_Len) := Getc;
+            Add_Char_To_Name_Buffer (Getc);
 
-            exit when At_End_Of_Field and not Ignore_Spaces;
+            exit when At_End_Of_Field and then not Ignore_Spaces;
 
             if not Ignore_Special then
                if Name_Buffer (1) = '"' then
@@ -533,7 +533,7 @@ package body ALI is
       begin
          Skip_Space;
 
-         --  Check if we are on a number. In the case of bas ALI files, this
+         --  Check if we are on a number. In the case of bad ALI files, this
          --  may not be true.
 
          if not (Nextc in '0' .. '9') then
@@ -545,7 +545,7 @@ package body ALI is
             V := V * 10 + (Character'Pos (Getc) - Character'Pos ('0'));
 
             exit when At_End_Of_Field;
-            exit when Nextc < '0' or Nextc > '9';
+            exit when Nextc < '0' or else Nextc > '9';
          end loop;
 
          return V;
@@ -936,8 +936,7 @@ package body ALI is
 
             Name_Len := 0;
             while not At_Eol loop
-               Name_Len := Name_Len + 1;
-               Name_Buffer (Name_Len) := Getc;
+               Add_Char_To_Name_Buffer (Getc);
             end loop;
 
             --  If -fstack-check, record that it occurred
@@ -1417,6 +1416,7 @@ package body ALI is
             UL.First_Arg                := First_Arg;
             UL.Elab_Position            := 0;
             UL.SAL_Interface            := ALIs.Table (Id).SAL_Interface;
+            UL.Directly_Scanned         := Directly_Scanned;
             UL.Body_Needed_For_SAL      := False;
             UL.Elaborate_Body_Desirable := False;
             UL.Optimize_Alignment       := 'O';
@@ -1999,13 +1999,16 @@ package body ALI is
 
                if Nextc not in '0' .. '9' then
                   Name_Len := 0;
-
                   while not At_End_Of_Field loop
-                     Name_Len := Name_Len + 1;
-                     Name_Buffer (Name_Len) := Getc;
+                     Add_Char_To_Name_Buffer (Getc);
                   end loop;
 
-                  Sdep.Table (Sdep.Last).Subunit_Name := Name_Enter;
+                  --  Set the subunit name. Note that we use Name_Find rather
+                  --  than Name_Enter here as the subunit name may already
+                  --  have been put in the name table by the Project Manager.
+
+                  Sdep.Table (Sdep.Last).Subunit_Name := Name_Find;
+
                   Skip_Space;
                end if;
 
@@ -2018,8 +2021,7 @@ package body ALI is
                   Name_Len := 0;
 
                   while not At_End_Of_Field loop
-                     Name_Len := Name_Len + 1;
-                     Name_Buffer (Name_Len) := Getc;
+                     Add_Char_To_Name_Buffer (Getc);
                   end loop;
 
                   Sdep.Table (Sdep.Last).Rfile := Name_Enter;
@@ -2248,7 +2250,9 @@ package body ALI is
                            end;
 
                         --  Interfaces are stored in the list of references,
-                        --  although the parent type itself is stored in XE
+                        --  although the parent type itself is stored in XE.
+                        --  The first interface (when there are only
+                        --  interfaces) is stored in XE.Tref*)
 
                         elsif Ref = Tref_Derived
                           and then Typ = 'R'