From 0ea298adfe527fc66186b58589c9f66c99de57df Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Sun, 24 Sep 2023 15:51:23 +0900 Subject: [PATCH] [Add]: Implement `-Wredefinition` option and a test for it --- cobj/warning-help.def | 3 +++ tests/Makefile.am | 3 +-- tests/Makefile.in | 1 + tests/command-line-options.at | 1 + .../command-line-options.src/Wredefinition.at | 24 +++++++++++++++++++ 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tests/command-line-options.src/Wredefinition.at diff --git a/cobj/warning-help.def b/cobj/warning-help.def index 4d331b8f..f8d890d5 100644 --- a/cobj/warning-help.def +++ b/cobj/warning-help.def @@ -23,6 +23,9 @@ /* CB_WARNDEF (var, name, wall, doc) */ +CB_WARNDEF (cb_warn_redefinition, "redefinition", 1, + N_("Warn incompatible redefinition of data items")) + CB_WARNDEF (cb_warn_parentheses, "parentheses", 1, N_("Warn lack of parentheses around AND within OR")) diff --git a/tests/Makefile.am b/tests/Makefile.am index b172a001..51671007 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -147,6 +147,7 @@ command_line_options_DEPENDENCIES = \ command-line-options.src/B.at \ command-line-options.src/list-reserved.at \ command-line-options.src/assign_external.at \ + command-line-options.src/Wredefinition.at \ command-line-options.src/Wparentheses.at \ command-line-options.src/Wcolumn-overflow.at \ command-line-options.src/Wterminator.at \ @@ -188,7 +189,6 @@ misc_DEPENDENCIES = \ misc.src/index-file-status.at \ misc.src/comp-n.at \ misc.src/fd-external.at - EXTRA_DIST = $(srcdir)/package.m4 \ $(TESTS) \ @@ -200,7 +200,6 @@ EXTRA_DIST = $(srcdir)/package.m4 \ $(command_line_options_DEPENDENCIES) \ $(misc_DEPENDENCIES) - DISTCLEANFILES = atconfig all: $(TESTS) diff --git a/tests/Makefile.in b/tests/Makefile.in index 6dd13cab..953fc120 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -688,6 +688,7 @@ command_line_options_DEPENDENCIES = \ command-line-options.src/B.at \ command-line-options.src/list-reserved.at \ command-line-options.src/assign_external.at \ + command-line-options.src/Wredefinition.at \ command-line-options.src/Wparentheses.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 0070bbc3..df0a0de7 100644 --- a/tests/command-line-options.at +++ b/tests/command-line-options.at @@ -9,6 +9,7 @@ m4_include([B.at]) m4_include([list-reserved.at]) m4_include([assign_external.at]) m4_include([java-package.at]) +m4_include([Wredefinition.at]) m4_include([Wparentheses.at]) m4_include([Wcolumn-overflow.at]) m4_include([Wterminator.at]) diff --git a/tests/command-line-options.src/Wredefinition.at b/tests/command-line-options.src/Wredefinition.at new file mode 100644 index 00000000..023aff5a --- /dev/null +++ b/tests/command-line-options.src/Wredefinition.at @@ -0,0 +1,24 @@ +AT_SETUP([-Wredefinition]) + +AT_DATA([prog.cbl], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 GRP. + 03 A PIC X(5). + 01 B redefines GRP. + 05 C PIC X(5). + 01 C PIC X(5). + PROCEDURE DIVISION. + MAIN-RTN. + STOP RUN. +]) + +AT_CHECK([${COBJ} -Wredefinition prog.cbl], [0], [], +[prog.cbl:10: Warning: Redefinition of 'C' +prog.cbl:9: Warning: 'C' previously defined here +]) + +AT_CHECK([${COBJ} --help | grep '\-Wredefinition' > /dev/null], [0]) +AT_CLEANUP