[COMMITTED] ada: Fix parsing bug in GNAT.Formatted_String

Message ID 20230103093612.76819-1-poulhies@adacore.com
State Unresolved
Headers
Series [COMMITTED] ada: Fix parsing bug in GNAT.Formatted_String |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Marc Poulhiès Jan. 3, 2023, 9:36 a.m. UTC
  From: Ronan Desplanques <desplanques@adacore.com>

Before this patch, GNAT.Formatted_String.Formatted_String failed to
handle format strings with two or more specifiers whose widths were
specified with the "*" syntax. This patch makes the parser
correctly reset its bits of state related to width and precision
parsing when needed.

gcc/ada/

	* libgnat/g-forstr.adb (P_Int_Format): Fix parsing bug.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/libgnat/g-forstr.adb | 1 +
 1 file changed, 1 insertion(+)
  

Patch

diff --git a/gcc/ada/libgnat/g-forstr.adb b/gcc/ada/libgnat/g-forstr.adb
index 8353e2c4ad8..c9fb86b44f7 100644
--- a/gcc/ada/libgnat/g-forstr.adb
+++ b/gcc/ada/libgnat/g-forstr.adb
@@ -808,6 +808,7 @@  package body GNAT.Formatted_String is
          Format.D.Index := Start;
          return Format;
       end if;
+      Format.D.Stored_Value := 0;
 
       case F.Kind is
          when Unsigned_Octal =>