[gcc r16-9333] a68: fix diagnostic in recover_from_error

"Jose E. Marchesi via Gcc-cvs" <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:57d58427aa7916a71fd3a2596ef5dd88ef64b8de

commit r16-9333-g57d58427aa7916a71fd3a2596ef5dd88ef64b8de
Author: Jose E. Marchesi <[email protected]>
Date:   Wed Jun 3 12:00:21 2026 +0200

    a68: fix diagnostic in recover_from_error
    
    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 <[email protected]>
    
    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.
    
    (cherry picked from commit 290221e86a32369f66a8ac089bd8430e45efe9f4)

Diff:
---
 gcc/algol68/a68-parser-bottom-up.cc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/algol68/a68-parser-bottom-up.cc b/gcc/algol68/a68-parser-bottom-up.cc
index 5cc0037ecc0e..f3e5793283ef 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)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.