https://gcc.gnu.org/g:422810aa9c9c6a43af786da31333c814042cd61c

commit r17-4428-g422810aa9c9c6a43af786da31333c814042cd61c
Author: Xavier Del Campo Romero <[email protected]>
Date:   Thu Sep 17 23:06:13 2026 +0200

    cobol: Print passing method on error
    
    Otherwise, under some circumstances an error message would be displayed
    to the developer where data types are in fact compatible (i.e., same
    signedness, same size, same type), but no information about the passing
    method, thus potentially causing confusion.
    
    gcc/cobol/ChangeLog:
    
            * parse.y: Print passing method on error.

Diff:
---
 gcc/cobol/parse.y | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y
index 8219342856d8..97795c4cdffa 100644
--- a/gcc/cobol/parse.y
+++ b/gcc/cobol/parse.y
@@ -13059,6 +13059,24 @@ bad_arg( const char name[],
   return ok;
 }  
 
+static const char *
+passby_str(int mask)
+{
+  switch( mask ) {
+  case by_default_e:
+  case by_reference_e:
+    return "BY REFERENCE";
+  case by_content_e:
+    return "BY CONTENT";
+  case by_value_e:
+    return "BY VALUE";
+  default:
+    break;
+  }
+
+  return "UNKNOWN PASSING METHOD";
+}
+
 // Verify provided actual parameters against formals.
 static void
 verify_args( const YYLTYPE& loc, 
@@ -13079,14 +13097,16 @@ verify_args( const YYLTYPE& loc,
      */
     if( ord < narg ) {
       if( ord < formals.size() ) {
-        error_msg( loc, "parameter %zu %qs (%s, capacity %u, %s) "
-                   "invalid for %qs parameter %qs (%s, capacity %u, %s)",
+        error_msg( loc, "parameter %zu %s %qs (%s, capacity %u, %s) "
+                   "invalid for %qs parameter %s %qs (%s, capacity %u, %s)",
                    1 + ord,
+                   passby_str(parg->crv),
                    nice_name_of(parg->field()),
                     cbl_field_type_name(parg->field()->type),
                     parg->field()->data.capacity(),
                     parg->field()->attr & signable_e ? "signed" : "unsigned",
                    name, 
+                   passby_str(formals[ord].crv),
                    nice_name_of(formals[ord].refer.field),
                    cbl_field_type_name(formals[ord].refer.field->type),
                    formals[ord].refer.field->data.capacity(),

Reply via email to