[COMMITTED] a68: fix diagnostic in recover_from_error

Message ID 20260603102707.4087-1-jemarch@gnu.org
State Committed
Headers
Series [COMMITTED] a68: fix diagnostic in recover_from_error |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-aarch64-bootstrap fail Patch failed to apply
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-arm-bootstrap fail Patch failed to apply

Commit Message

Jose E. Marchesi June 3, 2026, 10:27 a.m. UTC
  The recover_from_error function calls a68_phrase_to_text in order to
get a descriptive text to emit in diagnostics.  This text, however,
may contain format tags such as %< and %>, so it has to be passed to
a68_error as a format string, therwise the format tags are not
interpreted and get printed verbatim.

Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>

gcc/algol68/ChangeLog

	* a68-parser-bottom-up.cc (recover_from_error): Use the output of
	a68_phrase_to_text as format string so format tags are honored.
---
 gcc/algol68/a68-parser-bottom-up.cc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gcc/algol68/a68-parser-bottom-up.cc b/gcc/algol68/a68-parser-bottom-up.cc
index 5cc0037ecc0..f3e5793283e 100644
--- a/gcc/algol68/a68-parser-bottom-up.cc
+++ b/gcc/algol68/a68-parser-bottom-up.cc
@@ -100,6 +100,8 @@ 
 #include "coretypes.h"
 #include "options.h"
 
+#include <string>
+
 #include "a68.h"
 #include "a68-pretty-print.h"
 
@@ -2836,8 +2838,10 @@  recover_from_error (NODE_T * p, enum a68_attribute expect, bool suppress)
 	}
       else
 	{
+	  std::string fmt = seq;
+	  fmt += " is an invalid %e";
 	  a68_attr_format_token a (expect);
-	  a68_error (w, "%s is an invalid %e", seq, &a);
+	  a68_error (w, fmt.c_str (), &a);
 	}
 
     if (ERROR_COUNT (&A68_JOB) >= MAX_ERRORS)