diff --git a/gcc/cobol/ChangeLog b/gcc/cobol/ChangeLog index b7b8d38a61e9df95fd957854e41316ffd455d168..fa847acd8647c5a40e1475ba8ca7af1dab144b34 100644 --- a/gcc/cobol/ChangeLog +++ b/gcc/cobol/ChangeLog @@ -66,5 +66,6 @@ * Normalize #includes in symbols.h.cc 2024-12-25 Robert Dubner <rdubner@symas.com> - * Use built_in versions of memcpy - + * Use built_in version of memcpy + * Use built_in version of malloc; required initialization + during lang_hook_init diff --git a/gcc/cobol/gengen.cc b/gcc/cobol/gengen.cc index ff64f17dcac2ff2317cdd9db57b404527e77a410..90d9a534096819c077e363fddc81b1714bbda8c1 100644 --- a/gcc/cobol/gengen.cc +++ b/gcc/cobol/gengen.cc @@ -109,6 +109,7 @@ static int sv_current_line_number; // These are globally useful constants tree char_nodes[256]; +tree pvoid_type_node; tree integer_minusone_node; tree integer_two_node; tree integer_eight_node; @@ -397,6 +398,14 @@ show_type(tree type) (TYPE_UNSIGNED(type) ? "unsigned" : " signed")); break; + case FUNCTION_TYPE: + sprintf(ach, "FUNCTION"); +// sprintf(ach, +// "%3ld-bit %s INT", +// TREE_INT_CST_LOW(TYPE_SIZE(type)), +// (TYPE_UNSIGNED(type) ? "unsigned" : " signed")); + break; + default: cbl_internal_error("Unknown type %d", TREE_CODE(type)); } @@ -3268,25 +3277,13 @@ gg_strdup(tree psz) tree gg_malloc(tree size) { -// tree pvoid_type_node = build_pointer_type (void_type_node); -// tree prvoid_type_node = build_qualified_type (pvoid_type_node, TYPE_QUAL_RESTRICT); -// -// tree malloc_tree = builtin_decl_explicit (BUILT_IN_MALLOC); -// -// show_type(TREE_TYPE(malloc_tree)); -// exit(1); -// -// -// tree the_call = fold_convert( prvoid_type_node, -// build_call_expr_loc(location_from_lineno(), -// malloc_tree, -// 1, -// size)); -// return the_call; - return gg_call_expr(VOID_P, - "malloc", - size, - NULL_TREE); + tree malloc_tree = builtin_decl_explicit (BUILT_IN_MALLOC); + tree the_call = fold_convert( pvoid_type_node, + build_call_expr_loc(location_from_lineno(), + malloc_tree, + 1, + size)); + return the_call; } tree diff --git a/gcc/cobol/gengen.h b/gcc/cobol/gengen.h index d5f1a727360b23ed3e4456a0bd008db42aa8a80a..bc10f7e39b82ecabee12db52fd9929efe9c954a5 100644 --- a/gcc/cobol/gengen.h +++ b/gcc/cobol/gengen.h @@ -264,23 +264,23 @@ extern struct cbl_translation_unit_t gg_trans_unit; #define current_function (&gg_trans_unit.function_stack.back()) -extern tree char_nodes[256]; - -extern tree integer_minusone_node; -extern tree integer_two_node; -extern tree integer_eight_node; -extern tree size_t_zero_node; -extern tree int128_zero_node; -extern tree int128_five_node; -extern tree int128_ten_node; -extern tree bool_true_node; -extern tree bool_false_node; -extern tree char_ptr_type_node; -extern tree uchar_ptr_type_node; -extern tree wchar_ptr_type_node; -extern tree long_double_ten_node; -extern tree sizeof_size_t; -extern tree sizeof_pointer; +extern tree char_nodes[256] GTY(()); +extern tree pvoid_type_node GTY(()); +extern tree integer_minusone_node GTY(()); +extern tree integer_two_node GTY(()); +extern tree integer_eight_node GTY(()); +extern tree size_t_zero_node GTY(()); +extern tree int128_zero_node GTY(()); +extern tree int128_five_node GTY(()); +extern tree int128_ten_node GTY(()); +extern tree bool_true_node GTY(()); +extern tree bool_false_node GTY(()); +extern tree char_ptr_type_node GTY(()); +extern tree uchar_ptr_type_node GTY(()); +extern tree wchar_ptr_type_node GTY(()); +extern tree long_double_ten_node GTY(()); +extern tree sizeof_size_t GTY(()); +extern tree sizeof_pointer GTY(()); // These routines happen when beginning to process a new file, which is also // known, in GCC, as a "translation unit" diff --git a/gcc/cobol/structs.cc b/gcc/cobol/structs.cc index d04d8d0c5fd9b05582e2c449fe6848010df4ec39..950ce0288fc2a4f6dab05efe66de9103acfad69b 100644 --- a/gcc/cobol/structs.cc +++ b/gcc/cobol/structs.cc @@ -347,6 +347,7 @@ create_our_type_nodes() // Create some useful constants to avoid cluttering up the code // build_int_cst_type() calls + pvoid_type_node = build_pointer_type(void_type_node); integer_minusone_node = build_int_cst_type(INT, -1); integer_two_node = build_int_cst_type(INT, 2); integer_eight_node = build_int_cst_type(INT, 8);