scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit d02dde25b6faa53013cbbb9894f1539645093ee5
parent 6526c3052cb52d7a55d42444dcda3628be67a44f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 18 Jun 2022 08:05:49 +0200

cc1: Simplify address()

The use of a few local variables can simplify some of the
expressions used in the code.

Diffstat:
Msrc/cmd/cc/cc1/expr.c | 12+++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/cmd/cc/cc1/expr.c b/src/cmd/cc/cc1/expr.c @@ -540,24 +540,26 @@ static Node * address(int op, Node *np) { Node *new; + Type *tp = np->type; + Symbol *sym = np->sym; /* * ansi c accepts & applied to a function name, and it generates * a function pointer */ if (np->op == OSYM) { - if (np->type->op == FTN) + if (tp->op == FTN) return decay(np); - if (np->type->op == ARY) + if (tp->op == ARY) goto dont_check_lvalue; } chklvalue(np); dont_check_lvalue: - if (np->sym && (np->sym->flags & SREGISTER)) + if (sym && (sym->flags & SREGISTER)) errorp("address of register variable '%s' requested", yytext); - new = node(op, mktype(np->type, PTR, 0, NULL), np, NULL); - if (np->sym && np->sym->flags & (SGLOBAL|SLOCAL|SPRIVATE)) + new = node(op, mktype(tp, PTR, 0, NULL), np, NULL); + if (sym && sym->flags & (SGLOBAL|SLOCAL|SPRIVATE)) new->flags |= NCONST; return new; }