]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Issue a proper error message when no format specifier found
authorPascal Obry <obry@adacore.com>
Thu, 16 Sep 2021 17:10:39 +0000 (19:10 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 5 Oct 2021 08:20:05 +0000 (08:20 +0000)
gcc/ada/

* libgnat/g-forstr.adb (Next_Format): When there is no more
format specifier found issue a proper error message instead of
raising a contraint error.

gcc/ada/libgnat/g-forstr.adb

index d6596126a8d97a2c2fda8e1507732bb46662ab9d..04539be026c6b2d2db5ed416f67f441078026438 100644 (file)
@@ -519,7 +519,7 @@ package body GNAT.Formatted_String is
          J := J + 1;
       end loop;
 
-      if F (J) /= '%' or else J = F'Last then
+      if J >= F'Last or else F (J) /= '%'  then
          raise Format_Error with "no format specifier found for parameter"
            & Positive'Image (Format.D.Current);
       end if;