scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 2f555ae12510f6214164f4e85f49ea2127d3c935
parent c4d94b222aa21eb5f956a37717627c0a55fd6404
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 15 Sep 2015 12:03:02 +0200

Simplify arydcl()

Diffstat:
cc1/decl.c | 25++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/cc1/decl.c b/cc1/decl.c @@ -96,26 +96,21 @@ static void arydcl(struct declarators *dp) { Node *np = NULL; - TINT n; + TINT n = 0; expect('['); if (yytoken != ']') { - if ((np = iconstexpr()) == NULL) - error("invalid storage size"); - } - expect(']'); - - if (np != NULL) { - n = np->sym->u.i; - if (n == 0 || n < 0) { - errorp("array size is not a positive number"); - n = 1; + if ((np = iconstexpr()) == NULL) { + errorp("invalid storage size"); + } else { + if ((n = np->sym->u.i) <= 0) { + errorp("array size is not a positive number"); + n = 1; + } + freetree(np); } - } else { - n = 0; } - - freetree(np); + expect(']'); push(dp, ARY, n); }