]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Make "gcc -gnatDGL" handle unterminated last lines properly
authorBob Duff <duff@adacore.com>
Mon, 22 Mar 2021 20:22:49 +0000 (16:22 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 18 Jun 2021 08:36:53 +0000 (04:36 -0400)
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.

gcc/ada/sprint.adb

index 5f2d027dfaf9752acc0c54dc3321b48b9b2a2cf4..7fc73409d1a6b0a73483fd691c908a74a129b717 100644 (file)
@@ -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;