commit 25b248b2ec25cb328aea47c140ca83f00ce2d37f
Author: Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Sat Aug 15 20:37:28 2015 +0200
Commit: Roberto E. Vargas Caballero <[email protected]>
CommitDate: Sat Aug 15 20:37:28 2015 +0200
Fix for condition
Condition() expects '(' before and ')' after, so it
was not a good idea call it in for. Exp2cond() does
the job.
diff --git a/cc1/cc1.h b/cc1/cc1.h
index fc16aa7..ea8ad78 100644
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -347,6 +347,7 @@ extern void freetree(Node *np);
extern Node *expr(void), *negate(Node *np), *constexpr(void);
extern Node *convert(Node *np, Type *tp1, char iscast);
extern Node *eval(Node *np), *iconstexpr(void), *condition(void);
+extern Node *exp2cond(Node *np, char neg);
/* cpp.c */
extern void icpp(void);
diff --git a/cc1/expr.c b/cc1/expr.c
index ebde5b1..f102a0c 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -562,7 +562,7 @@ negate(Node *np)
return np;
}
-static Node *
+Node *
exp2cond(Node *np, char neg)
{
np = decay(np);
diff --git a/cc1/stmt.c b/cc1/stmt.c
index c31fd8d..294ab5d 100644
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
@@ -91,7 +91,7 @@ For(Symbol *lbreak, Symbol *lcont, Caselist *lswitch)
expect('(');
einit = (yytoken != ';') ? expr() : NULL;
expect(';');
- econd = (yytoken != ';') ? condition() : NULL;
+ econd = (yytoken != ';') ? exp2cond(expr(), 0) : NULL;
expect(';');
einc = (yytoken != ')') ? expr() : NULL;
expect(')');