Skip to content

Commit b079403

Browse files
committed
Merge branch 'release/v1.5.2J'
2 parents f426214 + 1a9c2a6 commit b079403

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+24425
-32714
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2019-04-19 OSS Consortium <[email protected]>
2+
3+
* opensource COBOL Version 1.5.2J released.
4+
15
2016-12-09 OSS Consortium <[email protected]>
26

37
* opensource COBOL Version 1.5.1J released.

NEWS

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,44 @@
11
NEWS - user visible changes -*- outline -*-
22

3+
* Changes in opensource COBOL 1.5.2J
4+
5+
** New features
6+
7+
*** ADD new Error check.
8+
(1) Detected division by zero.
9+
Compile check: use the character "0".
10+
Runtime check: use variable with value 0.
11+
12+
Use this option, Add the following values to config.
13+
enable-zero-division-error: yes
14+
15+
(2) Check subscript out of bounds.
16+
This feature was previously included in the debug options.
17+
18+
Use this option, Add the following values to config.
19+
enable-check-subscript-out-of-bounds: yes
20+
21+
(3) Expect numeric error.
22+
Compile check: Move const string to numeric variable.
23+
Runtime check: Move variable included string to numeric variable.
24+
25+
Use this option, Add the following values to config.
26+
enable-expect-numeric-error: yes
27+
28+
(4) Expect compute string error.
29+
This feature was previously included in the debug options.
30+
31+
Use this option, Add the following values to config.
32+
enable-expect-compute-string-error: yes
33+
34+
35+
** Bug fixes
36+
37+
*** Correct errors in Japanese translation on cobc help.
38+
39+
40+
-----------------------------------------------------------------------
41+
342
* Changes in opensource COBOL 1.5.1J
443

544
** Bug fixes

cobc/cobc.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ cobc_sig_handler (int sig)
817817
static void
818818
cobc_print_version (void)
819819
{
820-
puts ("opensource COBOL 1.5.1J");
820+
puts ("opensource COBOL 1.5.2J");
821821
puts ("OSS Consortium's patched version of OpenCOBOL1.1(Feb.06 2009)");
822822
#ifdef I18N_UTF8
823823
puts ("[unicode/utf-8 support]");
@@ -2327,6 +2327,15 @@ main (int argc, char *argv[])
23272327
/* Process command line arguments */
23282328
iargs = process_command_line (argc, argv);
23292329

2330+
/* Process config file options */
2331+
if (cb_enable_check_subscript_out_of_bounds) {
2332+
CB_EXCEPTION_ENABLE (COB_EC_BOUND_SUBSCRIPT) = 1;
2333+
}
2334+
if (cb_enable_expect_compute_string_error) {
2335+
CB_EXCEPTION_ENABLE (COB_EC_DATA_INCOMPATIBLE) = 1;
2336+
}
2337+
2338+
23302339
/* Check the filename */
23312340
if (iargs == argc) {
23322341
fprintf (stderr, "cobc: No input files\n");

cobc/codegen.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
* it under the terms of the GNU General Public License as published by
77
* the Free Software Foundation; either version 2, or (at your option)
88
* any later version.
9-
*
9+
*
1010
* This program is distributed in the hope that it will be useful,
1111
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1212
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313
* GNU General Public License for more details.
14-
*
14+
*
1515
* You should have received a copy of the GNU General Public License
1616
* along with this software; see the file COPYING. If not, write to
1717
* the Free Software Foundation, 51 Franklin Street, Fifth Floor
@@ -1594,7 +1594,7 @@ initialize_type (struct cb_initialize *p, struct cb_field *f, int topfield)
15941594
} else if (cb_tree_type (CB_TREE (f)) == COB_TYPE_NUMERIC_DISPLAY) {
15951595
if (f->flag_sign_separate) {
15961596
return INITIALIZE_ONE;
1597-
} else if (cb_display_sign == COB_DISPLAY_SIGN_EBCDIC
1597+
} else if (cb_display_sign == COB_DISPLAY_SIGN_EBCDIC
15981598
&& f->pic->have_sign) {
15991599
return INITIALIZE_ONE;
16001600
} else {
@@ -3267,6 +3267,12 @@ output_stmt (cb_tree x)
32673267
output_line ("cob_exception_code = 0;");
32683268
}
32693269

3270+
if (cb_enable_zero_division_error && p->name &&
3271+
((strcmp (p->name, "DIVIDE") == 0) || (strcmp (p->name, "COMPUTE") == 0)) &&
3272+
(!p->handler1 && !p->handler2)) {
3273+
output_line ("cob_error_on_exit_flag = 1;");
3274+
}
3275+
32703276
if (p->null_check) {
32713277
output_stmt (p->null_check);
32723278
}

cobc/config.def

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
* it under the terms of the GNU General Public License as published by
77
* the Free Software Foundation; either version 2, or (at your option)
88
* any later version.
9-
*
9+
*
1010
* This program is distributed in the hope that it will be useful,
1111
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1212
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313
* GNU General Public License for more details.
14-
*
14+
*
1515
* You should have received a copy of the GNU General Public License
1616
* along with this software; see the file COPYING. If not, write to
1717
* the Free Software Foundation, 51 Franklin Street, Fifth Floor
@@ -59,6 +59,10 @@ CB_CONFIG_BOOLEAN (cb_switch_no_mnemonic, "switch-no-mnemonic")
5959
CB_CONFIG_BOOLEAN (cb_allow_is_in_sort_key_spec, "allow-is-in-sort-key-spec")
6060
CB_CONFIG_BOOLEAN (cb_allow_search_key_in_rhs, "allow-search-key-in-rhs")
6161
CB_CONFIG_BOOLEAN (cb_ignore_invalid_record_contains, "ignore-invalid-record-contains")
62+
CB_CONFIG_BOOLEAN (cb_enable_zero_division_error, "enable-zero-division-error")
63+
CB_CONFIG_BOOLEAN (cb_enable_check_subscript_out_of_bounds, "enable-check-subscript-out-of-bounds")
64+
CB_CONFIG_BOOLEAN (cb_enable_expect_numeric_error, "enable-expect-numeric-error")
65+
CB_CONFIG_BOOLEAN (cb_enable_expect_compute_string_error, "enable-expect-compute-string-error")
6266
CB_CONFIG_SUPPORT (cb_author_paragraph, "author-paragraph")
6367
CB_CONFIG_SUPPORT (cb_memory_size_clause, "memory-size-clause")
6468
CB_CONFIG_SUPPORT (cb_multiple_file_tape_clause, "multiple-file-tape-clause")

cobc/tree.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ cb_build_picture (const char *str)
13241324
if (count_value == 0) {
13251325
goto error;
13261326
} else if (count_value == CHARACTER_LENGTH_OVERFLOW) {
1327-
n = CHARACTER_LENGTH_OVERFLOW;
1327+
n = CHARACTER_LENGTH_OVERFLOW;
13281328
} else if (n != CHARACTER_LENGTH_OVERFLOW) {
13291329
remain = INT_MAX - n;
13301330
if (remain < (count_value - 1)) {
@@ -1837,7 +1837,7 @@ static void
18371837
compute_composite_key (cb_tree key, struct cb_key_component *component_list)
18381838
{
18391839
int cb;
1840-
char pic[32];
1840+
char pic[32];
18411841
struct cb_key_component *key_component;
18421842
struct cb_field *composite_key;
18431843

@@ -1883,7 +1883,7 @@ finalize_file (struct cb_file *f, struct cb_field *records)
18831883
compute_composite_key (alt_key->key, alt_key->component_list);
18841884
}
18851885
}
1886-
}
1886+
}
18871887

18881888
/* check the record size if it is limited */
18891889
if (cb_ignore_invalid_record_contains) {
@@ -2251,6 +2251,12 @@ cb_build_binary_op (cb_tree x, int op, cb_tree y)
22512251
if (x == cb_error_node || y == cb_error_node) {
22522252
return cb_error_node;
22532253
}
2254+
if (cb_enable_zero_division_error && op == '/') {
2255+
y = cb_check_zero_division (y);
2256+
if (y == cb_error_node) {
2257+
return cb_error_node;
2258+
}
2259+
}
22542260
category = CB_CATEGORY_NUMERIC;
22552261
break;
22562262

cobc/tree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ extern int cb_fits_long_long (cb_tree x);
260260
extern int cb_get_int (cb_tree x);
261261
extern int cb_is_digist_data (cb_tree x);
262262
extern long long cb_get_long_long (cb_tree x);
263+
extern cb_tree cb_check_zero_division(cb_tree x);
263264

264265
/*
265266
* Constants

cobc/typeck.c

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4689,6 +4689,56 @@ move_error (cb_tree src, cb_tree dst, const size_t value_flag, const int flag,
46894689
return 0;
46904690
}
46914691

4692+
static void
4693+
error_destination (cb_tree x)
4694+
{
4695+
struct cb_reference *r;
4696+
struct cb_field *f;
4697+
cb_tree loc;
4698+
4699+
r = CB_REFERENCE (x);
4700+
f = CB_FIELD (r->value);
4701+
loc = CB_TREE (f);
4702+
4703+
if (r->offset) {
4704+
return;
4705+
}
4706+
4707+
if (!strcmp (f->name, "RETURN-CODE") ||
4708+
!strcmp (f->name, "SORT-RETURN") ||
4709+
!strcmp (f->name, "NUMBER-OF-CALL-PARAMETERS")) {
4710+
cb_error (_("Internal register '%s' defined as BINARY-LONG"), f->name);
4711+
} else if (f->pic) {
4712+
cb_error_x (loc, _("'%s' defined here as PIC %s"), check_filler_name ((char *)f->name), f->pic->orig);
4713+
} else {
4714+
cb_error_x (loc, _("'%s' defined here as a group of length %d"), check_filler_name ((char *)f->name), f->size);
4715+
}
4716+
}
4717+
4718+
static int
4719+
move_error2 (cb_tree src, cb_tree dst, const size_t value_flag, const int flag,
4720+
const int src_flag, const char *msg)
4721+
{
4722+
cb_tree loc;
4723+
4724+
loc = src->source_line ? src : dst;
4725+
if (value_flag) {
4726+
/* VALUE clause */
4727+
cb_error_x (loc, msg);
4728+
} else {
4729+
/* MOVE statement */
4730+
if (flag) {
4731+
cb_error_x (loc, msg);
4732+
if (src_flag) {
4733+
error_destination (src);
4734+
}
4735+
error_destination (dst);
4736+
}
4737+
}
4738+
4739+
return 0;
4740+
}
4741+
46924742
/* count the number of free places in an alphanumeric edited field */
46934743
static int
46944744
count_pic_alphanumeric_edited (struct cb_field *field)
@@ -5335,6 +5385,11 @@ validate_move (cb_tree src, cb_tree dst, size_t is_value)
53355385
return 0;
53365386

53375387
expect_numeric:
5388+
if (cb_enable_expect_numeric_error) {
5389+
return move_error2 (src, dst, is_value, 1, 0,
5390+
_("Numeric value is expected"));
5391+
}
5392+
53385393
return move_error (src, dst, is_value, cb_warn_strict_typing, 0,
53395394
_("Numeric value is expected"));
53405395

@@ -6029,6 +6084,11 @@ cb_emit_move (cb_tree src, cb_tree dsts)
60296084
}
60306085

60316086
for (l = dsts; l; l = CB_CHAIN (l)) {
6087+
if (cb_enable_expect_numeric_error) {
6088+
if (CB_TREE_TAG (src) == CB_TAG_REFERENCE) {
6089+
cb_emit (cb_build_funcall_2 ("cob_check_mvstrnum", src, CB_VALUE (l)));
6090+
}
6091+
}
60326092
cb_emit (cb_build_move (src, CB_VALUE (l)));
60336093
}
60346094
}
@@ -7717,3 +7777,22 @@ cb_build_write_advancing_page (cb_tree pos)
77177777

77187778
return cb_int (opt | COB_WRITE_PAGE);
77197779
}
7780+
7781+
cb_tree
7782+
cb_check_zero_division (cb_tree x)
7783+
{
7784+
if (x == cb_error_node) {
7785+
return cb_error_node;
7786+
}
7787+
7788+
if (! CB_NUMERIC_LITERAL_P (x)) {
7789+
return x;
7790+
}
7791+
7792+
if (cb_get_int(x) == 0) {
7793+
cb_error_x (x, _("Detected division by zero."));
7794+
return cb_error_node;
7795+
}
7796+
7797+
return x;
7798+
}

config/default-en.conf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ assign-clause: mf
2222
# 3. the value of environment variable 'DATAFILE' or
2323
# 4. the literal "DATAFILE"
2424
# If no, the value of the assign clause is the file name.
25-
#
25+
#
2626
# Value: 'yes', 'no'
2727
filename-mapping: yes
2828

@@ -87,7 +87,7 @@ sticky-linkage: no
8787

8888
# If yes, set the file assign to the external file
8989
# Value: 'yes', 'no'
90-
assign_external: no
90+
assign_external: no
9191

9292
# If yes, allow non-matching level numbers
9393
# Value: 'yes', 'no'
@@ -147,3 +147,7 @@ switch-no-mnemonic: no
147147
allow-is-in-sort-key-spec: no
148148
allow-search-key-in-rhs: no
149149
ignore-invalid-record-contains: no
150+
enable-zero-division-error: no
151+
enable-check-subscript-out-of-bounds: yes
152+
enable-expect-numeric-error: yes
153+
enable-expect-compute-string-error: yes

config/default-jp.conf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ assign-clause: mf
2222
# 3. the value of environment variable 'DATAFILE' or
2323
# 4. the literal "DATAFILE"
2424
# If no, the value of the assign clause is the file name.
25-
#
25+
#
2626
# Value: 'yes', 'no'
2727
filename-mapping: yes
2828

@@ -87,7 +87,7 @@ sticky-linkage: no
8787

8888
# If yes, set the file assign to the external file
8989
# Value: 'yes', 'no'
90-
assign_external: no
90+
assign_external: no
9191

9292
# If yes, allow non-matching level numbers
9393
# Value: 'yes', 'no'
@@ -147,3 +147,7 @@ switch-no-mnemonic: no
147147
allow-is-in-sort-key-spec: no
148148
allow-search-key-in-rhs: no
149149
ignore-invalid-record-contains: no
150+
enable-zero-division-error: yes
151+
enable-check-subscript-out-of-bounds: yes
152+
enable-expect-numeric-error: yes
153+
enable-expect-compute-string-error: yes

0 commit comments

Comments
 (0)