Commit c18d1a78 authored by Russ Cox's avatar Russ Cox

gc: implement new return restriction

R=ken2
CC=golang-dev
https://golang.org/cl/5245056
parent 06862617
...@@ -1546,6 +1546,18 @@ non_dcl_stmt: ...@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment