From 71d225bf68f1c5cf31b2e7fd5759b43f8dadc280 Mon Sep 17 00:00:00 2001 From: Robert Dubner Date: Mon, 3 Aug 2026 13:26:27 -0400 Subject: [PATCH] cobol: Repairs to structure creation. [PR119461] This PR is over a year old. The original observation that the record layout was done in odd ways has been addressed in the intervening months; these changes finalize those repairs. Some recursive references (where a structure contains a pointer to structures like itself) have been repaired (instead of using a placeholding "char *"). The use of ULONGLONG (a synonym for long_long_unsigned_type_node) has been replaced with UINT64 (for uint64_type_node) in order to reduce possible ambiguity. PR cobol/119461 gcc/cobol/ChangeLog: * genapi.cc (array_of_long_long): Renamed array_of_uint64(). (array_of_uint64): Likewise. (parser_compile_ecs): Use array_of_uint64(). (parser_compile_dcls): Likewise. (parser_file_add): Likewise. (gg_array_of_file_pointers): Use new cblc_file_pp_type_node; * gengen.cc (gg_get_structure_type_decl): Moved to structs.cc and renamed. * gengen.h (ULONGLONG): #define removed and replaced with UINT64. (UINT64): Likewise. (gg_get_structure_type_decl): Declaration removed. * structs.cc (create_structure_type): New function. (get_structure_type_decl): Renamed version of gg_get_structure_type_decl(). (create_cblc_field_t): Cleaned up structure creation. (create_referlet_t): Likewise. (create_refer_t): Likewise. (create_our_type_nodes): Likewise. * structs.h (GTY): New declaration for cblc_file_pp_type_node; * symbols.h (enum cbl_ctype_t): Removed. --- gcc/cobol/genapi.cc | 36 +++---- gcc/cobol/gengen.cc | 52 ---------- gcc/cobol/gengen.h | 6 +- gcc/cobol/structs.cc | 228 +++++++++++++++++++++++++++---------------- gcc/cobol/structs.h | 1 + gcc/cobol/symbols.h | 27 ----- 6 files changed, 166 insertions(+), 184 deletions(-) diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc index 5054a33e408..a0af3999129 100644 --- a/gcc/cobol/genapi.cc +++ b/gcc/cobol/genapi.cc @@ -885,7 +885,7 @@ parser_initialize_programs( size_t nprogs, } static tree -array_of_long_long(const char *name, +array_of_uint64(const char *name, const std::vector &vals) { /* @@ -899,14 +899,14 @@ array_of_long_long(const char *name, * ... * }; */ - tree const_ulonglong_type = - build_qualified_type( ULONGLONG, + tree const_uint64_type = + build_qualified_type( UINT64, TYPE_QUAL_CONST ); - tree array_of_ulonglong_type = - build_array_type_nelts( const_ulonglong_type, + tree array_of_uint64_type = + build_array_type_nelts( const_uint64_type, vals.size()+1 ); - tree array_of_ulonglong = - gg_define_variable( array_of_ulonglong_type, + tree array_of_uint64 = + gg_define_variable( array_of_uint64_type, name, vs_file_static ); vec *elts = NULL; @@ -916,17 +916,17 @@ array_of_long_long(const char *name, CONSTRUCTOR_APPEND_ELT( elts, bitsize_int( 0 ), - build_int_cstu( ULONGLONG, vals.size() ) ); + build_int_cstu( UINT64, vals.size() ) ); for( size_t i=0; i& ecs ) char ach[64]; static int counter = 1; sprintf(ach, "_ecs_table_%d", counter++); - tree retval = array_of_long_long(ach, ecs); + tree retval = array_of_uint64(ach, ecs); SHOW_IF_PARSE(nullptr) { SHOW_PARSE_HEADER @@ -1059,7 +1059,7 @@ parser_compile_dcls( const std::vector& dcls ) char ach[64]; static int counter = 1; sprintf(ach, "_dcls_table_%d", counter++); - tree retval = array_of_long_long(ach, dcls); + tree retval = array_of_uint64(ach, dcls); SHOW_IF_PARSE(nullptr) { SHOW_PARSE_HEADER @@ -9106,7 +9106,7 @@ parser_file_add(struct cbl_file_t *file) "__gg__file_init", gg_get_address_of(new_var_decl), gg_string_literal(file->name), - build_int_cst_type(ULONGLONG, symbol_table_index), + build_int_cst_type(UINT64, symbol_table_index), array_of_keys, key_numbers, unique_flags, @@ -12196,8 +12196,8 @@ static tree gg_array_of_file_pointers( size_t N, cbl_file_t **files ) { - tree retval = gg_define_variable(build_pointer_type(cblc_file_p_type_node)); - gg_assign(retval, gg_cast( build_pointer_type(cblc_file_p_type_node), + tree retval = gg_define_variable(cblc_file_pp_type_node); + gg_assign(retval, gg_cast( cblc_file_pp_type_node, gg_malloc( build_int_cst_type(SIZE_T, N * int_size_in_bytes(VOID_P))))); for(size_t i=0; i