[hackers] [scc] [cc1] Remove iconstexpr() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sat, 4 Feb 2017 18:59:11 +0100 (CET)

commit 28974f98e6d51b5413f0080787bf3f2d074b9589
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sat Feb 4 18:56:44 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Sat Feb 4 18:58:57 2017 +0100

    [cc1] Remove iconstexpr()
    
    there were a constexpr() and an iconstexpr() but only
    iconstexpr() was used, so it is better to join them
    and simplify the code.

diff --git a/cc1/cc1.h b/cc1/cc1.h
index b3975d9..c118641 100644
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
_AT_@ -426,7 +426,7 @@ extern TUINT ones(int nbytes);
 /* expr.c */
 extern Node *decay(Node *), *negate(Node *np), *assign(void);
 extern Node *convert(Node *np, Type *tp1, char iscast);
-extern Node *iconstexpr(void), *condexpr(void), *expr(void);
+extern Node *constexpr(void), *condexpr(void), *expr(void);
 extern int isnodecmp(int op);
 extern int negop(int op);
 extern int cmpnode(Node *np, TUINT val);
diff --git a/cc1/cpp.c b/cc1/cpp.c
index bd65816..9ce036d 100644
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
_AT_@ -621,7 +621,7 @@ ifclause(int negate, int isifdef)
                         killsym(sym);
         } else {
                 /* TODO: catch recovery here */
- if ((expr = iconstexpr()) == NULL) {
+ if ((expr = constexpr()) == NULL) {
                         cpperror("parameter of #if is not an integer constant expression");
                         return;
                 }
diff --git a/cc1/decl.c b/cc1/decl.c
index b032197..004300f 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -106,7 +106,7 @@ arydcl(struct declarators *dp)
 
         expect('[');
         if (yytoken != ']') {
- if ((np = iconstexpr()) == NULL) {
+ if ((np = constexpr()) == NULL) {
                         errorp("invalid storage size");
                 } else {
                         if ((n = np->sym->u.i) <= 0) {
_AT_@ -572,7 +572,7 @@ enumdcl(void)
                         toomany = 1;
                 }
                 if (accept('=')) {
- Node *np = iconstexpr();
+ Node *np = constexpr();
 
                         if (np == NULL)
                                 errorp("invalid enumeration value");
_AT_@ -626,7 +626,7 @@ field(struct decl *dcl)
                 Node *np;
                 TINT n;
 
- if ((np = iconstexpr()) == NULL) {
+ if ((np = constexpr()) == NULL) {
                         unexpected();
                         n = 0;
                 } else {
diff --git a/cc1/expr.c b/cc1/expr.c
index 8dfd00b..a009a48 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -1199,26 +1199,10 @@ constexpr(void)
         Node *np;
 
         np = ternary();
- if (!(np->flags & NCONST)) {
+ if (!np || !(np->flags & NCONST) || np->type->op != INT) {
                 freetree(np);
                 return NULL;
         }
- return np;
-}
-
-Node *
-iconstexpr(void)
-{
- Node *np;
-
- if ((np = constexpr()) == NULL)
- return NULL;
-
- if (np->type->op != INT) {
- freetree(np);
- return NULL;
- }
-
         return convert(np, inttype, 0);
 }
 
diff --git a/cc1/init.c b/cc1/init.c
index 94f4c6f..8e16420 100644
--- a/cc1/init.c
+++ b/cc1/init.c
_AT_@ -37,7 +37,7 @@ arydesig(Init *ip)
         if (ip->type->op != ARY)
                 errorp("array index in non-array initializer");
         next();
- np = iconstexpr();
+ np = constexpr();
         npos = np->sym->u.i;
         if (npos < 0 || (tp->prop & TDEFINED) && npos >= tp->n.elem) {
                 errorp("array index in initializer exceeds array bounds");
diff --git a/cc1/stmt.c b/cc1/stmt.c
index 16bc3d9..3abee59 100644
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
_AT_@ -265,7 +265,7 @@ Case(Symbol *lbreak, Symbol *lcont, Switch *sw)
         Symbol *label;
 
         expect(CASE);
- if ((np = iconstexpr()) == NULL)
+ if ((np = constexpr()) == NULL)
                 errorp("case label does not reduce to an integer constant");
         if (!sw) {
                 errorp("case label not within a switch statement");
Received on Sat Feb 04 2017 - 18:59:11 CET

This archive was generated by hypermail 2.3.0 : Sat Feb 04 2017 - 19:00:19 CET