From 51a348dec6a10c8908a1519b30754b50c74d34f0 Mon Sep 17 00:00:00 2001
From: Bob Dubner <rdubner@symas.com>
Date: Mon, 1 Jan 2024 18:41:36 -0500
Subject: [PATCH] WIP: DOUBLE parameters

---
 gcc/cobol/genapi.cc | 41 ++++++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc
index 7021bbc7a419..6985c5298f5a 100644
--- a/gcc/cobol/genapi.cc
+++ b/gcc/cobol/genapi.cc
@@ -5390,18 +5390,10 @@ parser_division(cbl_division_t division,
     // returning is the stack-based operative variable; returning is the space
     // in static mamory used to actually return the value
     
-    if( returning && !returning->data_decl_node )
-      {
-      // This is the first time through
-      // treat returning as a local-storage variable:
-      returning->attr |= local_e;
-      returning->attr &= ~(linkage_e);
-      current_function->returning = returning;
-      }
-
     if( returning )
       {
       parser_local_add(returning);
+      current_function->returning = returning;
       }
 
     // Stash the returning variables for use during parser_return()
@@ -5434,8 +5426,20 @@ parser_division(cbl_division_t division,
       char ach[2*sizeof(cbl_name_t)];
       sprintf(ach, "_p_%s", args[i].refer.field->name);
 
-      size_t nchars = 0;
-      tree par_type = tree_type_from_field_type(args[i].refer.field, nchars);
+      size_t nbytes = 0;
+      tree par_type = tree_type_from_field_type(args[i].refer.field, nbytes);
+      if( par_type == FLOAT )
+        {
+        par_type = SSIZE_T;
+        }
+      if( par_type == DOUBLE )
+        {
+        par_type = SSIZE_T;
+        }
+      if( par_type == FLOAT128 )
+        {
+        par_type = INT128;
+        }
       chain_parameter_to_function(current_function->function_decl, par_type, ach);
       }
 
@@ -10794,7 +10798,7 @@ parser_call(   cbl_refer_t name,
         // We are doing float-to-float, and we require that those be identical
         // one the caller and callee sides.
         gg_memcpy(  returned_location,
-                    returned_value,
+                    gg_get_address_of(returned_value),
                     returned_length);
 
         TRACE1
@@ -13103,7 +13107,7 @@ move_helper(cbl_refer_t destref,
   if(     (sourceref.field->attr & (linkage_e | based_e))
       ||  (  destref.field->attr & (linkage_e | based_e)) )
     {
-    goto dont_be_clever;
+    //goto dont_be_clever;
     }
 
   if( !moved )
@@ -13726,22 +13730,15 @@ initial_from_float128(cbl_field_t *field, _Float128 value)
     case FldFloat:
       {
       retval = (char *)xmalloc(field->data.capacity);
-//      char ach[128];
       switch( field->data.capacity )
         {
         case 4:
-          // strfromf128(ach, sizeof(ach), "%.9E", value);
-          // *(_Float32 *)retval = strtof32(ach, NULL);
           *(_Float32 *)retval = (_Float32) value;
           break;
         case 8:
-          // strfromf128(ach, sizeof(ach), "%.14E", value);
-          // *(_Float64 *)retval = strtof64(ach, NULL);
           *(_Float64 *)retval = (_Float64) value;
           break;
         case 16:
-          // strfromf128(ach, sizeof(ach), "%.33E", value);
-          // *(_Float128 *)retval = strtof128(ach, NULL);
           *(_Float128 *)retval = (_Float128) value;
           break;
         }
@@ -14134,7 +14131,7 @@ parser_local_add(struct cbl_field_t *new_var )
 void
 parser_symbol_add(struct cbl_field_t *new_var )
   {
-  //fprintf(stderr, ">>>>>>> parser_symbol_add %s %s \n", cbl_field_type_str(new_var->type), new_var->name);
+  // fprintf(stderr, ">>>>>>> parser_symbol_add %s %s \n", cbl_field_type_str(new_var->type), new_var->name);
   // fprintf(stderr,
           // "parser_symbol_add %s %s",
           // new_var->name,
@@ -14265,6 +14262,8 @@ parser_symbol_add(struct cbl_field_t *new_var )
       case FldLiteralA:
       case FldNumericEdited:
       case FldAlphaEdited:
+
+      case FldFloat:
         figconst = normal_value_e;
         break;
       default:
-- 
GitLab