commit ee6d21258db24ac2640a410bc27ea1b552b36ca1
parent 6decf612c382dab28f910aca45b6e34a842fc4c5
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 23 Apr 2014 15:17:04 +0200
Check that void function can return a value
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/stmt.c b/stmt.c
@@ -17,7 +17,9 @@ Return(void)
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);