scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit b08f92985bfbf55d321c4942b3742823515c2ba0
parent e4d7773b6ee603349d12c0367518d356070b1135
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 18 Apr 2014 09:29:21 +0200

Convert expressions of ternary operator

In a ternary operator the two result expressions must be of the
same type, or in other case they must be converted to the same type.

Diffstat:
Mexpr.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/expr.c b/expr.c @@ -691,14 +691,14 @@ or(void) static Node * ternary(void) { - register Node *cond, *ifyes, *ifno; + Node *cond, *ifyes, *ifno; cond = or(); while (accept('?')) { ifyes = promote(expr()); expect(':'); ifno = promote(ternary()); - /* TODO: check the types of ifno and ifyes */ + typeconv(&ifyes, &ifno); cond = ternarycode(compare(ONE, cond, constcode(zero)), ifyes, ifno); }