shithub: scc

Download patch

ref: ee6d21258db24ac2640a410bc27ea1b552b36ca1
parent: 6decf612c382dab28f910aca45b6e34a842fc4c5
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Apr 23 11:17:04 EDT 2014

Check that void function can return a value

--- a/stmt.c
+++ b/stmt.c
@@ -17,7 +17,9 @@
 	expect(RETURN);
 	np = expr();
 	if (np->type != tp) {
-		if ((np = convert(np, tp, 0)) == NULL)
+		if (tp == voidtype)
+			warn(1, "function returning void returns a value");
+		else if ((np = convert(np, tp, 0)) == NULL)
 			error("incorrect type in return");
 	}
 	emitret(tp);