From 912c68b91f91835120ba01d20f811279cb874019 Mon Sep 17 00:00:00 2001 From: David Declerck Date: Tue, 17 Sep 2024 00:37:54 +0200 Subject: [PATCH] Merge SVN 4980 --- cobc/ChangeLog | 7 +++++++ cobc/parser.y | 48 +++++++++++++++++++----------------------------- cobc/tree.h | 2 +- cobc/typeck.c | 24 ++++++++++++------------ 4 files changed, 39 insertions(+), 42 deletions(-) diff --git a/cobc/ChangeLog b/cobc/ChangeLog index ae2faf39a..6c253513c 100644 --- a/cobc/ChangeLog +++ b/cobc/ChangeLog @@ -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 + + * 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 * typeck.c (validate_alphabet): slightly rewritten to fix compiler warnings diff --git a/cobc/parser.y b/cobc/parser.y index 2e6b190eb..764e8ce2e 100644 --- a/cobc/parser.y +++ b/cobc/parser.y @@ -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; @@ -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 = @@ -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"); } } @@ -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" */ @@ -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; @@ -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; @@ -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: @@ -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 */ @@ -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; } } @@ -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) { @@ -7273,7 +7265,7 @@ constant_entry: } | SEVENTY_EIGHT user_entry_name { - if (set_current_field ($1, $2)) { + if (set_current_field (78, $2)) { YYERROR; } } @@ -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) { @@ -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; @@ -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) { @@ -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) { diff --git a/cobc/tree.h b/cobc/tree.h index 6703d03e9..8d7276018 100644 --- a/cobc/tree.h +++ b/cobc/tree.h @@ -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 *); diff --git a/cobc/typeck.c b/cobc/typeck.c index c29ccd3dc..f5bde8a75 100644 --- a/cobc/typeck.c +++ b/cobc/typeck.c @@ -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; @@ -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; @@ -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; @@ -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);