]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: define func value symbols at declaration
authorRuss Cox <rsc@golang.org>
Tue, 14 Jul 2015 00:50:51 +0000 (20:50 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 15 Jul 2015 04:11:01 +0000 (04:11 +0000)
These used to be defined at use, but that breaks when shared libraries
are involved.

For #11480.

Change-Id: I416a848754fb615c0d75f9f0ccc00723d07f7f01
Reviewed-on: https://go-review.googlesource.com/12145
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/compile/internal/gc/closure.go
src/cmd/compile/internal/gc/dcl.go

index 24af94c0cda3a65c6161d4c15c2185858c18fa4e..65f77d9079924f17756ab825248f83a68bde8d38 100644 (file)
@@ -199,6 +199,7 @@ func makeclosure(func_ *Node) *Node {
        xfunc.Func.Nname.Name.Funcdepth = func_.Func.Depth
        xfunc.Func.Depth = func_.Func.Depth
        xfunc.Func.Endlineno = func_.Func.Endlineno
+       makefuncsym(xfunc.Func.Nname.Sym)
 
        xfunc.Nbody = func_.Nbody
        xfunc.Func.Dcl = concat(func_.Func.Dcl, xfunc.Func.Dcl)
index cba8e21705f050c448f825713f86ef00c1591e71..0cb04eead6d301d9ce74afc99cb1fa1c9f230068 100644 (file)
@@ -585,6 +585,10 @@ func funchdr(n *Node) {
                Fatal("funchdr: dclcontext")
        }
 
+       if importpkg == nil && n.Func.Nname != nil {
+               makefuncsym(n.Func.Nname.Sym)
+       }
+
        dclcontext = PAUTO
        markdcl()
        Funcdepth++
@@ -1489,12 +1493,16 @@ func funcsym(s *Sym) *Sym {
        }
 
        s1 := Pkglookup(s.Name+"·f", s.Pkg)
-       if s1.Def == nil {
-               s1.Def = newfuncname(s1)
-               s1.Def.Func.Shortname = newname(s)
-               funcsyms = list(funcsyms, s1.Def)
-       }
        s.Fsym = s1
-
        return s1
 }
+
+func makefuncsym(s *Sym) {
+       if isblanksym(s) {
+               return
+       }
+       s1 := funcsym(s)
+       s1.Def = newfuncname(s1)
+       s1.Def.Func.Shortname = newname(s)
+       funcsyms = list(funcsyms, s1.Def)
+}