From 23fe4f3345343c18cf698f54eaee0f5548b99268 Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Thu, 15 Feb 2024 19:58:31 +0900 Subject: [PATCH] [Add]: add options `-Warchaic` and `-Wobsolete` --- cobj/warning-help.def | 6 + tests/Makefile.am | 1 + tests/command-line-options.at | 1 + .../Wobsolete-Warchaic.at | 23 +++ .../stop-literal-statement-archaic.conf | 153 ++++++++++++++++++ .../stop-literal-statement-obsolete.conf | 153 ++++++++++++++++++ 6 files changed, 337 insertions(+) create mode 100644 tests/command-line-options.src/Wobsolete-Warchaic.at create mode 100644 tests/command-line-options.src/stop-literal-statement-archaic.conf create mode 100644 tests/command-line-options.src/stop-literal-statement-obsolete.conf diff --git a/cobj/warning-help.def b/cobj/warning-help.def index e56f4ef0..6a4ad940 100644 --- a/cobj/warning-help.def +++ b/cobj/warning-help.def @@ -23,6 +23,12 @@ /* CB_WARNDEF (var, name, wall, doc) */ +CB_WARNDEF (cb_warn_obsolete, "obsolete", 1, + N_("Warn if obsolete features are used")) + +CB_WARNDEF (cb_warn_archaic, "archaic", 1, + N_("Warn if archaic features are used")) + CB_WARNDEF (cb_warn_redefinition, "redefinition", 1, N_("Warn incompatible redefinition of data items")) diff --git a/tests/Makefile.am b/tests/Makefile.am index 466a2d01..ba2c2941 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -150,6 +150,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/Wobsolete-Warchaic.at \ command-line-options.src/Wredefinition.at \ command-line-options.src/Wconstant.at \ command-line-options.src/Wparentheses.at \ diff --git a/tests/command-line-options.at b/tests/command-line-options.at index 6e6108cc..0a5c172a 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([Wobsolete-Warchaic.at]) m4_include([Wredefinition.at]) m4_include([Wconstant.at]) m4_include([Wparentheses.at]) diff --git a/tests/command-line-options.src/Wobsolete-Warchaic.at b/tests/command-line-options.src/Wobsolete-Warchaic.at new file mode 100644 index 00000000..0ff9d2d7 --- /dev/null +++ b/tests/command-line-options.src/Wobsolete-Warchaic.at @@ -0,0 +1,23 @@ +AT_SETUP([-Wobsolete and -Warchaic]) + +AT_DATA([prog.cbl], +[ IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + DATA DIVISION. + WORKING-STORAGE SECTION. + PROCEDURE DIVISION. + DISPLAY "HELLO". + STOP "hello". +]) + +AT_CHECK([${COBJ} -Wobsolete -conf=../../command-line-options.src/stop-literal-statement-obsolete.conf prog.cbl], [0], [], +[prog.cbl:7: Warning: STOP literal is obsolete in OpenCOBOL +]) + +AT_CHECK([${COBJ} -Warchaic -conf=../../command-line-options.src/stop-literal-statement-archaic.conf prog.cbl], [0], [], +[prog.cbl:7: Warning: STOP literal is archaic in OpenCOBOL +]) + +AT_CHECK([${COBJ} --help | grep '\-Warchaic' > /dev/null], [0]) +AT_CHECK([${COBJ} --help | grep '\-Wobsolete' > /dev/null], [0]) +AT_CLEANUP diff --git a/tests/command-line-options.src/stop-literal-statement-archaic.conf b/tests/command-line-options.src/stop-literal-statement-archaic.conf new file mode 100644 index 00000000..ebc92f21 --- /dev/null +++ b/tests/command-line-options.src/stop-literal-statement-archaic.conf @@ -0,0 +1,153 @@ +# COBOL compiler configuration -*- sh -*- + +# Value: any string +name: "OpenCOBOL" + +# Value: int +tab-width: 8 +text-column: 72 + +# Value: 'record-sequential', 'line-sequential' +# This sets the default organization for sequential files, +# where the organization is not explicitly defined. +default-organization: record-sequential + +# Value: 'cobol2002', 'mf', 'ibm', 'jph1' +assign-clause: mf + +# If yes, file names are resolved at run time using environment variables. +# For example, given ASSIGN TO "DATAFILE", the actual file name will be +# 1. the value of environment variable 'DD_DATAFILE' or +# 2. the value of environment variable 'dd_DATAFILE' or +# 3. the value of environment variable 'DATAFILE' or +# 4. the literal "DATAFILE" +# If no, the value of the assign clause is the file name. +# +# Value: 'yes', 'no' +filename-mapping: yes + +# Value: 'yes', 'no' +pretty-display: yes + +# Value: 'yes', 'no' +auto-initialize: yes + +# Value: 'yes', 'no' +complex-odo: no + +# Value: 'yes', 'no' +indirect-redefines: no + +# Binary byte size - defines the allocated bytes according to PIC +# Value: signed unsigned bytes +# ------ -------- ----- +# '2-4-8' 1 - 4 2 +# 5 - 9 4 +# 10 - 18 8 +# +# '1-2-4-8' 1 - 2 1 +# 3 - 4 2 +# 5 - 9 4 +# 10 - 18 8 +# +# '1--8' 1 - 2 1 - 2 1 +# 3 - 4 3 - 4 2 +# 5 - 6 5 - 7 3 +# 7 - 9 8 - 9 4 +# 10 - 11 10 - 12 5 +# 12 - 14 13 - 14 6 +# 15 - 16 15 - 16 7 +# 17 - 18 17 - 18 8 +binary-size: 1-2-4-8 + +# Value: 'yes', 'no' +binary-truncate: yes + +# Value: 'native', 'big-endian' +binary-byteorder: big-endian + +# Value: 'any', 'fatal', 'never' +abort-on-io-exception: any + +# Value: 'yes', 'no' +larger-redefines-ok: no + +# Value: 'yes', 'no' +relaxed-syntax-check: no + +# Perform type OSVS - If yes, the exit point of any currently executing perform +# is recognized if reached. +# Value: 'yes', 'no' +perform-osvs: no + +# If yes, linkage-section items remain allocated +# between invocations. +# Value: 'yes', 'no' +sticky-linkage: no + +# If yes, set the file assign to the external file +# Value: 'yes', 'no' +assign_external: no + +# If yes, allow non-matching level numbers +# Value: 'yes', 'no' +relax-level-hierarchy: no + +# not-reserved: +# Value: Word to be taken out of the reserved words list +# (case independent) + +# Dialect features +# Value: 'ok', 'archaic', 'obsolete', 'skip', 'ignore', 'unconformable' +author-paragraph: obsolete +memory-size-clause: obsolete +multiple-file-tape-clause: obsolete +label-records-clause: obsolete +value-of-clause: obsolete +data-records-clause: obsolete +top-level-occurs-clause: skip +synchronized-clause: ok +goto-statement-without-name: obsolete +stop-literal-statement: archaic +debugging-line: obsolete +padding-character-clause: obsolete +next-sentence-phrase: archaic +eject-statement: skip +entry-statement: obsolete +move-noninteger-to-alphanumeric: error +odo-without-to: ok + +# Value: any single character +default-currency-symbol: $ + +# Value: int +max-alpha-character-data-size: 2147483647 +max-sjis-character-data-size: 1073741823 +max-utf8-character-data-size: 715827882 + +# If yes, length of PROGRAM-ID of after translation is bigger than +# 31 characters, give warning. +c89-identifier-length-check: no + +# jp compatible +# Value: 'yes', 'no' +allow-end-program-with-wrong-name: no +allow-missing-also-clause-in-evaluate: no +allow-empty-imperative-statement: no +enable-program-status-register: no +enable-sort-status-register: no +enable-special-names-argument-clause: no +enable-special-names-environment-clause: no +enable-leng-intrinsic-function: no +enable-length-an-intrinsic-function: no +enable-national-intrinsic-function: no +use-invalidkey-handler-on-status34: no +cobol68-copy-in-data-description: no +switch-no-mnemonic: no +allow-is-in-sort-key-spec: no +allow-search-key-in-rhs: no +ignore-invalid-record-contains: no +enable-zero-division-error: no +enable-check-subscript-out-of-bounds: no +enable-expect-numeric-error: no +enable-expect-compute-string-error: no diff --git a/tests/command-line-options.src/stop-literal-statement-obsolete.conf b/tests/command-line-options.src/stop-literal-statement-obsolete.conf new file mode 100644 index 00000000..c3be730d --- /dev/null +++ b/tests/command-line-options.src/stop-literal-statement-obsolete.conf @@ -0,0 +1,153 @@ +# COBOL compiler configuration -*- sh -*- + +# Value: any string +name: "OpenCOBOL" + +# Value: int +tab-width: 8 +text-column: 72 + +# Value: 'record-sequential', 'line-sequential' +# This sets the default organization for sequential files, +# where the organization is not explicitly defined. +default-organization: record-sequential + +# Value: 'cobol2002', 'mf', 'ibm', 'jph1' +assign-clause: mf + +# If yes, file names are resolved at run time using environment variables. +# For example, given ASSIGN TO "DATAFILE", the actual file name will be +# 1. the value of environment variable 'DD_DATAFILE' or +# 2. the value of environment variable 'dd_DATAFILE' or +# 3. the value of environment variable 'DATAFILE' or +# 4. the literal "DATAFILE" +# If no, the value of the assign clause is the file name. +# +# Value: 'yes', 'no' +filename-mapping: yes + +# Value: 'yes', 'no' +pretty-display: yes + +# Value: 'yes', 'no' +auto-initialize: yes + +# Value: 'yes', 'no' +complex-odo: no + +# Value: 'yes', 'no' +indirect-redefines: no + +# Binary byte size - defines the allocated bytes according to PIC +# Value: signed unsigned bytes +# ------ -------- ----- +# '2-4-8' 1 - 4 2 +# 5 - 9 4 +# 10 - 18 8 +# +# '1-2-4-8' 1 - 2 1 +# 3 - 4 2 +# 5 - 9 4 +# 10 - 18 8 +# +# '1--8' 1 - 2 1 - 2 1 +# 3 - 4 3 - 4 2 +# 5 - 6 5 - 7 3 +# 7 - 9 8 - 9 4 +# 10 - 11 10 - 12 5 +# 12 - 14 13 - 14 6 +# 15 - 16 15 - 16 7 +# 17 - 18 17 - 18 8 +binary-size: 1-2-4-8 + +# Value: 'yes', 'no' +binary-truncate: yes + +# Value: 'native', 'big-endian' +binary-byteorder: big-endian + +# Value: 'any', 'fatal', 'never' +abort-on-io-exception: any + +# Value: 'yes', 'no' +larger-redefines-ok: no + +# Value: 'yes', 'no' +relaxed-syntax-check: no + +# Perform type OSVS - If yes, the exit point of any currently executing perform +# is recognized if reached. +# Value: 'yes', 'no' +perform-osvs: no + +# If yes, linkage-section items remain allocated +# between invocations. +# Value: 'yes', 'no' +sticky-linkage: no + +# If yes, set the file assign to the external file +# Value: 'yes', 'no' +assign_external: no + +# If yes, allow non-matching level numbers +# Value: 'yes', 'no' +relax-level-hierarchy: no + +# not-reserved: +# Value: Word to be taken out of the reserved words list +# (case independent) + +# Dialect features +# Value: 'ok', 'archaic', 'obsolete', 'skip', 'ignore', 'unconformable' +author-paragraph: obsolete +memory-size-clause: obsolete +multiple-file-tape-clause: obsolete +label-records-clause: obsolete +value-of-clause: obsolete +data-records-clause: obsolete +top-level-occurs-clause: skip +synchronized-clause: ok +goto-statement-without-name: obsolete +stop-literal-statement: obsolete +debugging-line: obsolete +padding-character-clause: obsolete +next-sentence-phrase: archaic +eject-statement: skip +entry-statement: obsolete +move-noninteger-to-alphanumeric: error +odo-without-to: ok + +# Value: any single character +default-currency-symbol: $ + +# Value: int +max-alpha-character-data-size: 2147483647 +max-sjis-character-data-size: 1073741823 +max-utf8-character-data-size: 715827882 + +# If yes, length of PROGRAM-ID of after translation is bigger than +# 31 characters, give warning. +c89-identifier-length-check: no + +# jp compatible +# Value: 'yes', 'no' +allow-end-program-with-wrong-name: no +allow-missing-also-clause-in-evaluate: no +allow-empty-imperative-statement: no +enable-program-status-register: no +enable-sort-status-register: no +enable-special-names-argument-clause: no +enable-special-names-environment-clause: no +enable-leng-intrinsic-function: no +enable-length-an-intrinsic-function: no +enable-national-intrinsic-function: no +use-invalidkey-handler-on-status34: no +cobol68-copy-in-data-description: no +switch-no-mnemonic: no +allow-is-in-sort-key-spec: no +allow-search-key-in-rhs: no +ignore-invalid-record-contains: no +enable-zero-division-error: no +enable-check-subscript-out-of-bounds: no +enable-expect-numeric-error: no +enable-expect-compute-string-error: no