shithub: scc

Download patch

ref: 7ab3e04d0e3943e2f70bec9579b606a80357dbe6
parent: 1e257a4aedd7fe98c0f59750b26807da432d326b
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Apr 18 15:41:46 EDT 2014

Add checkof equal type in typeconv()

This function must convert two expressions to the same type, but
it faulted when they have the same type.

--- a/expr.c
+++ b/expr.c
@@ -46,6 +46,8 @@
 
 	tp1 = UNQUAL(np1->type);
 	tp2 = UNQUAL(np2->type);
+	if (tp1 == tp2)
+		return;
 	new1 = new2 = NULL;
 	n = tp1->u.size - tp2->u.size;
 
@@ -697,7 +699,6 @@
 ternary(void)
 {
 	Node *np, *ifyes, *ifno;
-	Type *tp1, *tp2;
 
 	np = or();
 	while (accept('?')) {
@@ -704,10 +705,7 @@
 		ifyes = promote(expr());
 		expect(':');
 		ifno = promote(ternary());
-		tp1 = UNQUAL(ifyes->type);
-		tp2 = UNQUAL(ifno->type);
-		if (tp1 != tp2)
-			typeconv(&ifyes, &ifno);
+		typeconv(&ifyes, &ifno);
 		np = ternarycode(iszero(np), ifyes, ifno);
 	}
 	return np;
--