From 04f9470ee130b6877edcaa202c0a143c9a48fced Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Fri, 1 Feb 2008 18:46:35 +0000 Subject: 20080201-1852 --- limbo/com.c | 12 +++++++++--- limbo/gen.c | 2 -- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'limbo') diff --git a/limbo/com.c b/limbo/com.c index 1bc070a4..967d17b0 100644 --- a/limbo/com.c +++ b/limbo/com.c @@ -368,6 +368,7 @@ fncom(Decl *decl) Node *n; Decl *loc, *last; Inst *in; + int valued; curfn = decl; if(ispoly(decl)) @@ -410,10 +411,11 @@ fncom(Decl *decl) scom(n->left); } pushblock(); - in = genrawop(&src, IRET, nil, nil, nil); + valued = decl->ty->tof != tnone; + in = genrawop(&src, valued? IRAISE: IRET, nil, nil, nil); popblock(); reach(decl->pc); - if(in->reach && decl->ty->tof != tnone) + if(valued && in->reach) error(src.start, "no return at end of function %D", decl); /* decl->endpc = lastinst; */ if(labdep != 0) @@ -1435,6 +1437,9 @@ ret(Node *n, int nilret) return n->op == Oret && n->left == nil; } +/* + * tail-recursive call + */ static int trcom(Node *e, Node *ne, int nilret) { @@ -1442,7 +1447,8 @@ trcom(Node *e, Node *ne, int nilret) Node *as, *a, *f, *n; Inst *p; -return 0; // TBS + if(1) + return 0; /* TO DO: should we enable this? */ if(e->op != Ocall || e->left->op != Oname) return 0; d = e->left->decl; diff --git a/limbo/gen.c b/limbo/gen.c index 64dce6e5..fe77dc80 100644 --- a/limbo/gen.c +++ b/limbo/gen.c @@ -590,8 +590,6 @@ foldbranch(Inst *in) next = in->next; *in = *b; in->next = next; - if(b->op == IRET) - b->reach = 1; /* might be default return (TO DO) */ continue; } foldbranch(b); -- cgit v1.2.3