Do not share constant 1 for enum autoincrements.

- AST nodes cannot be shared, because type conversion changes them in
  place, and what's appropriate for one use is by no means appropriate for
  all uses.
This commit is contained in:
Randy Heit 2013-10-25 22:20:22 -05:00
parent 6384613487
commit 2b96db5fac

View file

@ -280,7 +280,6 @@ enum_def(X) ::= ENUM(T) IDENTIFIER(A) enum_type(B) LBRACE opt_enum_list(C) RBRAC
if (C != NULL) if (C != NULL)
{ {
ZCC_ConstantDef *node = C, *prev = node; ZCC_ConstantDef *node = C, *prev = node;
ZCC_ExprConstant *one = NULL;
if (node->Value == NULL) if (node->Value == NULL)
{ {
@ -308,11 +307,7 @@ enum_def(X) ::= ENUM(T) IDENTIFIER(A) enum_type(B) LBRACE opt_enum_list(C) RBRAC
// Otherwise, create a new addition expression to add 1. // Otherwise, create a new addition expression to add 1.
else else
{ {
if (one == NULL) NEW_INTCONST_NODE(one, TypeSInt32, 1, T);
{ // Use a single 1 node for the right-hand side of the addition.
NEW_INTCONST_NODE(cval, TypeSInt32, 1, T);
one = cval;
}
NEW_AST_NODE(ExprID, label, node); NEW_AST_NODE(ExprID, label, node);
label->Operation = PEX_ID; label->Operation = PEX_ID;
label->Identifier = prev->Name; label->Identifier = prev->Name;