https://gcc.gnu.org/g:09626b3d0d5a380f94037cd2c4db23f21711302d

commit r17-4429-g09626b3d0d5a380f94037cd2c4db23f21711302d
Author: Xavier Del Campo Romero <[email protected]>
Date:   Thu Sep 17 23:08:01 2026 +0200

    cobol: Fix wrong diagnostic on numeric literals
    
    For some reason, $1->data.initial expanded to a whitespace (i.e., " ")
    rather than the expected numeric literal (e.g.: "18").
    
    Before:
    
    num-reference.cbl:4:42: error: cannot pass ‘ ’ BY REFERENCE [-Wcall-literal]
    4 |           call "prog" using by reference 0.
      |                                          ^~
    num-reference.cbl:4:42: error: ‘BY CONTENT expression’ requires ‘-dialect 
ibm or mf or gnu’ [-Wcontent-expr]
    
    Now:
    
    num-reference.cbl:4:42: error: cannot pass ‘0’ BY REFERENCE [-Wcall-literal]
    4 |           call "prog" using by reference 0.
      |                                          ^~
    num-reference.cbl:4:42: error: ‘BY CONTENT expression’ requires ‘-dialect 
ibm or mf or gnu’ [-Wcontent-expr]
    
    gcc/cobol/ChangeLog:
    
            * parse.y: Fix wrong diagnostic on numeric literals.

Diff:
---
 gcc/cobol/parse.y | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y
index 97795c4cdffa..8e6b0d9a28b3 100644
--- a/gcc/cobol/parse.y
+++ b/gcc/cobol/parse.y
@@ -10907,7 +10907,8 @@ ffi_by_ref:     scalar_arg[refer]
         |       num_literal
                 {
                   cbl_message(@1, MfCallLiteral,
-                              "cannot pass %qs BY REFERENCE", 
$1->data.initial);
+                              "cannot pass %qs BY REFERENCE",
+                              $1->data.original());
                   cbl_refer_t *r = new_reference($1);
                   $$ = new cbl_ffi_arg_t(by_content_e, r);
                 }

Reply via email to