1
0
mirror of https://github.com/golang/go synced 2024-11-25 10:17:57 -07:00

gc: implement new return restriction

R=ken2
CC=golang-dev
https://golang.org/cl/5245056
This commit is contained in:
Russ Cox 2011-10-13 12:17:55 -04:00
parent 06862617c1
commit c18d1a78a4

View File

@ -1546,6 +1546,18 @@ non_dcl_stmt:
{ {
$$ = nod(ORETURN, N, N); $$ = nod(ORETURN, N, N);
$$->list = $2; $$->list = $2;
if($$->list == nil) {
NodeList *l;
for(l=curfn->dcl; l; l=l->next) {
if(l->n->class == PPARAM)
continue;
if(l->n->class != PPARAMOUT)
break;
if(l->n->sym->def != l->n)
yyerror("%s is shadowed during return", l->n->sym->name);
}
}
} }
stmt_list: stmt_list: