From 6359e5dad9aa2ccb84f783c2dd35babe47085666 Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Sun, 21 Apr 2024 17:24:19 +0900 Subject: [PATCH] [Feat]: implement -Wstrict-typing --- cobj/warning-help.def | 3 ++ tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/command-line-options.at | 1 + .../Wstrict-typing.at | 37 +++++++++++++++++++ 5 files changed, 43 insertions(+) create mode 100644 tests/command-line-options.src/Wstrict-typing.at diff --git a/cobj/warning-help.def b/cobj/warning-help.def index 27f8ef53..d00668c9 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_strict_typing, "strict-typing", 1, + N_("Warn type mismatch strictly")) + CB_WARNDEF (cb_warn_call_params, "call-params", 0, N_("Warn non 01/77 items for CALL params")) diff --git a/tests/Makefile.am b/tests/Makefile.am index 6724124e..72e9ba24 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -155,6 +155,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/Wstrict-typing.at \ command-line-options.src/Wcall-params.at \ command-line-options.src/Wcolumn-overflow.at \ command-line-options.src/Wterminator.at \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 7b1ef4d2..5c442544 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -696,6 +696,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/Wstrict-typing.at \ command-line-options.src/Wcall-params.at \ command-line-options.src/Wcolumn-overflow.at \ command-line-options.src/Wterminator.at \ diff --git a/tests/command-line-options.at b/tests/command-line-options.at index 36c07075..f07cab5c 100644 --- a/tests/command-line-options.at +++ b/tests/command-line-options.at @@ -15,6 +15,7 @@ m4_include([Wobsolete-Warchaic.at]) m4_include([Wredefinition.at]) m4_include([Wconstant.at]) m4_include([Wparentheses.at]) +m4_include([Wstrict-typing.at]) m4_include([Wcall-params.at]) m4_include([Wcolumn-overflow.at]) m4_include([Wterminator.at]) diff --git a/tests/command-line-options.src/Wstrict-typing.at b/tests/command-line-options.src/Wstrict-typing.at new file mode 100644 index 00000000..70af52b1 --- /dev/null +++ b/tests/command-line-options.src/Wstrict-typing.at @@ -0,0 +1,37 @@ +AT_SETUP([-Wstrict-typing]) + +AT_DATA([prog.cbl], +[ IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 X PIC X(5). + 01 X-EDIT PIC X(3),X(2). + 01 N PIC N(5). + 01 NUM PIC 9(5). + 01 NUM-EDIT PIC 9(3),9(2). + PROCEDURE DIVISION. + MAIN SECTION. + MOVE 12345 TO X. + MOVE 12345 TO X-EDIT. + MOVE 12345 TO N. + MOVE "12345" TO NUM. + MOVE "12345" TO NUM-EDIT. +]) + +AT_CHECK([${COBJ} -Wstrict-typing prog.cbl], [0], [], +[prog.cbl:12: Warning: Alphanumeric value is expected +prog.cbl:5: Warning: 'X' defined here as PIC X(5) +prog.cbl:13: Warning: Alphanumeric value is expected +prog.cbl:6: Warning: 'X-EDIT' defined here as PIC X(3),X(2) +prog.cbl:14: Warning: National value is expected +prog.cbl:7: Warning: 'N' defined here as PIC N(5) +prog.cbl:15: Warning: Numeric value is expected +prog.cbl:8: Warning: 'NUM' defined here as PIC 9(5) +prog.cbl:16: Warning: Numeric value is expected +prog.cbl:9: Warning: 'NUM-EDIT' defined here as PIC 9(3),9(2) +]) + +AT_CHECK([${COBJ} --help | grep '\-Wstrict-typing' > /dev/null], [0]) + +AT_CLEANUP