commit e2548f029977708f67328a66a45dec089996d831
parent cceaac6c6ed7505f2e552af7bd5d52d2ef6abd71
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Thu, 4 Nov 2021 16:01:05 +0100
cc1: Simplify postfix()
The doube switch was only to unify the call to decay().
It is much simpler just to call decay in every case
where it is needed.
Diffstat:
1 file changed, 16 insertions(+), 23 deletions(-)
diff --git a/src/cmd/cc/cc1/expr.c b/src/cmd/cc/cc1/expr.c
@@ -778,39 +778,32 @@ sizeexp(void)
static Node *
postfix(Node *lp)
{
+ int op;
Node *rp;
for (;;) {
switch (yytoken) {
case '[':
+ next();
+ rp = xexpr();
+ expect(']');
+ lp = array(decay(lp), rp);
+ break;
case DEC:
case INC:
+ op = (yytoken == INC) ? OINC : ODEC;
+ lp = incdec(decay(lp), op);
+ next();
+ break;
+
case INDIR:
+ lp = content(OPTR, decay(lp));
case '.':
+ lp = field(decay(lp));
+ break;
case '(':
- lp = decay(lp);
- switch (yytoken) {
- case '[':
- next();
- rp = xexpr();
- expect(']');
- lp = array(lp, rp);
- break;
- case DEC:
- case INC:
- lp = incdec(lp, (yytoken == INC) ? OINC : ODEC);
- next();
- break;
- case INDIR:
- lp = content(OPTR, lp);
- case '.':
- lp = field(lp);
- break;
- case '(':
- lp = arguments(lp);
- lp->flags |= NEFFECT;
- break;
- }
+ lp = arguments(decay(lp));
+ lp->flags |= NEFFECT;
break;
default:
return lp;