From 9a361a66d7ba92bf42d7d87dd383cf018ed04a61 Mon Sep 17 00:00:00 2001
From: Bob Dubner <rdubner@symas.com>
Date: Wed, 27 Dec 2023 00:11:41 -0500
Subject: [PATCH] User-defined FUNCTION can return a group

---
 gcc/cobol/parse_ante.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gcc/cobol/parse_ante.h b/gcc/cobol/parse_ante.h
index 931748d7e0fc..223fb08f966d 100644
--- a/gcc/cobol/parse_ante.h
+++ b/gcc/cobol/parse_ante.h
@@ -1841,6 +1841,18 @@ static inline cbl_field_t *
 new_temporary_clone( const cbl_field_t *orig) {
   cbl_field_type_t type = is_literal(orig)? FldAlphanumeric : orig->type;
   auto f = new_temporary_imply(type);
+
+  // Dubner kludge
+  if( orig->type == FldGroup )
+    {
+    cbl_name_t tname;
+    memcpy(tname, f->name, sizeof(cbl_name_t));
+    memcpy(f, orig, sizeof(cbl_field_t));
+    memcpy(f->name, tname, sizeof(cbl_name_t));
+    f->attr = temporary_e;
+    f->var_decl_node = NULL;
+    f->data_decl_node = NULL;
+    }
   f->data = orig->data;
   parser_symbol_add(f);
   return f;
-- 
GitLab