shithub: scc

Download patch

ref: 57b5eebf19d3c1de5d7ebde4722c5bbabf17f395
parent: ebd1bfd80b0716ec72b256c6b65c01e9f8d8e2f1
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Jan 7 18:15:51 EST 2016

Convert chkternary() o use the new fields in type

--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -147,7 +147,7 @@
 			if (yes->type->integer && cmpnode(yes, 0))
 				yes = convert(yes, no->type, 0);
 			if (no->type->integer && cmpnode(no, 0))
-				no = convert(no, no->type, 0);
+				no = convert(no, yes->type, 0);
 
 			if (yes->type->op != PTR || no->type->op != PTR)
 				goto wrong_type;
@@ -161,7 +161,7 @@
 				goto wrong_type;
 		}
 	}
-	return node(OCOLON, yes->type, yes, yes);
+	return node(OCOLON, yes->type, yes, no);
 
 wrong_type:
 	errorp("type mismatch in conditional expression");