scc

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

commit f441e1db75872457deb4aacf39500f3cc6185554
parent 75f3f829eaa2e72575b9e5c802b290a17d837e54
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 16 Jun 2022 16:37:34 +0200

cc1: Accept () in primary()

Accepting parentheses was moved to cast() because we require a 2 token
ahead, and the only possible way of doing that was accepting parenthesis
there. The problems comes because unary() calls primary() and unary() is
called from sizeexp() that is called from unary(). It means that a sizeof
expression could not begin with 2 parenthesis (one was already removed
in sizeexp()) and for that reason we have to accept parenthesis in
primary().

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

diff --git a/src/cmd/cc/cc1/expr.c b/src/cmd/cc/cc1/expr.c @@ -627,6 +627,13 @@ primary(void) case DEFINED: np = defined(); break; + case '(': + next(); + np = xexpr(); + expect(')'); + + /* do not call to next */ + return np; case IDEN: assert((sym->flags & SCONSTANT) == 0); if ((sym->flags & SDECLARED) != 0) {