From e5d57b64a33bcba270821b6bff05b31a0568b101 Mon Sep 17 00:00:00 2001
From: Bob Dubner <rdubner@symas.com>
Date: Wed, 20 Dec 2023 11:33:27 -0500
Subject: [PATCH] CALL ... USING ... BY CONTENT can now call a function
 receiving ANY LENGTH variables

---
 gcc/cobol/genapi.cc | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc
index e179a260c4ef..a5f0c313ce28 100644
--- a/gcc/cobol/genapi.cc
+++ b/gcc/cobol/genapi.cc
@@ -10771,9 +10771,9 @@ parser_call(   cbl_refer_t name,
           arguments[i] = location;
           //gg_printf(">>>>>Calling %ld location is %p\n", build_int_cst_type(SIZE_T, i), arguments[i], NULL_TREE);
 
-          // BY REFERENCE variables might -- might! -- be going into an ANY LENGTH
+          // BY REFERENCE variables might be going into an ANY LENGTH
           // linkage variable in the called program.  So, just in case, we need
-          // to provide  a length through the global table.
+          // to provide a length through the global table.
           gg_assign(gg_array_value(var_decl_call_parameter_lengths, i), length);
           break;
           }
@@ -10791,6 +10791,11 @@ parser_call(   cbl_refer_t name,
           gg_memcpy(arguments[i], location, length);
 
           //gg_printf(">>>>>Calling %ld location is %p\n", build_int_cst_type(SIZE_T, i), arguments[i], NULL_TREE);
+
+          // BY CONTENT variables might be going into an ANY LENGTH
+          // linkage variable in the called program.  So, just in case, we need
+          // to provide a length through the global table.
+          gg_assign(gg_array_value(var_decl_call_parameter_lengths, i), length);
           break;
           }
 
-- 
GitLab