Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/goPublic

Commitb82120b

Browse files
committed
[release-branch.go1.1] cmd/gc: fix issue with method wrappers not having escape analysis run on them.
««« CL 10383048 / 58e15340e78fcmd/gc: fix issue with method wrappers not having escape analysis run on them.Escape analysis needs the right curfn value on a dclfunc node, otherwise it will not analyze the function.When generating method value wrappers, we forgot to set the curfn correctly.Fixes#5753.R=golang-dev, rscCC=golang-devhttps://golang.org/cl/10383048»»»Update#5928R=golang-dev, daveCC=golang-devhttps://golang.org/cl/11669043
1 parentb315b7f commitb82120b

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

‎src/cmd/gc/closure.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ typecheckpartialcall(Node *fn, Node *sym)
280280
staticNode*
281281
makepartialcall(Node*fn,Type*t0,Node*meth)
282282
{
283-
Node*ptr,*n,*fld,*call,*xtype,*xfunc,*cv;
283+
Node*ptr,*n,*fld,*call,*xtype,*xfunc,*cv,*savecurfn;
284284
Type*rcvrtype,*basetype,*t;
285285
NodeList*body,*l,*callargs,*retargs;
286286
char*p;
@@ -304,13 +304,17 @@ makepartialcall(Node *fn, Type *t0, Node *meth)
304304
if(sym->flags&SymUniq)
305305
returnsym->def;
306306
sym->flags |=SymUniq;
307+
308+
savecurfn=curfn;
309+
curfn=N;
307310

308311
xtype=nod(OTFUNC,N,N);
309312
i=0;
310313
l=nil;
311314
callargs=nil;
312315
ddd=0;
313316
xfunc=nod(ODCLFUNC,N,N);
317+
curfn=xfunc;
314318
for(t=getinargx(t0)->type;t;t=t->down) {
315319
snprint(namebuf,sizeofnamebuf,"a%d",i++);
316320
n=newname(lookup(namebuf));
@@ -385,6 +389,7 @@ makepartialcall(Node *fn, Type *t0, Node *meth)
385389
typecheck(&xfunc,Etop);
386390
sym->def=xfunc;
387391
xtop=list(xtop,xfunc);
392+
curfn=savecurfn;
388393

389394
returnxfunc;
390395
}

‎test/fixedbugs/issue5753.go‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// run
2+
3+
// Copyright 2013 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
// issue 5753: bad typecheck info causes escape analysis to
8+
// not run on method thunks.
9+
10+
package main
11+
12+
typeThingstruct{}
13+
14+
func (t*Thing)broken(sstring) []string {
15+
foo:= [1]string{s}
16+
returnfoo[:]
17+
}
18+
19+
funcmain() {
20+
t:=&Thing{}
21+
22+
f:=t.broken
23+
s:=f("foo")
24+
_=f("bar")
25+
ifs[0]!="foo" {
26+
panic(`s[0] != "foo"`)
27+
}
28+
29+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp