From: Russ Cox Date: Tue, 7 Jul 2009 06:42:57 +0000 (-0700) Subject: insert ODCL in type switch case. X-Git-Tag: weekly.2009-11-06~1239 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0417aafe755acc5eb0cac0a030de08216e44488b;p=gostls13.git insert ODCL in type switch case. needed for heap allocation if variable escapes. package main func main(){ var i interface{} = 42; switch v := i.(type) { case int: println(&v, v); } } R=ken OCL=31245 CL=31245 --- diff --git a/src/cmd/gc/swt.c b/src/cmd/gc/swt.c index 6ea8c96288..4347eeac95 100644 --- a/src/cmd/gc/swt.c +++ b/src/cmd/gc/swt.c @@ -680,9 +680,11 @@ static Node* boolname; Node* typeone(Node *t) { - Node *a, *b; + Node *a, *b, *dcl; a = t->left->left; // var + dcl = nod(ODCL, a, N); + a = nod(OLIST, a, boolname); // var,bool b = nod(ODOTTYPE, facename, N); @@ -693,7 +695,7 @@ typeone(Node *t) b = nod(OIF, N, N); b->ntest = boolname; b->nbody = t->right; // if bool { goto l } - return list(a, b); + return list(list(dcl, a), b); } Node*