aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
-rw-r--r--ir.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/ir.c b/ir.c
index 836d4eb2..2e284c25 100644
--- a/ir.c
+++ b/ir.c
@@ -107,6 +107,17 @@ static int check_switch(struct entrypoint *ep, struct instruction *insn)
return err;
}
+static int check_return(struct instruction *insn)
+{
+ struct symbol *ctype = insn->type;
+
+ if (ctype && ctype->bit_size > 0 && insn->src == VOID) {
+ sparse_error(insn->pos, "return without value");
+ return 1;
+ }
+ return 0;
+}
+
static int validate_insn(struct entrypoint *ep, struct instruction *insn)
{
int err = 0;
@@ -152,6 +163,10 @@ static int validate_insn(struct entrypoint *ep, struct instruction *insn)
err += check_user(insn, insn->src);
break;
+ case OP_RET:
+ err += check_return(insn);
+ break;
+
case OP_BR:
err += check_branch(ep, insn, insn->bb_true);
break;