commit 2f555ae12510f6214164f4e85f49ea2127d3c935
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Tue Sep 15 12:03:02 2015 +0200
Commit:     Roberto E. Vargas Caballero <[email protected]>
CommitDate: Tue Sep 15 12:03:02 2015 +0200

    Simplify arydcl()

diff --git a/cc1/decl.c b/cc1/decl.c
index d213198..4eb1003 100644
--- 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);
 }

Reply via email to