]> Cypherpunks repositories - gostls13.git/commitdiff
gc: implement new return restriction
authorRuss Cox <rsc@golang.org>
Thu, 13 Oct 2011 16:17:55 +0000 (12:17 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 13 Oct 2011 16:17:55 +0000 (12:17 -0400)
R=ken2
CC=golang-dev
https://golang.org/cl/5245056

src/cmd/gc/go.y

index 63cff8655c0e7f7a8acf75aaed5ea4b0dbee72aa..ea467cd23ec1276017d383b60dedcade0334fead 100644 (file)
@@ -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: