This patch fixes a bug in which "gcc -gnatDGL" raises an unhandled
Constraint_Error in checks-on mode if the last line in the file is not
terminated with a line terminator.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

        * sprint.adb (Write_Source_Line): Check for EOF in
        Line_Terminator loop.  Note that when a source file is read in,
        an EOF character is added to the end.
diff --git a/gcc/ada/sprint.adb b/gcc/ada/sprint.adb
--- a/gcc/ada/sprint.adb
+++ b/gcc/ada/sprint.adb
@@ -4847,7 +4847,10 @@ package body Sprint is
          Write_Int (Int (L));
          Write_Str (": ");
 
-         while Src (Loc) not in Line_Terminator loop
+         --  We need to check for EOF here, in case the last line of the source
+         --  file does not have a Line_Terminator.
+
+         while Src (Loc) not in Line_Terminator | EOF loop
             Write_Char (Src (Loc));
             Loc := Loc + 1;
          end loop;


Reply via email to