Skip to content

Commit

Permalink
Merge SVN 4420, 4421
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Jun 18, 2024
1 parent b30cdff commit d70ef10
Show file tree
Hide file tree
Showing 22 changed files with 107 additions and 101 deletions.
9 changes: 9 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,15 @@
* cobc.c: removed unused aflag_set, renamed gflag_set to source_debugging
* cobc.c (process) [__OS400__]: simplified source-debugging handling

2021-10-19 Simon Sobisch <[email protected]>

* config.def (larger-redefines): changed to support option from boolean
larger-redefines-ok
* warning.def (cb_warn_larger_01_redefines): new warning for possibly
problematic but allowed level 01 non-external REDEFINE
* field.c (compute_size): cater for cb_larger_redefines and
cb_warn_larger_01_redefines

2021-10-18 Simon Sobisch <[email protected]>

* field.c (cb_build_full_field_reference): fix bug #776
Expand Down
7 changes: 4 additions & 3 deletions cobc/config.def
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ CB_CONFIG_BOOLEAN (cb_odoslide, "odoslide",
CB_CONFIG_BOOLEAN (cb_indirect_redefines, "indirect-redefines",
_("allow REDEFINES to other than last equal level number"))

CB_CONFIG_BOOLEAN (cb_larger_redefines_ok, "larger-redefines-ok", /* TO-DO: change to CB_CONFIG_SUPPORT */
_("allow larger REDEFINES items"))

CB_CONFIG_BOOLEAN (cb_relaxed_syntax_checks, "relax-syntax-checks",
_("allow certain syntax variations (e.g. REDEFINES position)"))

Expand Down Expand Up @@ -331,6 +328,10 @@ CB_CONFIG_SUPPORT (cb_accept_display_extensions, "accept-display-extensions",
CB_CONFIG_SUPPORT (cb_renames_uncommon_levels, "renames-uncommon-levels",
_("RENAMES of 01-, 66- and 77-level items"))

/* larger REDEFINES items other than 01 non-external */
CB_CONFIG_SUPPORT (cb_larger_redefines, "larger-redefines",
_("allow larger REDEFINES items"))

CB_CONFIG_SUPPORT (cb_symbolic_constant, "symbolic-constant",
_("constants defined in SPECIAL-NAMES"))

Expand Down
40 changes: 21 additions & 19 deletions cobc/field.c
Original file line number Diff line number Diff line change
Expand Up @@ -2711,7 +2711,7 @@ compute_size (struct cb_field *f)
&& !(f->report_flag & COB_REPORT_LINE_PLUS)
&& f->parent
&& f->parent->children != f) {
for(c = f->parent->children; c && c != f; c = c->sister) {
for (c = f->parent->children; c && c != f; c = c->sister) {
if ((c->report_flag & COB_REPORT_LINE)
&& !(c->report_flag & COB_REPORT_LINE_PLUS)
&& c->report_line == f->report_line) {
Expand Down Expand Up @@ -2742,10 +2742,7 @@ compute_size (struct cb_field *f)
if (c->level != 66
&& c->size * c->occurs_max >
c->redefines->size * c->redefines->occurs_max) {
if (cb_larger_redefines_ok) {
cb_warning_x (cb_warn_additional, CB_TREE (c),
_("size of '%s' larger than size of '%s'"),
c->name, c->redefines->name);
if (cb_verify_x (CB_TREE (c), cb_larger_redefines, _("larger REDEFINES"))) {
maxsz = c->redefines->size * c->redefines->occurs_max;
for (c0 = c->redefines->sister; c0 != c; c0 = c0->sister) {
if (c0->size * c0->occurs_max > maxsz) {
Expand All @@ -2755,10 +2752,11 @@ compute_size (struct cb_field *f)
if (c->size * c->occurs_max > maxsz) {
size_check += ((cob_s64_t)c->size * c->occurs_max) - maxsz;
}
} else {
cb_error_x (CB_TREE (c),
_("size of '%s' larger than size of '%s'"),
c->name, c->redefines->name);
}
if (cb_larger_redefines >= CB_WARNING) {
cb_note_x (cb_warn_dialect, CB_TREE (c),
_("size of '%s' larger than size of '%s'"),
c->name, c->redefines->name);
}
}
} else {
Expand Down Expand Up @@ -3063,18 +3061,22 @@ compute_size (struct cb_field *f)
}
}

/* The size of redefining field should not be larger than
the size of redefined field unless the redefined field
is level 01 and non-external */
if (f->redefines
&& f->redefines->flag_external
/* COBOL standard: The size of redefining field should not be larger
than the size of redefined field unless the redefined field is
level 01 and non-external */
if (f->level == 1 && f->redefines
&& (f->size * f->occurs_max > f->redefines->size * f->redefines->occurs_max)) {
if (cb_larger_redefines_ok) {
cb_warning_x (cb_warn_additional, CB_TREE (f),
_("size of '%s' larger than size of '%s'"),
f->name, f->redefines->name);
/* note: when allowed the redefined field is NOT size-adjusted here */
if (f->redefines->flag_external) {
if (!cb_verify_x (CB_TREE (f), cb_larger_redefines, _("larger REDEFINES"))
|| cb_larger_redefines == CB_WARNING) {
cb_note_x (cb_warn_dialect, CB_TREE (f),
_("size of '%s' larger than size of '%s'"),
f->name, f->redefines->name);
}
} else {
cb_error_x (CB_TREE (f), _("size of '%s' larger than size of '%s'"),
cb_warning_x (cb_warn_larger_01_redefines, CB_TREE (f),
_("size of '%s' larger than size of '%s'"),
f->name, f->redefines->name);
}
}
Expand Down
3 changes: 3 additions & 0 deletions cobc/warning.def
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ CB_WARNDEF (cb_warn_constant_expr, "constant-expression",
CB_WARNDEF (cb_warn_constant_numlit_expr, "constant-numlit-expression",
_(" -Wconstant-numlit-expression\twarn about numeric expressions that always resolve to true/false"))

CB_WARNDEF (cb_warn_larger_01_redefines, "larger-01-redefines",
_(" -Wlarger-01-redefines warn about larger redefines allowed by COBOL standards"))

CB_NOWARNDEF (cb_warn_column_overflow, "column-overflow",
_(" -Wcolumn-overflow warn about text after program-text area, FIXED format"))

Expand Down
18 changes: 5 additions & 13 deletions config/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@

* Added 'record-sequential-advancing' initial value

2021-10-19 Simon Sobisch <[email protected]>

* general: changed larger-redefines-ok (boolean) to larger-redefines,
now a support option allowing "warning only"

2021-10-01 Ron Norman <[email protected]>

* runtime.cfg: Removed the COB_MF_LS_xxx options and replaced COB_MF_FILES
Expand Down Expand Up @@ -104,19 +109,6 @@

* fileio: added option file_log for ISAM files

||||||| .merge-left.r4286
=======
2021-07-29 Simon Sobisch <[email protected]>

* general: added self-call-recursive, only active (as "warning") for
default.conf, in all other cases no change to RECURSIVE attribute
is happening any more, fixing bug 686

2021-02-03 Simon Sobisch <[email protected]>

* acu-strict.conf: fix settings indirect-redefines + assign-variable

>>>>>>> .merge-right.r4287
2020-11-08 Simon Sobisch <[email protected]>

* general: added ref-mod-zero-length, only active for default.conf
Expand Down
4 changes: 2 additions & 2 deletions config/acu-strict.conf
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ binary-truncate: yes
# Value: 'native', 'big-endian'
binary-byteorder: big-endian

# Allow larger REDEFINES items
larger-redefines-ok: no # not verified yet
# Allow larger REDEFINES items other than 01 non-external
larger-redefines: ok # not verified yet

# Allow certain syntax variations (eg. REDEFINES position)
relax-syntax-checks: yes
Expand Down
4 changes: 2 additions & 2 deletions config/bs2000-strict.conf
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ binary-truncate: yes # TO-DO: For BINARY, *not* for COMP or COMP-5!
# Value: 'native', 'big-endian'
binary-byteorder: big-endian

# Allow larger REDEFINES items
larger-redefines-ok: no # TO-DO: Except for level 01 items.
# Allow larger REDEFINES items other than 01 non-external
larger-redefines: error

# Allow certain syntax variations (eg. REDEFINES position)
relax-syntax-checks: no
Expand Down
4 changes: 2 additions & 2 deletions config/cobol2002.conf
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ binary-truncate: yes
# Value: 'native', 'big-endian'
binary-byteorder: big-endian

# Allow larger REDEFINES items
larger-redefines-ok: no
# Allow larger REDEFINES items other than 01 non-external
larger-redefines: error

# Allow certain syntax variations (eg. REDEFINES position)
relax-syntax-checks: no
Expand Down
4 changes: 2 additions & 2 deletions config/cobol2014.conf
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ binary-truncate: yes
# Value: 'native', 'big-endian'
binary-byteorder: big-endian

# Allow larger REDEFINES items
larger-redefines-ok: no
# Allow larger REDEFINES items other than 01 non-external
larger-redefines: error

# Allow certain syntax variations (eg. REDEFINES position)
relax-syntax-checks: no
Expand Down
4 changes: 2 additions & 2 deletions config/cobol85.conf
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ binary-truncate: yes
# Value: 'native', 'big-endian'
binary-byteorder: big-endian

# Allow larger REDEFINES items
larger-redefines-ok: no
# Allow larger REDEFINES items other than 01 non-external
larger-redefines: error

# Allow certain syntax variations (eg. REDEFINES position)
relax-syntax-checks: no
Expand Down
4 changes: 2 additions & 2 deletions config/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ binary-truncate: yes
# Value: 'native', 'big-endian'
binary-byteorder: big-endian

# Allow larger REDEFINES items
larger-redefines-ok: no
# Allow larger REDEFINES items other than 01 non-external
larger-redefines: error

# Allow certain syntax variations (eg. REDEFINES position)
relax-syntax-checks: no
Expand Down
4 changes: 2 additions & 2 deletions config/gcos-strict.conf
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ binary-truncate: yes
# Value: 'native', 'big-endian'
binary-byteorder: big-endian

# Allow larger REDEFINES items
larger-redefines-ok: no
# Allow larger REDEFINES items other than 01 non-external
larger-redefines: error

# Allow certain syntax variations (eg. REDEFINES position)
relax-syntax-checks: yes
Expand Down
4 changes: 2 additions & 2 deletions config/ibm-strict.conf
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ binary-truncate: no
# Value: 'native', 'big-endian'
binary-byteorder: big-endian

# Allow larger REDEFINES items
larger-redefines-ok: no
# Allow larger REDEFINES items other than 01 non-external
larger-redefines: error

# Allow certain syntax variations (eg. REDEFINES position)
relax-syntax-checks: no
Expand Down
4 changes: 2 additions & 2 deletions config/lax.conf-inc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ complex-odo: yes
# Allow REDEFINES to other than last equal level number
indirect-redefines: yes

# Allow larger REDEFINES items
larger-redefines-ok: yes
# Allow larger REDEFINES items other than 01 non-external
larger-redefines: +warning

# Allow certain syntax variations (eg. REDEFINES position)
relax-syntax-checks: yes
Expand Down
4 changes: 2 additions & 2 deletions config/mf-strict.conf
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ binary-truncate: no
# Value: 'native', 'big-endian'
binary-byteorder: big-endian

# Allow larger REDEFINES items
larger-redefines-ok: yes
# Allow larger REDEFINES items other than 01 non-external
larger-redefines: ok

# Allow certain syntax variations (eg. REDEFINES position)
relax-syntax-checks: yes
Expand Down
4 changes: 2 additions & 2 deletions config/mvs-strict.conf
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ binary-truncate: no
# Value: 'native', 'big-endian'
binary-byteorder: big-endian

# Allow larger REDEFINES items
larger-redefines-ok: no
# Allow larger REDEFINES items other than 01 non-external
larger-redefines: error

# Allow certain syntax variations (eg. REDEFINES position)
relax-syntax-checks: no
Expand Down
8 changes: 4 additions & 4 deletions config/realia-strict.conf
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ numeric-literal-length: 18 # to check
pic-length: 100 # to check
occurs-max-length-without-subscript: yes # to check

# Value: 'mf', 'ibm'
#
# Default assign type
# Value: 'dynamic', 'external'
assign-clause: dynamic # to check

# If yes, file names are resolved at run time using
Expand Down Expand Up @@ -95,8 +95,8 @@ binary-truncate: no # to check
# Value: 'native', 'big-endian'
binary-byteorder: big-endian # to check

# Allow larger REDEFINES items
larger-redefines-ok: no # not verified yet
# Allow larger REDEFINES items other than 01 non-external
larger-redefines: error # not verified yet

# Allow certain syntax variations (eg. REDEFINES position)
relax-syntax-checks: no # to check
Expand Down
4 changes: 2 additions & 2 deletions config/rm-strict.conf
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ binary-truncate: yes
# Value: 'native', 'big-endian'
binary-byteorder: big-endian

# Allow larger REDEFINES items
larger-redefines-ok: yes # TO-DO: But only for 01 items (see p. 134)
# Allow larger REDEFINES items other than 01 non-external
larger-redefines: ok # (see p. 134)

# Allow certain syntax variations (eg. REDEFINES position)
relax-syntax-checks: yes # TO-DO: For REDEFINES position, at least.
Expand Down
4 changes: 2 additions & 2 deletions config/xopen.conf
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ binary-truncate: yes
# Value: 'native', 'big-endian'
binary-byteorder: big-endian

# Allow larger REDEFINES items
larger-redefines-ok: no
# Allow larger REDEFINES items other than 01 non-external
larger-redefines: error

# Allow certain syntax variations (eg. REDEFINES position)
relax-syntax-checks: no
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite.src/configuration.at
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ test.conf: missing definitions:
no definition of 'complex-odo'
no definition of 'odoslide'
no definition of 'indirect-redefines'
no definition of 'larger-redefines-ok'
no definition of 'relax-syntax-checks'
no definition of 'ref-mod-zero-length'
no definition of 'relax-level-hierarchy'
Expand Down Expand Up @@ -503,6 +502,7 @@ test.conf: missing definitions:
no definition of 'not-exception-before-exception'
no definition of 'accept-display-extensions'
no definition of 'renames-uncommon-levels'
no definition of 'larger-redefines'
no definition of 'symbolic-constant'
no definition of 'constant-78'
no definition of 'constant-01'
Expand Down
35 changes: 8 additions & 27 deletions tests/testsuite.src/run_extensions.at
Original file line number Diff line number Diff line change
Expand Up @@ -3588,46 +3588,27 @@ AT_DATA([prog.cob], [
PROCEDURE DIVISION.
MOVE LENGTH OF XMAIN TO Z.
IF Z NOT = 8
DISPLAY "Test 1 " Z
END-DISPLAY
END-IF.
DISPLAY "Test 1 " Z.
MOVE LENGTH OF XMAINRED TO Z.
IF Z NOT = 9
DISPLAY "Test 2 " Z
END-DISPLAY
END-IF.
DISPLAY "Test 2 " Z.
MOVE LENGTH OF XMAIN03 TO Z.
IF Z NOT = 5
DISPLAY "Test 3 " Z
END-DISPLAY
END-IF.
DISPLAY "Test 3 " Z.
MOVE LENGTH OF XMAIN0501 TO Z.
IF Z NOT = 4
DISPLAY "Test 4 " Z
END-DISPLAY
END-IF.
DISPLAY "Test 4 " Z.
MOVE LENGTH OF XMAIN0502 TO Z.
IF Z NOT = 5
DISPLAY "Test 5 " Z
END-DISPLAY
END-IF.
DISPLAY "Test 5 " Z.
IF LENGTH OF USE-FIRST NOT = 33211
DISPLAY LENGTH OF USE-FIRST END-DISPLAY
END-IF.
DISPLAY LENGTH OF USE-FIRST END-DISPLAY.
IF LENGTH OF USE-SECOND NOT = 27241
DISPLAY LENGTH OF USE-SECOND END-DISPLAY
END-IF.
DISPLAY LENGTH OF USE-SECOND END-DISPLAY.
STOP RUN.
])

AT_CHECK([$COMPILE -flarger-redefines-ok -Wno-constant-expression prog.cob], [0], [],
[prog.cob:12: warning: size of 'XMAIN0502' larger than size of 'XMAIN0501'
prog.cob:21: warning: size of 'FIRST-VARIANT-A' larger than size of 'FIRST-DATA'
prog.cob:23: warning: size of 'FIRST-VARIANT-B' larger than size of 'FIRST-DATA'
prog.cob:25: warning: size of 'FIRST-VARIANT-C' larger than size of 'FIRST-DATA'
prog.cob:31: warning: size of 'SECOND-VARIANT-A' larger than size of 'SECOND-HEADER'
prog.cob:33: warning: size of 'SECOND-VARIANT-B' larger than size of 'SECOND-HEADER'
])
AT_CHECK([$COMPILE -flarger-redefines=ok -w prog.cob], [0], [], [])
AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [], [])
AT_CLEANUP

Expand Down
Loading

0 comments on commit d70ef10

Please sign in to comment.