From d015f896bbabadbfa2025f775996065e2f541ac5 Mon Sep 17 00:00:00 2001 From: Ken Thompson Date: Wed, 1 Oct 2008 20:00:58 -0700 Subject: [PATCH] clear output parameters R=r OCL=16345 CL=16345 --- src/cmd/6g/gen.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/cmd/6g/gen.c b/src/cmd/6g/gen.c index 1f053afc191..6623c517f7c 100644 --- a/src/cmd/6g/gen.c +++ b/src/cmd/6g/gen.c @@ -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;