Skip to content

Commit

Permalink
Merge SVN 4980
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Sep 16, 2024
1 parent 8d77c10 commit 99e6c28
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 47 deletions.
7 changes: 7 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@
* tree.c: Change to use cb_max_binary instead of constant
* typeck.c: Change to use cb_max_binary instead of constant

2023-02-10 Simon Sobisch <[email protected]>

* cobc.c (clean_up_intermediates): fix missing move of temporary files
when --save-temps=dir is used in combination with -g
* field.c (cb_build_field_tree), tree.h, parser.y: pass level number as
integer, not as cb_tree

2023-02-09 Simon Sobisch <[email protected]>

* typeck.c (validate_alphabet): slightly rewritten to fix compiler warnings
Expand Down
2 changes: 1 addition & 1 deletion cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1974,7 +1974,7 @@ clean_up_intermediates (struct filename *fn, const int status)
lf->local_fp = NULL;
}
}
if (save_all_src) {
if (save_all_src && !save_temps_dir) {
return;
}
if (fn->need_preprocess
Expand Down
8 changes: 4 additions & 4 deletions cobc/field.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ cb_get_level (cb_tree x)
}

cb_tree
cb_build_field_tree (cb_tree level, cb_tree name, struct cb_field *last_field,
cb_build_field_tree (const int level, cb_tree name, struct cb_field *last_field,
enum cb_storage storage, struct cb_file *fn,
const int expl_level)
{
Expand All @@ -426,7 +426,7 @@ cb_build_field_tree (cb_tree level, cb_tree name, struct cb_field *last_field,
return cb_error_node;
}
/* Check the level number */
lv = cb_get_level (level);
lv = level;
#if 0 /*level is always valid --> 01 thru 49, 77, 66, 78, 88 */
if (!lv) {
return cb_error_node;
Expand Down Expand Up @@ -694,10 +694,10 @@ copy_duplicated_field_into_field (struct cb_field *field, struct cb_field *targe
{
cb_tree x;
if (!field->flag_filler && field->name) {
x = cb_build_field_tree (NULL, cb_build_reference (field->name),
x = cb_build_field_tree (0, cb_build_reference (field->name),
target, storage, NULL, level);
} else {
x = cb_build_field_tree (NULL, cb_build_filler (),
x = cb_build_field_tree (0, cb_build_filler (),
target, storage, NULL, level);
}
if (x == cb_error_node) {
Expand Down
48 changes: 19 additions & 29 deletions cobc/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -1604,12 +1604,10 @@ error_if_record_delimiter_incompatible (const enum cob_file_org organization,
}

static int
set_current_field (cb_tree level, cb_tree name)
set_current_field (int level, cb_tree name)
{
cb_tree x = cb_build_field_tree (level, name, current_field,
current_storage, current_file, 0);
/* Free tree associated with level number */
cobc_parse_free (level);

if (CB_INVALID_TREE (x)) {
return 1;
Expand Down Expand Up @@ -1711,7 +1709,7 @@ setup_external_definition_type (cb_tree x)
inherits the definition of the original field specified
by SAME AS or by type_name */
static void
inherit_external_definition (cb_tree lvl)
inherit_external_definition (const int lvl)
{
/* note: REDEFINES (clause 1) is allowed with RM/COBOL but not COBOL 2002+ */
static const cob_flags_t allowed_clauses =
Expand All @@ -1726,11 +1724,11 @@ inherit_external_definition (cb_tree lvl)
current_field->flag_invalid = 1;
} else {
struct cb_field *fld = CB_FIELD (current_field->external_definition);
int new_level = lvl ? cb_get_level (lvl) : 0;
int new_level = lvl;
int old_level = current_field->level;
copy_into_field (fld, current_field);
if (new_level > 1 && new_level < 66 && new_level > old_level) {
cb_error_x (lvl, _("entry following %s may not be subordinate to it"),
cb_error (_("entry following %s may not be subordinate to it"),
fld->flag_is_typedef ? "TYPE TO" : "SAME AS");
}
}
Expand All @@ -1743,7 +1741,7 @@ get_finalized_description_tree (void)

/* finalize last field if target of SAME AS / TYPEDEF */
if (current_field && !CB_INVALID_TREE (current_field->external_definition)) {
inherit_external_definition (NULL);
inherit_external_definition (0);
}

/* validate the complete current "block" */
Expand Down Expand Up @@ -6961,11 +6959,12 @@ data_description:
| condition_name_entry
| level_number _entry_name
{
const int level = cb_get_level ($1);
if (current_field && !CB_INVALID_TREE (current_field->external_definition)) {
/* finalize last field if target of SAME AS / type-name */
inherit_external_definition ($1);
inherit_external_definition (level);
}
if (set_current_field ($1, $2)) {
if (set_current_field (level, $2)) {
YYERROR;
}
save_tree = NULL;
Expand All @@ -6981,10 +6980,6 @@ data_description:
}
| level_number error TOK_DOT
{
#if 0 /* works fine without, leads to invalid free otherwise [COB_TREE_DEBUG] */
/* Free tree associated with level number */
cobc_parse_free ($1);
#endif
yyerrok;
cb_unput_dot ();
check_pic_duplicate = 0;
Expand All @@ -6998,7 +6993,7 @@ data_description:
level_number:
not_const_word LEVEL_NUMBER
{
int level = cb_get_level ($2);
const int level = cb_get_level ($2);
switch (level) {
case 1:
case 77:
Expand Down Expand Up @@ -7175,7 +7170,7 @@ renames_entry:

non_const_word = 0;

if (set_current_field ($1, $2)) {
if (set_current_field (66, $2)) {
/* error in the definition, no further checks possible */
} else if (renames_target == cb_error_node) {
/* error in the target, skip further checks */
Expand Down Expand Up @@ -7222,7 +7217,7 @@ _renames_thru:
condition_name_entry:
EIGHTY_EIGHT _user_entry_name
{
if (set_current_field ($1, $2)) {
if (set_current_field (88, $2)) {
YYERROR;
}
}
Expand All @@ -7247,12 +7242,9 @@ constant_entry:
level_number user_entry_name CONSTANT _const_global constant_source
{
cb_tree x;
int level;
const int level = cb_get_level ($1);

cobc_cs_check = 0;
level = cb_get_level ($1);
/* Free tree associated with level number */
cobc_parse_free ($1);
if (level != 1) {
cb_error (_("CONSTANT item not at 01 level"));
} else if ($5) {
Expand All @@ -7273,7 +7265,7 @@ constant_entry:
}
| SEVENTY_EIGHT user_entry_name
{
if (set_current_field ($1, $2)) {
if (set_current_field (78, $2)) {
YYERROR;
}
}
Expand Down Expand Up @@ -9238,7 +9230,8 @@ _report_group_description_list:
report_group_description_entry:
level_number _entry_name
{
if (set_current_field ($1, $2)) {
const int level = cb_get_level ($1);
if (set_current_field (level, $2)) {
YYERROR;
}
if (!description_field) {
Expand All @@ -9251,11 +9244,6 @@ report_group_description_entry:
}
| level_number error _dot_or_else_end_of_report_group_description
{
/* Free tree associated with level number */
#if 0 /* works fine without, leads to invalid free otherwise [COB_TREE_DEBUG] */
/* Free tree associated with level number */
cobc_parse_free ($1);
#endif
yyerrok;
check_pic_duplicate = 0;
check_duplicate = 0;
Expand Down Expand Up @@ -9759,7 +9747,8 @@ screen_description:
/* normal screen definition */
| level_number _entry_name
{
if (set_current_field ($1, $2)) {
const int level = cb_get_level ($1);
if (set_current_field (level, $2)) {
YYERROR;
}
if (current_field->parent) {
Expand Down Expand Up @@ -9809,7 +9798,8 @@ screen_description:
/* ACUCOBOL-GT control definition */
| level_number _entry_name
{
if (set_current_field ($1, $2)) {
const int level = cb_get_level ($1);
if (set_current_field (level, $2)) {
YYERROR;
}
if (current_field->parent) {
Expand Down
2 changes: 1 addition & 1 deletion cobc/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -2340,7 +2340,7 @@ extern void output_xfd_file (struct cb_file *);
/* field.c */
extern size_t cb_needs_01;
extern int cb_get_level (cb_tree);
extern cb_tree cb_build_field_tree (cb_tree, cb_tree, struct cb_field *,
extern cb_tree cb_build_field_tree (const int, cb_tree, struct cb_field *,
enum cb_storage, struct cb_file *,
const int);
extern cb_tree cb_build_full_field_reference (struct cb_field *);
Expand Down
24 changes: 12 additions & 12 deletions cobc/typeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -4517,42 +4517,42 @@ cb_build_debug_item (void)

/* Set up DEBUG-ITEM */
l = cb_build_reference ("DEBUG-ITEM");
lvl01_tree = cb_build_field_tree (NULL, l, NULL, CB_STORAGE_WORKING,
lvl01_tree = cb_build_field_tree (0, l, NULL, CB_STORAGE_WORKING,
NULL, 1);
f = CB_FIELD (lvl01_tree);
f->values = CB_LIST_INIT (cb_space);
cb_debug_item = l;

l = cb_build_reference ("DEBUG-LINE");
x = cb_build_field_tree (NULL, l, f, CB_STORAGE_WORKING, NULL, 3);
x = cb_build_field_tree (0, l, f, CB_STORAGE_WORKING, NULL, 3);
f = CB_FIELD (x);
f->pic = cb_build_picture ("X(6)");
cb_validate_field (f);
cb_debug_line = l;

l = cb_build_filler ();
x = cb_build_field_tree (NULL, l, f, CB_STORAGE_WORKING, NULL, 3);
x = cb_build_field_tree (0, l, f, CB_STORAGE_WORKING, NULL, 3);
f = CB_FIELD (x);
f->pic = cb_build_picture ("X");
f->flag_filler = 1;
cb_validate_field (f);

l = cb_build_reference ("DEBUG-NAME");
x = cb_build_field_tree (NULL, l, f, CB_STORAGE_WORKING, NULL, 3);
x = cb_build_field_tree (0, l, f, CB_STORAGE_WORKING, NULL, 3);
f = CB_FIELD (x);
f->pic = cb_build_picture ("X(30)");
cb_validate_field (f);
cb_debug_name = l;

l = cb_build_filler ();
x = cb_build_field_tree (NULL, l, f, CB_STORAGE_WORKING, NULL, 3);
x = cb_build_field_tree (0, l, f, CB_STORAGE_WORKING, NULL, 3);
f = CB_FIELD (x);
f->pic = cb_build_picture ("X");
f->flag_filler = 1;
cb_validate_field (f);

l = cb_build_reference ("DEBUG-SUB-1");
x = cb_build_field_tree (NULL, l, f, CB_STORAGE_WORKING, NULL, 3);
x = cb_build_field_tree (0, l, f, CB_STORAGE_WORKING, NULL, 3);
f = CB_FIELD (x);
f->pic = cb_build_picture ("S9(4)");
f->flag_sign_leading = 1;
Expand All @@ -4561,14 +4561,14 @@ cb_build_debug_item (void)
cb_debug_sub_1 = l;

l = cb_build_filler ();
x = cb_build_field_tree (NULL, l, f, CB_STORAGE_WORKING, NULL, 3);
x = cb_build_field_tree (0, l, f, CB_STORAGE_WORKING, NULL, 3);
f = CB_FIELD (x);
f->pic = cb_build_picture ("X");
f->flag_filler = 1;
cb_validate_field (f);

l = cb_build_reference ("DEBUG-SUB-2");
x = cb_build_field_tree (NULL, l, f, CB_STORAGE_WORKING, NULL, 3);
x = cb_build_field_tree (0, l, f, CB_STORAGE_WORKING, NULL, 3);
f = CB_FIELD (x);
f->pic = cb_build_picture ("S9(4)");
f->flag_sign_leading = 1;
Expand All @@ -4577,14 +4577,14 @@ cb_build_debug_item (void)
cb_debug_sub_2 = l;

l = cb_build_filler ();
x = cb_build_field_tree (NULL, l, f, CB_STORAGE_WORKING, NULL, 3);
x = cb_build_field_tree (0, l, f, CB_STORAGE_WORKING, NULL, 3);
f = CB_FIELD (x);
f->pic = cb_build_picture ("X");
f->flag_filler = 1;
cb_validate_field (f);

l = cb_build_reference ("DEBUG-SUB-3");
x = cb_build_field_tree (NULL, l, f, CB_STORAGE_WORKING, NULL, 3);
x = cb_build_field_tree (0, l, f, CB_STORAGE_WORKING, NULL, 3);
f = CB_FIELD (x);
f->pic = cb_build_picture ("S9(4)");
f->flag_sign_leading = 1;
Expand All @@ -4593,14 +4593,14 @@ cb_build_debug_item (void)
cb_debug_sub_3 = l;

l = cb_build_filler ();
x = cb_build_field_tree (NULL, l, f, CB_STORAGE_WORKING, NULL, 3);
x = cb_build_field_tree (0, l, f, CB_STORAGE_WORKING, NULL, 3);
f = CB_FIELD (x);
f->pic = cb_build_picture ("X");
f->flag_filler = 1;
cb_validate_field (f);

l = cb_build_reference ("DEBUG-CONTENTS");
x = cb_build_field_tree (NULL, l, f, CB_STORAGE_WORKING, NULL, 3);
x = cb_build_field_tree (0, l, f, CB_STORAGE_WORKING, NULL, 3);
f = CB_FIELD (x);
f->pic = cb_build_picture ("X(" CB_XSTRINGIFY(DFLT_DEBUG_CONTENTS_SIZE) ")");
cb_validate_field (f);
Expand Down

0 comments on commit 99e6c28

Please sign in to comment.