https://gcc.gnu.org/g:5feec11d51e96ec06ee2654c84dbf836e742da73

commit r16-7617-g5feec11d51e96ec06ee2654c84dbf836e742da73
Author: Jose E. Marchesi <[email protected]>
Date:   Sat Feb 21 21:36:19 2026 +0100

    a68: fix %%< and %%> marks in snprintf calls
    
    The function a68_mode_error_text computes a string that is then passed
    to a68_error or a68_warning.  The later functions feed the resulting
    string to the diagnostics machinery, which knows how to handle %< and
    %>, but the *printf calls don't.  Therefore the %s have to be escaped
    for %< and %> to be interpreted literally.
    
    Signed-off-by: Jose E. Marchesi <[email protected]>
    
            * a68-moids-diagnostics.cc (a68_mode_error_text): Properly escape
            %< and %> in snprintf calls.

Diff:
---
 gcc/algol68/a68-moids-diagnostics.cc | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/algol68/a68-moids-diagnostics.cc 
b/gcc/algol68/a68-moids-diagnostics.cc
index 180d7fb89a75..10ee4a774159 100644
--- a/gcc/algol68/a68-moids-diagnostics.cc
+++ b/gcc/algol68/a68-moids-diagnostics.cc
@@ -78,7 +78,7 @@ a68_mode_error_text (NODE_T *n, MOID_T *p, MOID_T *q, int 
context, int deflex, i
                              N++;
                              len = strlen (txt);
                            }
-                         if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, 
"%<%s%>",
+                         if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, 
"%%<%s%%>",
                                        a68_moid_to_string (MOID (u), 
MOID_ERROR_WIDTH, n)) < 0)
                            gcc_unreachable ();
                          N++;
@@ -96,7 +96,7 @@ a68_mode_error_text (NODE_T *n, MOID_T *p, MOID_T *q, int 
context, int deflex, i
                gcc_unreachable ();
              len = strlen (txt);
            }
-         if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, " cannot be coerced 
to %<%s%>",
+         if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, " cannot be coerced 
to %%<%s%%>",
                        a68_moid_to_string (q, MOID_ERROR_WIDTH, n)) < 0)
            gcc_unreachable ();
        }
@@ -137,7 +137,7 @@ a68_mode_error_text (NODE_T *n, MOID_T *p, MOID_T *q, int 
context, int deflex, i
                }
            }
          len = strlen (txt);
-         if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, " cannot be coerced 
to %<%s%>",
+         if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, " cannot be coerced 
to %%<%s%%>",
                        a68_moid_to_string (SLICE (SUB (q)), MOID_ERROR_WIDTH, 
n)) < 0)
            gcc_unreachable ();
        }
@@ -171,7 +171,7 @@ a68_mode_error_text (NODE_T *n, MOID_T *p, MOID_T *q, int 
context, int deflex, i
                            gcc_unreachable ();
                          len = strlen (txt);
                        }
-                     if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, "%<%s%>",
+                     if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, 
"%%<%s%%>",
                                    a68_moid_to_string (MOID (u), 
MOID_ERROR_WIDTH, n)) < 0)
                        gcc_unreachable ();
                    }
@@ -212,7 +212,7 @@ a68_mode_error_text (NODE_T *n, MOID_T *p, MOID_T *q, int 
context, int deflex, i
                            gcc_unreachable ();
                          len = strlen (txt);
                        }
-                     if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, "%<%s%> 
cannot be coerced to %<%s%>",
+                     if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, "%%<%s%%> 
cannot be coerced to %%<%s%%>",
                                    a68_moid_to_string (MOID (u), 
MOID_ERROR_WIDTH, n),
                                    a68_moid_to_string (MOID (v), 
MOID_ERROR_WIDTH, n)) < 0)
                        gcc_unreachable ();

Reply via email to