From e62b6792afc55ee7aff91f187d53d4ebc64bc816 Mon Sep 17 00:00:00 2001 From: johanknol Date: Sun, 9 Dec 2001 13:29:38 +0000 Subject: [PATCH] fixed bug #482668 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1665 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCC.y | 28 +++++++++++++++------------- src/SDCCsymt.c | 1 + support/regression/tests/enum.c | 11 +++++++---- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/SDCC.y b/src/SDCC.y index 7539a672..b4b36646 100644 --- a/src/SDCC.y +++ b/src/SDCC.y @@ -791,8 +791,8 @@ struct_declarator enum_specifier : ENUM '{' enumerator_list '}' { - addSymChain ($3); - allocVariables(reverseSyms($3)) ; + //addSymChain ($3); + //allocVariables(reverseSyms($3)) ; $$ = copyLinkChain(cenum->type); } | ENUM identifier '{' enumerator_list '}' { @@ -806,8 +806,8 @@ enum_specifier werror(E_DUPLICATE_TYPEDEF,csym->name); addSym ( enumTab,$2,$2->name,$2->level,$2->block, 0); - addSymChain ($4); - allocVariables (reverseSyms($4)); + //addSymChain ($4); + //allocVariables (reverseSyms($4)); $$ = copyLinkChain(cenum->type); SPEC_SCLS(getSpec($$)) = 0 ; } @@ -838,15 +838,17 @@ enumerator_list ; enumerator - : identifier opt_assign_expr { - /* make the symbol one level up */ - $1->level-- ; - $1->type = copyLinkChain($2->type); - $1->etype= getSpec($1->type); - SPEC_ENUM($1->etype) = 1; - $$ = $1 ; - - } + : identifier opt_assign_expr + { + /* make the symbol one level up */ + $1->level-- ; + $1->type = copyLinkChain($2->type); + $1->etype= getSpec($1->type); + SPEC_ENUM($1->etype) = 1; + $$ = $1 ; + // do this now, so we can use it for the next enums in the list + addSymChain($1); + } ; opt_assign_expr diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index db8e3ad9..9d45864c 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -621,6 +621,7 @@ mergeSpec (sym_link * dest, sym_link * src, char *name) SPEC_BLEN (dest) |= SPEC_BLEN (src); SPEC_BSTR (dest) |= SPEC_BSTR (src); SPEC_TYPEDEF (dest) |= SPEC_TYPEDEF (src); + SPEC_ENUM (dest) |= SPEC_ENUM (src); if (IS_STRUCT (dest) && SPEC_STRUCT (dest) == NULL) SPEC_STRUCT (dest) = SPEC_STRUCT (src); diff --git a/support/regression/tests/enum.c b/support/regression/tests/enum.c index 19e0fdb2..49ef416b 100644 --- a/support/regression/tests/enum.c +++ b/support/regression/tests/enum.c @@ -19,9 +19,11 @@ enum _ValuesEnum { enum _IndexedEnum { INDEXED_ZERO, INDEXED_ONE, - /* PENDING: Fails */ - //INDEXED_ONE_ALIAS = INDEXED_ONE, - INDEXED_TWO + INDEXED_ONE_ALIAS = INDEXED_ONE, + INDEXED_TWO, + INDEXED_THREE, + INDEXED_MATH = INDEXED_ONE_ALIAS + INDEXED_TWO * INDEXED_THREE + }; void @@ -47,6 +49,7 @@ testIndexedEnum(void) { ASSERT(INDEXED_ZERO == 0); ASSERT(INDEXED_ONE == 1); - // ASSERT(INDEXED_ONE_ALIAS == 1); + ASSERT(INDEXED_ONE_ALIAS == 1); ASSERT(INDEXED_TWO == 2); + ASSERT(INDEXED_MATH == 7); } -- 2.47.2