From 49b695d12404d1145bcab993898f0990a2c4295c Mon Sep 17 00:00:00 2001 From: "James K. Lowden" <jklowden@symas.com> Date: Wed, 17 Apr 2024 15:03:02 -0400 Subject: [PATCH] pendantic correctness, no effect --- gcc/cobol/genmath.cc | 7 ++++--- gcc/cobol/parse.y | 7 +++---- gcc/cobol/symbols.h | 6 +++++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/gcc/cobol/genmath.cc b/gcc/cobol/genmath.cc index c07b17c1a6b6..bc2175a76bd2 100644 --- a/gcc/cobol/genmath.cc +++ b/gcc/cobol/genmath.cc @@ -388,7 +388,8 @@ arithmetic_operation( size_t nC, cbl_num_result_t *C, // We need a duplicate of the remainder, because we have to take into count // the possibility of a size error in moving the remainder into place temp_field.type = remainder->field->type; - temp_field.attr = (remainder->field->attr | temporary_e) & ~initialized_e; + temp_field.attr = (remainder->field->attr | temporary_e); + temp_field.clear_attr(initialized_e); temp_field.level = 1; temp_field.data.memsize = remainder->field->data.memsize ; temp_field.data.capacity = remainder->field->data.capacity; @@ -396,8 +397,8 @@ arithmetic_operation( size_t nC, cbl_num_result_t *C, temp_field.data.rdigits = remainder->field->data.rdigits ; temp_field.data.initial = remainder->field->data.initial ; temp_field.data.picture = remainder->field->data.picture ; - parser_symbol_add(&temp_field); - temp_remainder.field = &temp_field; + + temp_remainder.field = new_temporary_like(temp_field); refer_fill_dest(temp_remainder); // For division, the optional remainder goes onto the beginning of the diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y index ee915ea413d7..ecda33508853 100644 --- a/gcc/cobol/parse.y +++ b/gcc/cobol/parse.y @@ -304,10 +304,9 @@ // YYEOF added for compatibility with Bison 3.5 // https://savannah.gnu.org/forum/forum.php?forum_id=9735 -%token YYEOF 0 "end of file" - -%type <number> sentence sentences statements statement +%token YYEOF 0 "end of file" +%type <number> sentence statements statement %type <number> star_cbl_opt close_how %type <number> test_before usage_clause1 might_be @@ -4040,7 +4039,7 @@ sentences: sentence { symbol_temporaries_free(); } | sentences sentence { - if( false && !getenv("STATIC") && $2 != PARAGRAPH ) + if( getenv("STATIC") && $2 != PARAGRAPH ) symbol_temporaries_free(); } ; diff --git a/gcc/cobol/symbols.h b/gcc/cobol/symbols.h index 14cbbb2431dc..7d6b1568d42b 100644 --- a/gcc/cobol/symbols.h +++ b/gcc/cobol/symbols.h @@ -261,7 +261,7 @@ struct os_locale_t { * A field is padded (in the unjustified direction) either with 0 or SPC. * (But maybe the fill character should just be an explicit character.) */ -enum cbl_field_attr_t { +enum cbl_field_attr_t : size_t { none_e = 0x0000000000, figconst_1_e = 0x0000000001, // This needs to be 1 - don't change the position figconst_2_e = 0x0000000002, // This needs to be 2 @@ -523,6 +523,7 @@ struct cbl_field_t { size_t offset; enum cbl_field_type_t type, usage; size_t attr; + static_assert(sizeof(attr) == sizeof(cbl_field_attr_t), "wrong attr size"); size_t parent; // symbols[] index of our parent size_t our_index; // symbols[] index of this field, set in symbol_add() uint32_t level; @@ -605,6 +606,9 @@ struct cbl_field_t { bool has_attr( cbl_field_attr_t attr ) const { return cbl_field_attr_t(this->attr & attr) == attr; } + size_t clear_attr( cbl_field_attr_t attr ) { + return this->attr &= ~size_t(attr); + } bool has_subordinate( const cbl_field_t *that ) const; -- GitLab