ref: 2f555ae12510f6214164f4e85f49ea2127d3c935
parent: c4d94b222aa21eb5f956a37717627c0a55fd6404
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Sep 15 08:03:02 EDT 2015
Simplify arydcl()
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -96,26 +96,21 @@
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);
}