aboutsummaryrefslogtreecommitdiff
path: root/test/escape_iface.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2021-05-14 11:11:40 -0700
committerColin Cross <ccross@android.com>2021-05-14 11:24:07 -0700
commit846c316dd40a5b611f4f0d9cc9349f2424bcfc69 (patch)
tree2d14d0e4674b6dbf4a6342cf8ef256eb69fce297 /test/escape_iface.go
parentcb309e79113b0b773635eb54df79f285900538c0 (diff)
downloadlinux-x86-846c316dd40a5b611f4f0d9cc9349f2424bcfc69.tar.gz
Update linux-x86 Go prebuilts from ab/7362735android-s-beta-2android-s-beta-1
https://ci.android.com/builds/branches/aosp-build-tools-release/grid?head=7362735&tail=7362735 Update script: toolchain/go/update-prebuilts.sh Test: Treehugger presubmit Change-Id: I94be24fb6cf1b227ba5ff0faed2605310b5c167f
Diffstat (limited to 'test/escape_iface.go')
-rw-r--r--test/escape_iface.go71
1 files changed, 38 insertions, 33 deletions
diff --git a/test/escape_iface.go b/test/escape_iface.go
index 118ed3c56..dba08e3cb 100644
--- a/test/escape_iface.go
+++ b/test/escape_iface.go
@@ -37,7 +37,7 @@ func efaceEscape0() {
_ = x
}
{
- i := 0 // ERROR "moved to heap: i"
+ i := 0 // ERROR "moved to heap: i"
v := M0{&i}
var x M = v
sink = x
@@ -50,7 +50,7 @@ func efaceEscape0() {
_ = v1
}
{
- i := 0 // ERROR "moved to heap: i"
+ i := 0 // ERROR "moved to heap: i"
v := M0{&i}
// BAD: v does not escape to heap here
var x M = v
@@ -58,14 +58,13 @@ func efaceEscape0() {
sink = v1
}
{
- i := 0 // ERROR "moved to heap: i"
+ i := 0
v := M0{&i}
- // BAD: v does not escape to heap here
var x M = v
- x.M()
+ x.M() // ERROR "devirtualizing x.M"
}
{
- i := 0 // ERROR "moved to heap: i"
+ i := 0 // ERROR "moved to heap: i"
v := M0{&i}
var x M = v
mescapes(x)
@@ -91,46 +90,45 @@ func efaceEscape1() {
{
i := 0
v := M1{&i, 0}
- var x M = v // ERROR "v does not escape"
+ var x M = v // ERROR "v does not escape"
_ = x
}
{
- i := 0 // ERROR "moved to heap: i"
+ i := 0 // ERROR "moved to heap: i"
v := M1{&i, 0}
- var x M = v // ERROR "v escapes to heap"
+ var x M = v // ERROR "v escapes to heap"
sink = x
}
{
i := 0
v := M1{&i, 0}
- var x M = v // ERROR "v does not escape"
+ var x M = v // ERROR "v does not escape"
v1 := x.(M1)
_ = v1
}
{
- i := 0 // ERROR "moved to heap: i"
+ i := 0 // ERROR "moved to heap: i"
v := M1{&i, 0}
var x M = v // ERROR "v does not escape"
v1 := x.(M1)
sink = v1 // ERROR "v1 escapes to heap"
}
{
- i := 0 // ERROR "moved to heap: i"
+ i := 0
v := M1{&i, 0}
- // BAD: v does not escape to heap here
- var x M = v // ERROR "v escapes to heap"
- x.M()
+ var x M = v // ERROR "v does not escape"
+ x.M() // ERROR "devirtualizing x.M"
}
{
- i := 0 // ERROR "moved to heap: i"
+ i := 0 // ERROR "moved to heap: i"
v := M1{&i, 0}
- var x M = v // ERROR "v escapes to heap"
+ var x M = v // ERROR "v escapes to heap"
mescapes(x)
}
{
i := 0
v := M1{&i, 0}
- var x M = v // ERROR "v does not escape"
+ var x M = v // ERROR "v does not escape"
mdoesnotescape(x)
}
}
@@ -146,26 +144,26 @@ func (*M2) M() {
func efaceEscape2() {
{
i := 0
- v := &M2{&i} // ERROR "&M2 literal does not escape"
+ v := &M2{&i} // ERROR "&M2{...} does not escape"
var x M = v
_ = x
}
{
i := 0 // ERROR "moved to heap: i"
- v := &M2{&i} // ERROR "&M2 literal escapes to heap"
+ v := &M2{&i} // ERROR "&M2{...} escapes to heap"
var x M = v
sink = x
}
{
i := 0
- v := &M2{&i} // ERROR "&M2 literal does not escape"
+ v := &M2{&i} // ERROR "&M2{...} does not escape"
var x M = v
v1 := x.(*M2)
_ = v1
}
{
i := 0 // ERROR "moved to heap: i"
- v := &M2{&i} // ERROR "&M2 literal escapes to heap"
+ v := &M2{&i} // ERROR "&M2{...} escapes to heap"
// BAD: v does not escape to heap here
var x M = v
v1 := x.(*M2)
@@ -173,7 +171,7 @@ func efaceEscape2() {
}
{
i := 0 // ERROR "moved to heap: i"
- v := &M2{&i} // ERROR "&M2 literal does not escape"
+ v := &M2{&i} // ERROR "&M2{...} does not escape"
// BAD: v does not escape to heap here
var x M = v
v1 := x.(*M2)
@@ -181,7 +179,7 @@ func efaceEscape2() {
}
{
i := 0 // ERROR "moved to heap: i"
- v := &M2{&i} // ERROR "&M2 literal does not escape"
+ v := &M2{&i} // ERROR "&M2{...} does not escape"
// BAD: v does not escape to heap here
var x M = v
v1, ok := x.(*M2)
@@ -189,21 +187,20 @@ func efaceEscape2() {
_ = ok
}
{
- i := 0 // ERROR "moved to heap: i"
- v := &M2{&i} // ERROR "&M2 literal escapes to heap"
- // BAD: v does not escape to heap here
+ i := 0
+ v := &M2{&i} // ERROR "&M2{...} does not escape"
var x M = v
- x.M()
+ x.M() // ERROR "devirtualizing x.M"
}
{
i := 0 // ERROR "moved to heap: i"
- v := &M2{&i} // ERROR "&M2 literal escapes to heap"
+ v := &M2{&i} // ERROR "&M2{...} escapes to heap"
var x M = v
mescapes(x)
}
{
i := 0
- v := &M2{&i} // ERROR "&M2 literal does not escape"
+ v := &M2{&i} // ERROR "&M2{...} does not escape"
var x M = v
mdoesnotescape(x)
}
@@ -219,8 +216,8 @@ type T2 struct {
func dotTypeEscape() *T2 { // #11931
var x interface{}
- x = &T1{p: new(int)} // ERROR "new\(int\) escapes to heap" "&T1 literal does not escape"
- return &T2{ // ERROR "&T2 literal escapes to heap"
+ x = &T1{p: new(int)} // ERROR "new\(int\) escapes to heap" "&T1{...} does not escape"
+ return &T2{ // ERROR "&T2{...} escapes to heap"
T1: *(x.(*T1)),
}
}
@@ -244,7 +241,7 @@ func dotTypeEscape2() { // #13805, #15796
var x interface{} = i // ERROR "i does not escape"
var y interface{} = j // ERROR "j does not escape"
- sink = x.(int) // ERROR "x.\(int\) escapes to heap"
+ sink = x.(int) // ERROR "x.\(int\) escapes to heap"
sink, *(&ok) = y.(int)
}
{
@@ -258,3 +255,11 @@ func dotTypeEscape2() { // #13805, #15796
sink, *(&ok) = y.(*int)
}
}
+
+func issue42279() {
+ type I interface{ M() }
+ type T struct{ I }
+
+ var i I = T{} // ERROR "T\{\} does not escape"
+ i.M() // ERROR "partially devirtualizing i.M to T"
+}