ref: 25b248b2ec25cb328aea47c140ca83f00ce2d37f
parent: ec647d24eb10e22e3f54acc0e22c9a9b91a2b6f7
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat Aug 15 16:37:28 EDT 2015
Fix for condition Condition() expects '(' before and ')' after, so it was not a good idea call it in for. Exp2cond() does the job.
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -347,6 +347,7 @@
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);
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -562,7 +562,7 @@
return np;
}
-static Node *
+Node *
exp2cond(Node *np, char neg)
{
np = decay(np);
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
@@ -91,7 +91,7 @@
expect('(');
einit = (yytoken != ';') ? expr() : NULL;
expect(';');
- econd = (yytoken != ';') ? condition() : NULL;
+ econd = (yytoken != ';') ? exp2cond(expr(), 0) : NULL;
expect(';');
einc = (yytoken != ')') ? expr() : NULL;
expect(')');