From c151d9588d55ca6d18c3d8896df34f53d2aff749 Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Sat, 2 Mar 2024 14:22:08 +0900 Subject: [PATCH 1/2] [Feat]: implement `-Wcall-params` --- cobj/typeck.c | 1 + cobj/warning-help.def | 3 +++ tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/command-line-options.at | 1 + .../command-line-options.src/Wcall-params.at | 24 +++++++++++++++++++ 6 files changed, 31 insertions(+) create mode 100644 tests/command-line-options.src/Wcall-params.at diff --git a/cobj/typeck.c b/cobj/typeck.c index 95db7b33..5a4baa21 100644 --- a/cobj/typeck.c +++ b/cobj/typeck.c @@ -1266,6 +1266,7 @@ void cb_validate_program_data(struct cb_program *prog) { CB_FILE(CB_VALUE(l))->assign = assign; } } + printf("[dbg] tag:%d\n", CB_TREE_TAG(assign)); if (CB_REFERENCE_P(assign) && CB_REFERENCE(assign)->word->count == 0) { if (cb_warn_implicit_define) { cb_warning(_("'%s' will be implicitly defined"), CB_NAME(assign)); diff --git a/cobj/warning-help.def b/cobj/warning-help.def index 6a4ad940..27f8ef53 100644 --- a/cobj/warning-help.def +++ b/cobj/warning-help.def @@ -38,6 +38,9 @@ CB_WARNDEF (cb_warn_constant, "constant", 1, CB_WARNDEF (cb_warn_parentheses, "parentheses", 1, N_("Warn lack of parentheses around AND within OR")) +CB_WARNDEF (cb_warn_call_params, "call-params", 0, + N_("Warn non 01/77 items for CALL params")) + CB_WARNDEF (cb_warn_column_overflow, "column-overflow", 0, N_("Warn text after column 72, FIXED format")) diff --git a/tests/Makefile.am b/tests/Makefile.am index 2ebeb813..a26738a6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -154,6 +154,7 @@ command_line_options_DEPENDENCIES = \ command-line-options.src/Wredefinition.at \ command-line-options.src/Wconstant.at \ command-line-options.src/Wparentheses.at \ + command-line-options.src/Wcall-params.at \ command-line-options.src/Wcolumn-overflow.at \ command-line-options.src/Wterminator.at \ command-line-options.src/Wunreachable.at \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 43c506de..7dc83d5b 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -695,6 +695,7 @@ command_line_options_DEPENDENCIES = \ command-line-options.src/Wredefinition.at \ command-line-options.src/Wconstant.at \ command-line-options.src/Wparentheses.at \ + command-line-options.src/Wcall-params.at \ command-line-options.src/Wcolumn-overflow.at \ command-line-options.src/Wterminator.at \ command-line-options.src/Wunreachable.at \ diff --git a/tests/command-line-options.at b/tests/command-line-options.at index 0a5c172a..f9af0506 100644 --- a/tests/command-line-options.at +++ b/tests/command-line-options.at @@ -13,6 +13,7 @@ m4_include([Wobsolete-Warchaic.at]) m4_include([Wredefinition.at]) m4_include([Wconstant.at]) m4_include([Wparentheses.at]) +m4_include([Wcall-params.at]) m4_include([Wcolumn-overflow.at]) m4_include([Wterminator.at]) m4_include([Wunreachable.at]) diff --git a/tests/command-line-options.src/Wcall-params.at b/tests/command-line-options.src/Wcall-params.at new file mode 100644 index 00000000..3c1c8f51 --- /dev/null +++ b/tests/command-line-options.src/Wcall-params.at @@ -0,0 +1,24 @@ +AT_SETUP([-Wcolumn-overflow]) + +AT_DATA([callee.cbl], +[ IDENTIFICATION DIVISION. + PROGRAM-ID. callee. + DATA DIVISION. + WORKING-STORAGE SECTION. + LINKAGE SECTION. + 01 GRP1. + 03 P1 PIC X(5). + 01 GRP2. + 03 P2 PIC X(5). + 77 P3 PIC X(5). + PROCEDURE DIVISION USING P1 GRP2 P3. + DISPLAY P1. +]) + +AT_CHECK([${COBJ} -Wcall-params callee.cbl], [1], [], +[callee.cbl:11: Error: 'P1' not level 01 or 77 +]) + +AT_CHECK([${COBJ} --help | grep '\-Wcall-params' > /dev/null], [0]) + +AT_CLEANUP From 70ad3afae46c47be9a3c9b0274f189b869cf86c6 Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Sat, 2 Mar 2024 14:41:30 +0900 Subject: [PATCH 2/2] [Fix]: remove debug code --- cobj/typeck.c | 1 - 1 file changed, 1 deletion(-) diff --git a/cobj/typeck.c b/cobj/typeck.c index 5a4baa21..95db7b33 100644 --- a/cobj/typeck.c +++ b/cobj/typeck.c @@ -1266,7 +1266,6 @@ void cb_validate_program_data(struct cb_program *prog) { CB_FILE(CB_VALUE(l))->assign = assign; } } - printf("[dbg] tag:%d\n", CB_TREE_TAG(assign)); if (CB_REFERENCE_P(assign) && CB_REFERENCE(assign)->word->count == 0) { if (cb_warn_implicit_define) { cb_warning(_("'%s' will be implicitly defined"), CB_NAME(assign));