From 219670f1728976e2d43cc054237e6196d78feefa Mon Sep 17 00:00:00 2001 From: Ben Elliston Date: Wed, 11 Jul 2001 13:10:18 +0000 Subject: [PATCH] * Revert today's change -- there is a subtle bug. From-SVN: r43935 --- gcc/cp/ChangeLog | 2 ++ gcc/cp/cp-tree.h | 2 +- gcc/cp/decl.c | 18 ++++++------------ gcc/cp/parse.y | 21 +++++++-------------- gcc/cp/pt.c | 2 +- 5 files changed, 17 insertions(+), 28 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4ecf0aa0bce..03d03d3fb75 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,7 @@ 2001-07-11 Ben Elliston + * Revert this change -- there is a subtle bug. + PR c++/80 * decl.c (finish_enum): New "attributes" argument; pass it to cplus_decl_attributes. Use a narrower type if the enum is packed. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index d27ee9fe830..66ce4fb0d31 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3845,7 +3845,7 @@ extern tree xref_tag PARAMS ((tree, tree, int)); extern tree xref_tag_from_type PARAMS ((tree, tree, int)); extern void xref_basetypes PARAMS ((tree, tree, tree, tree)); extern tree start_enum PARAMS ((tree)); -extern void finish_enum PARAMS ((tree, tree)); +extern void finish_enum PARAMS ((tree)); extern void build_enumerator PARAMS ((tree, tree, tree)); extern int start_function PARAMS ((tree, tree, tree, int)); extern tree finish_function PARAMS ((int)); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 15ee0be1a39..5de71508626 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -12984,9 +12984,8 @@ start_enum (name) ENUMTYPE is the type object and VALUES a list of name-value pairs. */ void -finish_enum (enumtype, attributes) +finish_enum (enumtype) tree enumtype; - tree attributes; { tree pair; tree minnode; @@ -12997,8 +12996,6 @@ finish_enum (enumtype, attributes) int highprec; int precision; - cplus_decl_attributes (enumtype, attributes, NULL_TREE); - /* We built up the VALUES in reverse order. */ TYPE_VALUES (enumtype) = nreverse (TYPE_VALUES (enumtype)); @@ -13077,14 +13074,11 @@ finish_enum (enumtype, attributes) else fixup_signed_type (enumtype); - if (flag_short_enums || TYPE_PACKED (enumtype) || - (precision > TYPE_PRECISION (integer_type_node))) - { - /* Use the width of the narrowest normal C type which is wide - enough. */ - TYPE_PRECISION (enumtype) = TYPE_PRECISION (type_for_size - (precision, 1)); - } + if (flag_short_enums || (precision > TYPE_PRECISION (integer_type_node))) + /* Use the width of the narrowest normal C type which is wide + enough. */ + TYPE_PRECISION (enumtype) = TYPE_PRECISION (type_for_size + (precision, 1)); else TYPE_PRECISION (enumtype) = TYPE_PRECISION (integer_type_node); diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index 6c2a6beb24b..6e2ac183ce5 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -340,7 +340,7 @@ cp_parse_init () %type init initlist maybeasm maybe_init defarg defarg1 %type asm_operands nonnull_asm_operands asm_operand asm_clobbers %type maybe_attribute attributes attribute attribute_list attrib -%type any_word enum_head +%type any_word %type save_lineno %type simple_stmt simple_if @@ -2240,29 +2240,22 @@ pending_defargs: { do_pending_defargs (); } ; -enum_head: - ENUM - { $$ = NULL_TREE; } - | ENUM attributes - { $$ = $2; } - ; - structsp: - enum_head identifier '{' + ENUM identifier '{' { $$ = current_enum_type; current_enum_type = start_enum ($2); } - enumlist_opt '}' maybe_attribute + enumlist_opt '}' { $$.t = current_enum_type; - finish_enum (current_enum_type, chainon ($1, $7)); + finish_enum (current_enum_type); $$.new_type_flag = 1; current_enum_type = $4; check_for_missing_semicolon ($$.t); } - | enum_head '{' + | ENUM '{' { $$ = current_enum_type; current_enum_type = start_enum (make_anon_name ()); } - enumlist_opt '}' maybe_attribute + enumlist_opt '}' { $$.t = current_enum_type; - finish_enum (current_enum_type, chainon ($1, $6)); + finish_enum (current_enum_type); $$.new_type_flag = 1; current_enum_type = $3; check_for_missing_semicolon ($$.t); } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9503e3ec13f..3d6279a8282 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10149,7 +10149,7 @@ tsubst_enum (tag, newtag, args) build_enumerator (TREE_PURPOSE (e), value, newtag); } - finish_enum (newtag, NULL_TREE); + finish_enum (newtag); DECL_SOURCE_LINE (TYPE_NAME (newtag)) = DECL_SOURCE_LINE (TYPE_NAME (tag)); DECL_SOURCE_FILE (TYPE_NAME (newtag)) = DECL_SOURCE_FILE (TYPE_NAME (tag)); } -- 2.30.2