Skip to content

Commit

Permalink
Merge SVN 3988
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Jun 11, 2024
1 parent d9950fa commit b9387f4
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 53 deletions.
8 changes: 8 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,14 @@
* error.c (cb_note_x): fixed late return that lead to listing issues and
memory leak

2020-11-27 Simon Sobisch <[email protected]>

* cobc.c (process_command_line): early processing for -g and optimization
flags to allow their "grouped" options to be adjusted by single options
later on
* cobc.c (process_command_line), flag.def: -g now implies the recently
added flags -fgen-c-line-directives and -fgen-c-labels

2020-11-27 Ron Norman <[email protected]>

* codegen.c,typeck.c,parser.y,tree.h: Optimize subscript checking when
Expand Down
109 changes: 63 additions & 46 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3051,6 +3051,68 @@ process_command_line (const int argc, char **argv)
conf_ret |= cb_load_conf (cob_optarg, 0);
break;

case '0':
/* -O0 : disable optimizations (or at least minimize them) */
cb_flag_optimize_check = 0;
strip_output = 0;
cb_constant_folding = 0;
copt = CB_COPT_0;
break;

case 'O':
/* -O : Optimize */
cb_flag_optimize_check = 1;
copt = CB_COPT_1;
break;

case '2':
/* -O2 : Optimize */
cb_flag_optimize_check = 1;
strip_output = 1;
copt = CB_COPT_2;
break;

case '3':
/* -O3 : Optimize */
cb_flag_optimize_check = 1;
strip_output = 1;
copt = CB_COPT_3;
break;

case 's':
/* -Os : Optimize */
cb_flag_optimize_check = 1;
strip_output = 1;
copt = CB_COPT_S;
break;

case 'g':
/* -g : Generate C debug code */
save_all_src = 1;
cb_source_debugging = 1;
/* note: cb_flag_source_location and cb_flag_stack_extended
are explicit not set here */
#if 1 /* auto-included, may be disabled manually if needed */
cb_flag_c_line_directives = 1;
cb_flag_c_labels = 1;
#endif
cb_flag_stack_check = 1;
cb_flag_source_location = 1;
cb_flag_symbols = 1;
cb_flag_remove_unreachable = 0;
#ifdef COB_DEBUG_FLAGS
COBC_ADD_STR (cobc_cflags, " ", cobc_debug_flags, NULL);
#endif
break;

case 'G':
/* -G : Generate C debug code for use with gdb on COBOL source */
cb_source_debugging = 1;
cb_cob_line_num = 1;
cb_flag_symbols = 1;
cb_flag_remove_unreachable = 0;
break;

case 'd':
/* --debug : Turn on all runtime checks */
cb_flag_source_location = 1;
Expand Down Expand Up @@ -3259,64 +3321,19 @@ process_command_line (const int argc, char **argv)

case '0':
/* -O0 : disable optimizations (or at least minimize them) */
cb_flag_optimize_check = 0;
strip_output = 0;
cb_constant_folding = 0;
copt = CB_COPT_0;
break;

case 'O':
/* -O : Optimize */
cb_flag_optimize_check = 1;
copt = CB_COPT_1;
break;

case '2':
/* -O2 : Optimize */
cb_flag_optimize_check = 1;
strip_output = 1;
copt = CB_COPT_2;
break;

case '3':
/* -O3 : Optimize */
cb_flag_optimize_check = 1;
strip_output = 1;
copt = CB_COPT_3;
break;

case 's':
/* -Os : Optimize */
cb_flag_optimize_check = 1;
strip_output = 1;
copt = CB_COPT_S;
break;

case 'g':
/* -g : Generate C debug code */
save_all_src = 1;
cb_source_debugging = 1;
/* note: cb_flag_source_location and cb_flag_stack_extended
are explicit not set here */
#if 0 /* TO BE MERGED auto-included, may be disabled manually if needed */
cb_flag_c_line_directives = 1;
cb_flag_c_labels = 1;
#endif
cb_flag_stack_check = 1;
cb_flag_source_location = 1;
cb_flag_symbols = 1;
cb_flag_remove_unreachable = 0;
#ifdef COB_DEBUG_FLAGS
COBC_ADD_STR (cobc_cflags, " ", cobc_debug_flags, NULL);
#endif
break;

case 'G':
/* -G : Generate C debug code for use with gdb on COBOL source */
cb_source_debugging = 1;
cb_cob_line_num = 1;
cb_flag_symbols = 1;
cb_flag_remove_unreachable = 0;
/* These options were all processed in the first getopt-run */
break;

case '$':
Expand Down
4 changes: 2 additions & 2 deletions cobc/flag.def
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ CB_FLAG_ON (cb_flag_c_decl_for_static_call, 1, "gen-c-decl-static-call",

CB_FLAG (cb_flag_c_line_directives, 1, "gen-c-line-directives",
_(" -fgen-c-line-directives\tgenerate source location directives in C code;\n"
" useful for source-level debugging"))
" * turned on by -g"))

CB_FLAG (cb_flag_c_labels, 1, "gen-c-labels",
_(" -fgen-c-labels generate extra labels in C sources;\n"
" useful for source-level debugging"))
" * turned on by -g"))

CB_FLAG (cb_mf_files, 1, "mf-files",
_(" -fmf-files Sequential & Relative files will match Micro Focus format"))
Expand Down
2 changes: 1 addition & 1 deletion libcob/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -8592,7 +8592,7 @@ cob_fatal_error (const enum cob_fatal_error fatal_error)
msg = _("permanent file error");
break;
case COB_STATUS_31_INCONSISTENT_FILENAME:
msg = _("inconsistant file name");
msg = _("inconsistent file name");
break;
case COB_STATUS_35_NOT_EXISTS:
msg = _("file does not exist");
Expand Down
8 changes: 4 additions & 4 deletions tests/testsuite.src/run_file.at
Original file line number Diff line number Diff line change
Expand Up @@ -2928,7 +2928,7 @@ AT_DATA([prog2.cob], [
AT_CHECK([$COMPILE prog.cob])
AT_CHECK([$COBCRUN_DIRECT ./prog X], [0], [], [])
AT_CHECK([$COBCRUN_DIRECT ./prog], [1], [],
[libcob: prog.cob:23: error: inconsistant file name (status = 31) for file test-file ('field with NULL address') on OPEN
[libcob: prog.cob:23: error: inconsistent file name (status = 31) for file test-file ('field with NULL address') on OPEN
])

AT_CHECK([$COMPILE prog2.cob])
Expand Down Expand Up @@ -3103,7 +3103,7 @@ Extend file: foxasg.txt - 00 #0002.
AT_CHECK([$COMPILE prog2.cob], [0], [], [])

AT_CHECK([$COBCRUN_DIRECT ./prog2], [1], [],
[libcob: prog2.cob:32: error: inconsistant file name (status = 31) for file f ('field with NULL address') on OPEN
[libcob: prog2.cob:32: error: inconsistent file name (status = 31) for file f ('field with NULL address') on OPEN
])

AT_CLEANUP
Expand Down Expand Up @@ -3141,10 +3141,10 @@ AT_DATA([prog.cob], [

AT_CHECK([$COBC -x prog.cob])
AT_CHECK([$COBCRUN_DIRECT ./prog], [1], [],
[libcob: error: inconsistant file name (status = 31) for file test-file ('')
[libcob: error: inconsistent file name (status = 31) for file test-file ('')
])
AT_CHECK([$COBCRUN_DIRECT ./prog X], [1], [],
[libcob: error: inconsistant file name (status = 31) for file test-file ('')
[libcob: error: inconsistent file name (status = 31) for file test-file ('')
])

AT_CLEANUP
Expand Down

0 comments on commit b9387f4

Please sign in to comment.