diff --git a/cobc/ChangeLog b/cobc/ChangeLog index 83d9c696c..369fb3449 100644 --- a/cobc/ChangeLog +++ b/cobc/ChangeLog @@ -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 + + * 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 * codegen.c,typeck.c,parser.y,tree.h: Optimize subscript checking when diff --git a/cobc/cobc.c b/cobc/cobc.c index 9673c6a49..624fa2efa 100644 --- a/cobc/cobc.c +++ b/cobc/cobc.c @@ -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; @@ -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 '$': diff --git a/cobc/flag.def b/cobc/flag.def index 0fe9c9a4b..218e3c847 100644 --- a/cobc/flag.def +++ b/cobc/flag.def @@ -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")) diff --git a/libcob/common.c b/libcob/common.c index 0bf689d3e..a6463ab4d 100644 --- a/libcob/common.c +++ b/libcob/common.c @@ -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"); diff --git a/tests/testsuite.src/run_file.at b/tests/testsuite.src/run_file.at index 153ac32d3..0df6a7174 100644 --- a/tests/testsuite.src/run_file.at +++ b/tests/testsuite.src/run_file.at @@ -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]) @@ -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 @@ -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