aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-10-13 12:17:55 -0400
committerRuss Cox <rsc@golang.org>2011-10-13 12:17:55 -0400
commitc18d1a78a4cb8e0052fb272964bbf94b5855c6f4 (patch)
tree34280a14e9fdefae7e2c0625183089f3aef2e702 /src
parent06862617c13614f6af96c27b9e648b2002b6dd60 (diff)
downloadgo-c18d1a78a4cb8e0052fb272964bbf94b5855c6f4.tar.xz
gc: implement new return restriction
R=ken2 CC=golang-dev https://golang.org/cl/5245056
Diffstat (limited to 'src')
-rw-r--r--src/cmd/gc/go.y12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cmd/gc/go.y b/src/cmd/gc/go.y
index 63cff8655c..ea467cd23e 100644
--- a/src/cmd/gc/go.y
+++ b/src/cmd/gc/go.y
@@ -1546,6 +1546,18 @@ non_dcl_stmt:
{
$$ = nod(ORETURN, N, N);
$$->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: