Use labels in autogenerated enum value expressions

- For an enum like this:
    enum { value1 = SOME_NUM*2, value2 };
  Generate an increment expression for value2 of the form
    (add (id value1) 1)
  and not
    (add (* SOME_NUM 2) 1)
This commit is contained in:
Randy Heit 2013-09-12 22:06:57 -05:00
parent af8e0f2ba6
commit 2a1414ad66

View file

@ -310,7 +310,12 @@ enum_def(X) ::= ENUM(T) IDENTIFIER(A) enum_type(B) LBRACE opt_enum_list(C) RBRAC
NEW_INTCONST_NODE(cval, TypeSInt32, 1, T);
one = cval;
}
BINARY_EXPR(prev->Value, one, PEX_Add);
NEW_AST_NODE(ExprID, label, node);
label->Operation = PEX_ID;
label->Identifier = prev->Name;
label->Type = NULL;
BINARY_EXPR(label, one, PEX_Add);
node->Value = expr;
}
}