scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 058e5104f68f1a0d1a0da305c7e730b2d5adb392
parent dfe85dcaa8a0216b88815c0cf67ef247c51dc18c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue,  9 Aug 2016 14:09:29 +0200

[cc1] Fix content()

With previous version of the code content() had no problems
receiving something different to a pointer, but, with the current
this is not true anymore. If we receive an array then it means
that we have a problem somewhere.

Diffstat:
Mcc1/expr.c | 11++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/cc1/expr.c b/cc1/expr.c @@ -494,10 +494,9 @@ free_np: static Node * content(char op, Node *np) { - switch (BTYPE(np)) { - case ARY: - case FTN: - case PTR: + if (BTYPE(np) != PTR) { + errorp("invalid argument of memory indirection"); + } else { if (np->op == OADDR) { Node *new = np->left; new->type = np->type->type; @@ -507,10 +506,8 @@ content(char op, Node *np) np = node(op, np->type->type, np, NULL); } np->flags |= NLVAL; - return np; - default: - error("invalid argument of memory indirection"); } + return np; } static Node *