Skip to content

Commit c1fc8d5

Browse files
cmd/gc: fix missing export data for inlining in a few other cases.
Exported inlined functions that perform a string conversion using a non-exported named type may miss it in export data. Fixes #5755. R=rsc, golang-dev, ality, r CC=golang-dev https://golang.org/cl/10464043
1 parent 7a0dc1c commit c1fc8d5

File tree

4 files changed

+98
-0
lines changed

4 files changed

+98
-0
lines changed

src/cmd/gc/export.c

+5
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ reexportdep(Node *n)
161161
case OCONV:
162162
case OCONVIFACE:
163163
case OCONVNOP:
164+
case ORUNESTR:
165+
case OARRAYBYTESTR:
166+
case OARRAYRUNESTR:
167+
case OSTRARRAYBYTE:
168+
case OSTRARRAYRUNE:
164169
case ODOTTYPE:
165170
case ODOTTYPE2:
166171
case OSTRUCTLIT:

test/fixedbugs/issue5755.dir/a.go

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2013 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package a
6+
7+
type I interface {
8+
F()
9+
}
10+
11+
type foo1 []byte
12+
type foo2 []rune
13+
type foo3 []uint8
14+
type foo4 []int32
15+
type foo5 string
16+
type foo6 string
17+
type foo7 string
18+
type foo8 string
19+
type foo9 string
20+
21+
func (f foo1) F() { return }
22+
func (f foo2) F() { return }
23+
func (f foo3) F() { return }
24+
func (f foo4) F() { return }
25+
func (f foo5) F() { return }
26+
func (f foo6) F() { return }
27+
func (f foo7) F() { return }
28+
func (f foo8) F() { return }
29+
func (f foo9) F() { return }
30+
31+
func Test1(s string) I { return foo1(s) }
32+
func Test2(s string) I { return foo2(s) }
33+
func Test3(s string) I { return foo3(s) }
34+
func Test4(s string) I { return foo4(s) }
35+
func Test5(s []byte) I { return foo5(s) }
36+
func Test6(s []rune) I { return foo6(s) }
37+
func Test7(s []uint8) I { return foo7(s) }
38+
func Test8(s []int32) I { return foo8(s) }
39+
func Test9(s int) I { return foo9(s) }
40+
41+
type bar map[int]int
42+
43+
func (b bar) F() { return }
44+
45+
func TestBar() I { return bar{1: 2} }
46+
47+
type baz int
48+
49+
func IsBaz(x interface{}) bool { _, ok := x.(baz); return ok }
50+
51+
type baz2 int
52+
53+
func IsBaz2(x interface{}) bool {
54+
switch x.(type) {
55+
case baz2:
56+
return true
57+
default:
58+
return false
59+
}
60+
}

test/fixedbugs/issue5755.dir/main.go

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2013 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import "./a"
8+
9+
func main() {
10+
a.Test1("frumious")
11+
a.Test2("frumious")
12+
a.Test3("frumious")
13+
a.Test4("frumious")
14+
15+
a.Test5(nil)
16+
a.Test6(nil)
17+
a.Test7(nil)
18+
a.Test8(nil)
19+
a.Test9(0)
20+
21+
a.TestBar()
22+
a.IsBaz(nil)
23+
}

test/fixedbugs/issue5755.go

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// compiledir
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 5755: exported data for inlining may miss
8+
// named types when used in string conversions.
9+
10+
package ignored

0 commit comments

Comments
 (0)