return "cobol";
}
+bool
+cobol_langhook_post_options(const char**)
+ {
+ // This flag, when set to 0, results in calls to gg_exit working properly.
+ // I don't know why it is necessary. There is something going on with the
+ // definition of __gg__data_return_code in constants.cc, and with how it
+ // is used through var_decl_return_code in genapi.cc. Without it, the value
+ // delivered to exit@PLT is zero, and not __gg__data_return_code
+ // Dubner, 2025-04-04.
+ flag_strict_aliasing = 0;
+
+ /* Returning false means that the backend should be used. */
+ return false;
+ }
+
+
#undef LANG_HOOKS_BUILTIN_FUNCTION
#undef LANG_HOOKS_GETDECLS
#undef LANG_HOOKS_GLOBAL_BINDINGS_P
////#undef LANG_HOOKS_TYPE_FOR_SIZE
#undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME
#undef LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE
+#undef LANG_HOOKS_POST_OPTIONS
// We use GCC in the name, not GNU, as others do,
// because "GnuCOBOL" refers to a different GNU project.
#define LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE cobol_get_sarif_source_language
+#define LANG_HOOKS_POST_OPTIONS cobol_langhook_post_options
+
struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
#include "gt-cobol-cobol1.h"
void set_user_status(struct cbl_file_t *file)
{
// This routine sets the user_status, if any, to the cblc_file_t::status
+
+ // We have to do it this way, because in the case where the file->user_status
+ // is in linkage, the memory addresses can end up pointing to the wrong
+ // places
if(file->user_status)
{
cbl_field_t *user_status = cbl_field_of(symbol_at(file->user_status));
SHOW_PARSE
{
SHOW_PARSE_HEADER
+ SHOW_PARSE_FIELD(" TO ", f)
+ for(size_t i=0; i<argc; i++)
+ {
+ SHOW_PARSE_INDENT
+ SHOW_PARSE_FIELD(" ", argv[i].orig.field)
+ SHOW_PARSE_FIELD(" ", argv[i].replacement.field)
+ }
SHOW_PARSE_END
}
TRACE1
if( strcmp(new_var->name, "RETURN-CODE") == 0 )
{
- strcpy(ach, "__gg___11_return_code6");
+ strcpy(ach, "__gg__return_code");
}
if( strcmp(new_var->name, "UPSI-0") == 0 )
{
- strcpy(ach, "__gg___6_upsi_04");
+ strcpy(ach, "__gg__upsi");
}
new_var->var_decl_node = gg_declare_variable(cblc_field_type_node, ach, NULL, vs_external_reference);
field->data.initial,
NULL_TREE,
field->var_decl_node);
+ TREE_READONLY(field->var_decl_node) = 1;
+ TREE_USED(field->var_decl_node) = 1;
+ TREE_STATIC(field->var_decl_node) = 1;
+ DECL_PRESERVE_P (field->var_decl_node) = 1;
nvar += 1;
}
TRACE1
static char ach[1024];
switch( TREE_CODE(type) )
{
+ case POINTER_TYPE:
+ sprintf(ach, "POINTER");
+ break;
+
case VOID_TYPE:
sprintf(ach, "VOID");
break;
DECL_CONTEXT (function_decl) = gg_trans_unit.trans_unit_decl;
TREE_PUBLIC(function_decl) = 0;
+ // This function is file static, but nobody calls it, so without
+ // intervention -O1+ optimizations will discard it.
+ DECL_PRESERVE_P (function_decl) = 1;
+
// Append this function to the list of functions and variables
// associated with the computation module.
gg_append_var_decl(function_decl);
tree
gg_array_of_bytes( size_t N, unsigned char *values)
{
- tree retval = gg_define_variable(build_pointer_type(UCHAR));
- gg_assign(retval, gg_cast(build_pointer_type(UCHAR), gg_malloc( build_int_cst_type(UCHAR, N * sizeof(unsigned char)))));
+ tree retval = gg_define_variable(UCHAR_P);
+ gg_assign(retval, gg_cast(UCHAR_P, gg_malloc( build_int_cst_type(SIZE_T, N * sizeof(unsigned char)))));
for(size_t i=0; i<N; i++)
{
gg_assign(gg_array_value(retval, i), build_int_cst_type(UCHAR, values[i]));
extern unsigned char __gg__data_high_values[1] ;
extern unsigned char __gg__data_quotes[1] ;
extern unsigned char __gg__data_upsi_0[2] ;
-extern unsigned char __gg__data_return_code[2] ;
+extern short __gg__data_return_code ;
// These are the various hardcoded tables used for conversions.
extern const unsigned short __gg__one_to_one_values[256];
unsigned char __gg__data_upsi_0[2] = {0,0};
-struct cblc_field_t __gg___6_upsi_04 = {
+struct cblc_field_t __gg__upsi = {
.data = __gg__data_upsi_0 ,
.capacity = 2 ,
.allocated = 2 ,
.dummy = 0 ,
};
-unsigned char __gg__data_return_code[2] = {0,0};
-struct cblc_field_t __gg___11_return_code6 = {
- .data = __gg__data_return_code ,
+short __gg__data_return_code = 0;
+struct cblc_field_t __gg__return_code = {
+ .data = (unsigned char *)&__gg__data_return_code ,
.capacity = 2 ,
.allocated = 2 ,
.offset = 0 ,
.parent = NULL,
.occurs_lower = 0 ,
.occurs_upper = 0 ,
- .attr = 0x0 ,
+ .attr = signable_e ,
.type = FldNumericBin5 ,
.level = 0 ,
.digits = 4 ,