diff options
author | Nathan Sidwell <nathan@acm.org> | 1999-08-03 14:24:07 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 1999-08-03 14:24:07 +0000 |
commit | 30ff82528b56f75cec222ac3d2c381e711123c0a (patch) | |
tree | c4991aad2813a901237a27dba87875a30ccf0535 | |
parent | f124f84ab03b1294d54070e60fc593ab7bcace09 (diff) | |
download | gcc-30ff82528b56f75cec222ac3d2c381e711123c0a.zip gcc-30ff82528b56f75cec222ac3d2c381e711123c0a.tar.gz gcc-30ff82528b56f75cec222ac3d2c381e711123c0a.tar.bz2 |
decl.c (start_enum): Show location of previous definition.
* decl.c (start_enum): Show location of previous definition.
* parse.y (enumlist_opt): New reduction.
(structsp): Simplify enum rules to use enumlist_opt.
From-SVN: r28471
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 5 | ||||
-rw-r--r-- | gcc/cp/parse.y | 20 |
3 files changed, 19 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5232c72..94d0b96 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +1999-08-03 Nathan Sidwell <nathan@acm.org> + + * decl.c (start_enum): Show location of previous definition. + * parse.y (enumlist_opt): New reduction. + (structsp): Simplify enum rules to use enumlist_opt. + 1999-08-03 Jason Merrill <jason@yorick.cygnus.com> * lex.c (yyprint): Handle PFUNCNAME. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index eedf277..498384b 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -12642,7 +12642,10 @@ start_enum (name) enumtype = lookup_tag (ENUMERAL_TYPE, name, b, 1); if (enumtype != NULL_TREE && TREE_CODE (enumtype) == ENUMERAL_TYPE) - cp_error ("multiple definition of `%#T'", enumtype); + { + cp_error ("multiple definition of `%#T'", enumtype); + cp_error_at ("previous definition here", enumtype); + } else { enumtype = make_node (ENUMERAL_TYPE); diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index 555b988..9551c15 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -211,7 +211,7 @@ empty_parms () %type <ttype> component_declarator component_declarator0 %type <ttype> notype_component_declarator notype_component_declarator0 %type <ttype> after_type_component_declarator after_type_component_declarator0 -%type <ttype> enumlist enumerator +%type <ttype> enumlist_opt enumlist enumerator %type <ttype> absdcl cv_qualifiers %type <ttype> direct_abstract_declarator conversion_declarator %type <ttype> new_declarator direct_new_declarator @@ -2104,32 +2104,24 @@ structsp: { $<itype>3 = suspend_momentary (); $<ttype>$ = current_enum_type; current_enum_type = start_enum ($2); } - enumlist maybecomma_warn '}' + enumlist_opt '}' { TYPE_VALUES (current_enum_type) = $5; $$.t = finish_enum (current_enum_type); $$.new_type_flag = 1; current_enum_type = $<ttype>4; resume_momentary ((int) $<itype>3); check_for_missing_semicolon ($$.t); } - | ENUM identifier '{' '}' - { $$.t = finish_enum (start_enum ($2)); - $$.new_type_flag = 1; - check_for_missing_semicolon ($$.t); } | ENUM '{' { $<itype>2 = suspend_momentary (); $<ttype>$ = current_enum_type; current_enum_type = start_enum (make_anon_name ()); } - enumlist maybecomma_warn '}' + enumlist_opt '}' { TYPE_VALUES (current_enum_type) = $4; $$.t = finish_enum (current_enum_type); $$.new_type_flag = 1; current_enum_type = $<ttype>3; resume_momentary ((int) $<itype>1); check_for_missing_semicolon ($$.t); } - | ENUM '{' '}' - { $$.t = finish_enum (start_enum (make_anon_name())); - $$.new_type_flag = 1; - check_for_missing_semicolon ($$.t); } | ENUM identifier { $$.t = xref_tag (enum_type_node, $2, 1); $$.new_type_flag = 0; } @@ -2681,6 +2673,12 @@ notype_component_declarator: cplus_decl_attributes ($$, $3, prefix_attributes); } ; +enumlist_opt: + enumlist maybecomma_warn + | maybecomma_warn + { $$ = NULL_TREE; } + ; + /* We chain the enumerators in reverse order. Because of the way enums are built, the order is insignificant. Take advantage of this fact. */ |