Commit 0417aafe authored by Russ Cox's avatar Russ Cox

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
parent 0aa1b150
...@@ -680,9 +680,11 @@ static Node* boolname; ...@@ -680,9 +680,11 @@ static Node* boolname;
Node* Node*
typeone(Node *t) typeone(Node *t)
{ {
Node *a, *b; Node *a, *b, *dcl;
a = t->left->left; // var a = t->left->left; // var
dcl = nod(ODCL, a, N);
a = nod(OLIST, a, boolname); // var,bool a = nod(OLIST, a, boolname); // var,bool
b = nod(ODOTTYPE, facename, N); b = nod(ODOTTYPE, facename, N);
...@@ -693,7 +695,7 @@ typeone(Node *t) ...@@ -693,7 +695,7 @@ typeone(Node *t)
b = nod(OIF, N, N); b = nod(OIF, N, N);
b->ntest = boolname; b->ntest = boolname;
b->nbody = t->right; // if bool { goto l } b->nbody = t->right; // if bool { goto l }
return list(a, b); return list(list(dcl, a), b);
} }
Node* Node*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment