Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into gc4
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Jan 15, 2025
2 parents 303c365 + b16b9e5 commit 2e4f14c
Show file tree
Hide file tree
Showing 29 changed files with 1,107 additions and 540 deletions.
10 changes: 10 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,12 @@ Open Plans:
the origin of entrypoints and PERFORM, this is used for the internal
stack trace on abort and can be used for improved source level debugging

** new flag -fmemory-check (implied with --debug) to do some validation
of internal memory used during CALL; this can help in finding otherwise
hard to diagnose overwrite of memory and as it is only done on CALL
has a much smaller footprint than -fec=bounds (as both check different
aspects at different places it is also reasonable to use both)

** the option -g does no longer imply -fno-remove-unreachable; if you want to
keep those in you need to explicit specify this

Expand Down Expand Up @@ -473,6 +479,8 @@ Open Plans:
or to use an explicit format (cut at 26 characters, may raise false-positives
in listing tests) e.g. date only `-DLISTING_TIMESTAMP_FORMAT="%Y-%m-%d"`

** new compile options to adjust the listing, see above

* More notable changes

** in 64-bit environments, the maximum field size was increased from
Expand Down Expand Up @@ -556,6 +564,8 @@ Open Plans:
* compile from stdin
* NIST: OBNC1M.CBL false positive (the test runner uses a nonportable way of
emulating a program kill)
* if build with -fsanitize, then some tests will fail; while we accept patches
to improve that, we don't consider the failing tests as bug in GnuCOBOL

** the recent additions of ">> TURN" and "variable LIKE variable" may not work
as expected in all cases
Expand Down
60 changes: 56 additions & 4 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,56 @@
* error.c, cobc.c (print_program_trailer), flag.def:
implemented -fmax-errors=0 as unlimited

2023-07-24 Simon Sobisch <[email protected]>

* parser.y (entry_statement): don't check parameter address
directly on ENTRY, because it just assigns it
* codegen.c (output_internal_function, output_entry_function): moved
setting of non-passed parameters to NULL to entry function as we only
have ordinal CALL numbers available there; set BY VALUE parameters to
zero instead of NULL
* codegen.c (output_field_no_target): extracted to reduce code duplication
* typeck.c (cb_emit_call): fixed skipping memory-fence generation for
EXTERNAL/BASED sub-fields

2023-07-13 Simon Sobisch <[email protected]>

* pplex.l (cb_ppecho_direct, output_pending_newlines): output only up
to 9 empty lines, for more empty lines in the preparsed output file
generate a matching #line directive, this saves both space and serves
as a workaround for an unclear scanner bug that may happen with huge
amounts of empty lines
* pplex.l (switch_to_buffer): don't re-strdup the filename
* parser.y (emit_statement): changed from define to inline function
* codegen.c: complete output of program's end source location if requested
* scanner.l: handle line directive in any state

2023-07-11 Fabrice Le Fessant <[email protected]>

* parser.y: fix code generation for OPEN/CLOSE with multiple
filenames, where DECLARATIVES for all arguments were called when
only one argument failed

2023-07-10 Simon Sobisch <[email protected]>

check for internal memory bounds with new flag "memory-check"
* flag.def, cobc.c (cobc_deciph_memory_check), tree.h: new compile
flag -fmemory-check, implied with --debug
* typeck.c (cb_emit_call), tree.h (cb_field): new field attribute
flag_used_in_call
* codegen.c (output_local_base_cache, output_nonlocal_base_cache):
generate fencing data fields for fields with flag_used_in_call
* codegen.c (output_call_cache): generate fencing data fields for
cob_call_union fields (call pointers)
* codegen.c (output_memory_check_call): new function to output
generate fencing data fields for flag_used_in_call
* codeoptim.def, codeoptim.c, codegen.c: new entry
COB_CHK_MEMORYFENCE

additional
* codegen.c: only increment/decrement output_indent_level by
indent_adjust_level

2023-07-07 Simon Sobisch <[email protected]>

common preparser cleanup
Expand Down Expand Up @@ -2603,7 +2653,8 @@

2020-09-27 Robert Dubner <[email protected]>

* codegen.c (output_cobol_info): emit doubled backslashes for source file
* codegen.c (output_cobol_info): emit doubled backslashes for source file,
fixing bug #698 problem with #line directives

2020-09-14 Simon Sobisch <[email protected]>

Expand Down Expand Up @@ -3020,9 +3071,10 @@

2020-04-26 Ron Norman <[email protected]>

* codeoptim.def,codeoptim.c: New routines to convert DISPLAY into
binary values
* codegen.c: Use new get_numdisps/64/s64 routines
* codeoptim.def (COB_GET_NUMDISPS), codeoptim.c, codegen.c: new routine
to convert signed DISPLAY into binary value;
* codeoptim.def (cob_get_numdisp, cob_get_numdisps): use of register
attribute and skipping of leading zeroes
* typeck.c: Check for integer expression and emit faster arithmetic
code by using the C language to do the arithmetic
* flag.def: New flag -fno-fast-math to disable these changes
Expand Down
59 changes: 52 additions & 7 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ enum compile_level {
#define CB_FLAG_GETOPT_NO_DUMP 13
#define CB_FLAG_GETOPT_EBCDIC_TABLE 14
#define CB_FLAG_GETOPT_DEFAULT_COLSEQ 15
#define CB_FLAG_GETOPT_SQLSCHEMA 16
#define CB_FLAG_GETOPT_FILE_FORMAT 17
#define CB_FLAG_MEMORY_CHECK 16
#define CB_FLAG_GETOPT_SQLSCHEMA 17
#define CB_FLAG_GETOPT_FILE_FORMAT 18


/* Info display limits */
Expand Down Expand Up @@ -1246,11 +1247,9 @@ void *
cobc_plex_strsub (const char *s, const int len)
{
void *p;
int n;

n = strlen (s);

#ifdef COB_TREE_DEBUG
int n = strlen (s);
/* LCOV_EXCL_START */
if ( len>n ) {
cobc_err_msg ("call to %s with bad argument len=%d>%d=strlen(s)",
Expand Down Expand Up @@ -1856,6 +1855,42 @@ cobc_deciph_optarg (const char *p, const int allow_quote)
return (int)n;
}

/* decipher a value for the memory-check flag,
directly setting cb_flag_memory_check,
returns -1 on error */
static int
cobc_deciph_memory_check (const char *p)
{
char buff[8] = { 0 };
const size_t len = strlen (p);
size_t i;

if (len > sizeof(buff)) {
return -1;
}
for (i = 0; i < len; ++i) {
buff[i] = cb_toupper (p[i]);
}

if (len == 3 && memcmp ("ALL", buff, 3) == 0) {
cb_flag_memory_check = CB_MEMCHK_ALL;
return 0;
}
if (len == 4 && memcmp ("NONE", buff, 4) == 0) {
cb_flag_memory_check = CB_MEMCHK_NONE;
return 0;
}
if (len == 5 && memcmp ("USING", buff, 5) == 0) {
cb_flag_memory_check = CB_MEMCHK_USING;
return 0;
}
if (len == 7 && memcmp ("POINTER", buff, 7) == 0) {
cb_flag_memory_check = CB_MEMCHK_POINTER;
return 0;
}
return -1;
}

/* exit to OS before processing a COBOL/C source file */
DECLNORET static void COB_A_NORETURN
cobc_early_exit (int ret_code)
Expand Down Expand Up @@ -3265,6 +3300,7 @@ process_command_line (const int argc, char **argv)
cb_flag_stack_extended = 1;
cb_flag_stack_check = 1;
cb_flag_symbols = 1;
cb_flag_memory_check = CB_MEMCHK_ALL;
cobc_wants_debug = 1;
break;

Expand Down Expand Up @@ -3869,7 +3905,7 @@ process_command_line (const int argc, char **argv)
cobc_deciph_funcs (cob_optarg);
break;

case CB_FLAG_GETOPT_SQLSCHEMA: /* 16 */
case CB_FLAG_GETOPT_SQLSCHEMA: /* 17 */
/* -fsqlschema=<name> : Database schema name for XFD */
cb_sqldb_schema = cobc_main_strdup (cob_optarg);
cb_flag_sql_xfd = 1;
Expand All @@ -3892,7 +3928,7 @@ process_command_line (const int argc, char **argv)
#endif
break;

case CB_FLAG_GETOPT_FILE_FORMAT: /* 17 */
case CB_FLAG_GETOPT_FILE_FORMAT: /* 18 */
/* -ffile-format=<name> : Default file format */
if (cb_strcasecmp (cob_optarg, "mf") == 0) {
cb_mf_files = 1;
Expand All @@ -3919,6 +3955,15 @@ process_command_line (const int argc, char **argv)
};
break;

case CB_FLAG_MEMORY_CHECK: /* 16 */
/* -fmemory-check=<scope> : */
if (!cob_optarg) {
cb_flag_memory_check = CB_MEMCHK_ALL;
} else if (cobc_deciph_memory_check (cob_optarg)) {
cobc_err_exit (COBC_INV_PAR, "-fmemory-check");
}
break;

case 'A':
/* -A <xx> : Add options to C compile phase */
COBC_ADD_STR (cobc_cflags, " ", cob_optarg, NULL);
Expand Down
Loading

0 comments on commit 2e4f14c

Please sign in to comment.