[gcc r17-2475] cobol: Repair mh_identical MOVEs involving DEBUG registers [PR126277]

Robert Dubner via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:8a5e08f24b9f28dd240344a4c637efb06be024da

commit r17-2475-g8a5e08f24b9f28dd240344a4c637efb06be024da
Author: Robert Dubner <[email protected]>
Date:   Thu Jul 16 16:23:37 2026 -0400

    cobol: Repair mh_identical MOVEs involving DEBUG registers [PR126277]
    
    The mh_identical MOVE routine was flummoxed by the DEBUG-XXX registers that
    are children of DEBUG-ITEM.  These changes repair that problem.
    
            PR cobol/126277
    
    gcc/cobol/ChangeLog:
    
            * move.cc (mh_identical): Handle externals that have parents.
            (mh_binary_to_packed): Eliminate trailing whitespace.
            * symbols.cc (symbol_table_init): Correct attributes of DEBUG-CONTENTS.
    
    libgcobol/ChangeLog:
    
            * constants.cc (struct cblc_field_t): Adjust initialization of
            DEBUG-ITEM fields.

Diff:
---
 gcc/cobol/move.cc      | 20 ++++++++++++++++++--
 gcc/cobol/symbols.cc   |  2 +-
 libgcobol/constants.cc | 40 ++++++++++++++++++++++++++--------------
 3 files changed, 45 insertions(+), 17 deletions(-)

diff --git a/gcc/cobol/move.cc b/gcc/cobol/move.cc
index d50d369b5497..6f1479074442 100644
--- a/gcc/cobol/move.cc
+++ b/gcc/cobol/move.cc
@@ -177,8 +177,24 @@ mh_identical(const cbl_refer_t &destref,
       &&  destref.field->codeset.encoding == sourceref.field->codeset.encoding
       )
     {
+    // These next tests were added because of the DEBUG- registers, which are
+    // global external, and most of which have a parent.  It turns out that
+    // get_location gets flummoxed by that, so we divert it here to the library
+    if(   sourceref.field->parent
+       && sourceref.field->data_decl_node
+       && DECL_EXTERNAL(sourceref.field->data_decl_node) )
+      {
+      return false;
+      }
+    if(   destref.field->parent
+       && destref.field->data_decl_node
+       && DECL_EXTERNAL(destref.field->data_decl_node) )
+      {
+      return false;
+      }
+
     // The source and destination are identical in type and the
-    // Source doesn't have a depending_on clause
+    // source doesn't have a depending_on clause
     SHOW_PARSE1
       {
       SHOW_PARSE_INDENT
@@ -1684,7 +1700,7 @@ mh_binary_to_packed(const cbl_refer_t &destref,
       }
 
     // We are now ready to convert the binary to the packed byte string.
-    
+
     int ndigits;
     if( !(destref.field->attr & packed_no_sign_e) )
       {
diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc
index 56dbf066145c..da0ca7448ea5 100644
--- a/gcc/cobol/symbols.cc
+++ b/gcc/cobol/symbols.cc
@@ -2479,7 +2479,7 @@ symbol_table_init(void) {
       {5,5,4,0, NULL},     2, "DEBUG-SUB-3", cp1252 },
     { FldAlphanumeric, register_e | filler_e,
       {1,1,0,0, " "},      2, "FILLER", cp1252 },
-    { FldAlphanumeric, signable_e | register_e,
+    { FldAlphanumeric, register_e,
       {76,76,0,0, NULL},   2, "DEBUG-CONTENTS", cp1252 },
   };
 
diff --git a/libgcobol/constants.cc b/libgcobol/constants.cc
index 8be304cb5f27..68d9e091bae0 100644
--- a/libgcobol/constants.cc
+++ b/libgcobol/constants.cc
@@ -422,13 +422,13 @@ struct cblc_field_t __ggsr__argi = {
         02 DEBUG-CONTENTS PIC X(76).
 */
 
-unsigned char __gg__debug_item_data[132] = 
+unsigned char __gg__data_debug_item[132] =
                                  "                                      "
                                  "+0000 +0000 +0000 "
                                  "                                      "
                                  "                                     ";
 struct cblc_field_t __ggsr__debug_item = {
-  .data           = __gg__debug_item_data ,
+  .data           = __gg__data_debug_item ,
   .capacity       = 132 ,
   .allocated      = 132 ,
   .offset         = 0 ,
@@ -450,8 +450,9 @@ struct cblc_field_t __ggsr__debug_item = {
   .alphabet       = 0 ,
   };
 
+unsigned char *__gg__data_debug_line = __gg__data_debug_item;
 struct cblc_field_t __ggsr__debug_line = {
-  .data           = __gg__debug_item_data + 0 ,
+  .data           = __gg__data_debug_line ,
   .capacity       = 6 ,
   .allocated      = 6 ,
   .offset         = 0 ,
@@ -470,8 +471,10 @@ struct cblc_field_t __ggsr__debug_line = {
   .alphabet       = 0 ,
   };
 
+
+unsigned char *__gg__data_debug_filler_1 = &__gg__data_debug_item[6];
 struct cblc_field_t __ggsr__debug_filler_1 = {
-  .data           = __gg__debug_item_data + 6 ,
+  .data           = __gg__data_debug_item ,
   .capacity       = 1 ,
   .allocated      = 1 ,
   .offset         = 6 ,
@@ -490,8 +493,9 @@ struct cblc_field_t __ggsr__debug_filler_1 = {
   .alphabet       = 0 ,
   };
 
+unsigned char *__gg__data_debug_name = &__gg__data_debug_item[7];
 struct cblc_field_t __ggsr__debug_name = {
-  .data           = __gg__debug_item_data + 7 ,
+  .data           = __gg__data_debug_name ,
   .capacity       = 30 ,
   .allocated      = 30 ,
   .offset         = 7 ,
@@ -510,8 +514,9 @@ struct cblc_field_t __ggsr__debug_name = {
   .alphabet       = 0 ,
   };
 
+unsigned char *__gg__data_debug_filler_2 = &__gg__data_debug_item[37];
 struct cblc_field_t __ggsr__debug_filler_2 = {
-  .data           = __gg__debug_item_data + 37 ,
+  .data           = __gg__data_debug_filler_2 ,
   .capacity       = 1 ,
   .allocated      = 1 ,
   .offset         = 37 ,
@@ -530,8 +535,9 @@ struct cblc_field_t __ggsr__debug_filler_2 = {
   .alphabet       = 0 ,
   };
 
+unsigned char *__gg__data_debug_sub_1 = &__gg__data_debug_item[38];
 struct cblc_field_t __ggsr__debug_sub_1 = {
-  .data           = __gg__debug_item_data + 38 ,
+  .data           = __gg__data_debug_sub_1 ,
   .capacity       = 5 ,
   .allocated      = 5 ,
   .offset         = 38 ,
@@ -550,8 +556,9 @@ struct cblc_field_t __ggsr__debug_sub_1 = {
   .alphabet       = 0 ,
   };
 
+unsigned char *__gg__data_debug_filler_3 = &__gg__data_debug_item[43];
 struct cblc_field_t __ggsr__debug_filler_3 = {
-  .data           = __gg__debug_item_data + 43,
+  .data           = __gg__data_debug_filler_3 ,
   .capacity       =  1,
   .allocated      =  1,
   .offset         =  43,
@@ -570,8 +577,9 @@ struct cblc_field_t __ggsr__debug_filler_3 = {
   .alphabet       = 0 ,
   };
 
+unsigned char *__gg__data_debug_sub_2 = &__gg__data_debug_item[44];
 struct cblc_field_t __ggsr__debug_sub_2 = {
-  .data           = __gg__debug_item_data + 44 ,
+  .data           = __gg__data_debug_sub_2 ,
   .capacity       = 5 ,
   .allocated      = 5 ,
   .offset         = 44 ,
@@ -590,8 +598,9 @@ struct cblc_field_t __ggsr__debug_sub_2 = {
   .alphabet       = 0 ,
   };
 
+unsigned char *__gg__data_debug_filler_4 = &__gg__data_debug_item[49];
 struct cblc_field_t __ggsr__debug_filler_4 = {
-  .data           = __gg__debug_item_data +  49,
+  .data           = __gg__data_debug_filler_4 ,
   .capacity       =  1,
   .allocated      =  1,
   .offset         =  49,
@@ -610,8 +619,9 @@ struct cblc_field_t __ggsr__debug_filler_4 = {
   .alphabet       = 0 ,
   };
 
+unsigned char *__gg__data_debug_sub_3 = &__gg__data_debug_item[50];
 struct cblc_field_t __ggsr__debug_sub_3 = {
-  .data           = __gg__debug_item_data + 50 ,
+  .data           = __gg__data_debug_sub_3 ,
   .capacity       = 5 ,
   .allocated      = 5 ,
   .offset         = 50 ,
@@ -630,8 +640,9 @@ struct cblc_field_t __ggsr__debug_sub_3 = {
   .alphabet       = 0 ,
   };
 
+unsigned char *__gg__data_debug_filler_5 = &__gg__data_debug_item[55];
 struct cblc_field_t __ggsr__debug_filler_5 = {
-  .data           = __gg__debug_item_data + 55,
+  .data           = __gg__data_debug_filler_5 ,
   .capacity       =  1,
   .allocated      =  1,
   .offset         =  55,
@@ -650,8 +661,9 @@ struct cblc_field_t __ggsr__debug_filler_5 = {
   .alphabet       = 0 ,
   };
 
+unsigned char *__gg__data_debug_contents = &__gg__data_debug_item[56];
 struct cblc_field_t __ggsr__debug_contents = {
-  .data           = __gg__debug_item_data + 56 ,
+  .data           = __gg__data_debug_contents ,
   .capacity       = 76 ,
   .allocated      = 76 ,
   .offset         = 56 ,
@@ -661,7 +673,7 @@ struct cblc_field_t __ggsr__debug_contents = {
   .parent         = &__ggsr__debug_item ,
   .occurs_lower   = 0 ,
   .occurs_upper   = 0 ,
-  .attr           = signable_e | register_e | leading_e | separate_e ,
+  .attr           = register_e ,
   .type           = FldAlphanumeric ,
   .level          = 05 ,
   .digits         = 0 ,
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.