]> Cypherpunks repositories - gostls13.git/commitdiff
clear output parameters
authorKen Thompson <ken@golang.org>
Thu, 2 Oct 2008 03:00:58 +0000 (20:00 -0700)
committerKen Thompson <ken@golang.org>
Thu, 2 Oct 2008 03:00:58 +0000 (20:00 -0700)
R=r
OCL=16345
CL=16345

src/cmd/6g/gen.c

index 1f053afc1916a310fb487aaf2f4638a70ff53b16..6623c517f7c24ab6e5ae4fbfb0b26203ba5a0dfc 100644 (file)
@@ -20,6 +20,7 @@ compile(Node *fn)
        Node nod1;
        Prog *ptxt;
        int32 lno;
+       Type *t;
 
 if(newproc == N) {
        newproc = nod(ONAME, N, N);
@@ -56,6 +57,17 @@ if(throwreturn == N) {
        curfn = fn;
        dowidth(curfn->type);
 
+       if(curfn->type->outnamed) {
+               // add clearing of the output parameters
+               t = structfirst(&pl, getoutarg(curfn->type));
+               while(t != T) {
+                       if(t->nname != N && t->nname->sym->name[0] != '_') {
+                               curfn->nbody = list(nod(OAS, t->nname, N), curfn->nbody);
+                       }
+                       t = structnext(&pl);
+               }
+       }
+
        walk(curfn);
        if(nerrors != 0)
                goto ret;