ali.ads, ali.adb (Get_Nat): Raise an exception if the file cursor is not on a natural.
authorQuentin Ochem <ochem@adacore.com>
Fri, 6 Apr 2007 09:17:01 +0000 (11:17 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 6 Apr 2007 09:17:01 +0000 (11:17 +0200)
2007-04-06  Quentin Ochem  <ochem@adacore.com>

* ali.ads, ali.adb (Get_Nat): Raise an exception if the file cursor is
not on a natural.
(Scan_ALI): Cancel the xref line if there has been a reading ALI error.

From-SVN: r123548

gcc/ada/ali.adb
gcc/ada/ali.ads

index 81008c8217494a9828947b00c66358da0a7d543f..b987636ac7bbdb3bd75de108985b87bdf22d0c4c 100644 (file)
@@ -195,6 +195,7 @@ package body ALI is
 
       function Get_Nat return Nat;
       --  Skip blanks, then scan out an unsigned integer value in Nat range
+      --  raises ALI_Reading_Error if the encoutered type is not natural.
 
       function Get_Stamp return Time_Stamp_Type;
       --  Skip blanks, then scan out a time stamp
@@ -347,7 +348,6 @@ package body ALI is
          --  Find start of line
 
          Ptr1 := P;
-
          while Ptr1 > T'First
            and then T (Ptr1 - 1) /= CR
            and then T (Ptr1 - 1) /= LF
@@ -478,9 +478,17 @@ package body ALI is
       begin
          Skip_Space;
 
+         --  Check if we are on a number. In the case of bas ALI files, this
+         --  may not be true.
+
+         if not (Nextc in '0' .. '9') then
+            Fatal_Error;
+         end if;
+
          V := 0;
          loop
             V := V * 10 + (Character'Pos (Getc) - Character'Pos ('0'));
+
             exit when At_End_Of_Field;
             exit when Nextc < '0' or Nextc > '9';
          end loop;
@@ -2186,6 +2194,24 @@ package body ALI is
 
                   XE.Last_Xref := Xref.Last;
                   C := Nextc;
+
+               exception
+                  when Bad_ALI_Format =>
+
+                     --  If ignoring errors, then we skip a line with an
+                     --  unexpected error, and try to continue subsequent
+                     --  xref lines.
+
+                     if Ignore_Errors then
+                        Xref_Entity.Decrement_Last;
+                        Skip_Line;
+                        C := Nextc;
+
+                     --  Otherwise, we reraise the fatal exception
+
+                     else
+                        raise;
+                     end if;
                end Read_Refs_For_One_Entity;
             end loop;
 
@@ -2209,7 +2235,6 @@ package body ALI is
    exception
       when Bad_ALI_Format =>
          return No_ALI_Id;
-
    end Scan_ALI;
 
    ---------
index 7d702b7248460eb039b5e53bd45512cc57f8f189..5a4dcaae38a90e575931f680f3d20dded752d46e 100644 (file)
@@ -839,7 +839,7 @@ package ALI is
       --  reference for the entity name.
 
       Oref_File_Num : Sdep_Id;
-      --  This field is set to No_Sdep_Id is the entity doesn't override any
+      --  This field is set to No_Sdep_Id if the entity doesn't override any
       --  other entity, or to the dependency reference for the overriden
       --  entity.