]> Cypherpunks.ru repositories - gostls13.git/blobdiff - test/escape_map.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / escape_map.go
index 99cbd482a6001a27d80180060b4ef869fe1ba64f..23abaa1e0cc5e91fa1a1ba7c3f66cc31b812f5a5 100644 (file)
@@ -15,25 +15,25 @@ func map0() {
        // BAD: i should not escape
        i := 0 // ERROR "moved to heap: i"
        // BAD: j should not escape
-       j := 0     // ERROR "moved to heap: j"
-       m[&i] = &j // ERROR "&i escapes to heap" "&j escapes to heap"
+       j := 0 // ERROR "moved to heap: j"
+       m[&i] = &j
        _ = m
 }
 
 func map1() *int {
        m := make(map[*int]*int) // ERROR "make\(map\[\*int\]\*int\) does not escape"
        // BAD: i should not escape
-       i := 0       // ERROR "moved to heap: i"
-       j := 0       // ERROR "moved to heap: j"
-       m[&i] = &j   // ERROR "&i escapes to heap" "&j escapes to heap"
-       return m[&i] // ERROR "&i does not escape"
+       i := 0 // ERROR "moved to heap: i"
+       j := 0 // ERROR "moved to heap: j"
+       m[&i] = &j
+       return m[&i]
 }
 
 func map2() map[*int]*int {
        m := make(map[*int]*int) // ERROR "make\(map\[\*int\]\*int\) escapes to heap"
        i := 0                   // ERROR "moved to heap: i"
        j := 0                   // ERROR "moved to heap: j"
-       m[&i] = &j               // ERROR "&i escapes to heap" "&j escapes to heap"
+       m[&i] = &j
        return m
 }
 
@@ -41,8 +41,8 @@ func map3() []*int {
        m := make(map[*int]*int) // ERROR "make\(map\[\*int\]\*int\) does not escape"
        i := 0                   // ERROR "moved to heap: i"
        // BAD: j should not escape
-       j := 0     // ERROR "moved to heap: j"
-       m[&i] = &j // ERROR "&i escapes to heap" "&j escapes to heap"
+       j := 0 // ERROR "moved to heap: j"
+       m[&i] = &j
        var r []*int
        for k := range m {
                r = append(r, k)
@@ -53,9 +53,9 @@ func map3() []*int {
 func map4() []*int {
        m := make(map[*int]*int) // ERROR "make\(map\[\*int\]\*int\) does not escape"
        // BAD: i should not escape
-       i := 0     // ERROR "moved to heap: i"
-       j := 0     // ERROR "moved to heap: j"
-       m[&i] = &j // ERROR "&i escapes to heap" "&j escapes to heap"
+       i := 0 // ERROR "moved to heap: i"
+       j := 0 // ERROR "moved to heap: j"
+       m[&i] = &j
        var r []*int
        for k, v := range m {
                // We want to test exactly "for k, v := range m" rather than "for _, v := range m".
@@ -68,18 +68,18 @@ func map4() []*int {
 }
 
 func map5(m map[*int]*int) { // ERROR "m does not escape"
-       i := 0     // ERROR "moved to heap: i"
-       j := 0     // ERROR "moved to heap: j"
-       m[&i] = &j // ERROR "&i escapes to heap" "&j escapes to heap"
+       i := 0 // ERROR "moved to heap: i"
+       j := 0 // ERROR "moved to heap: j"
+       m[&i] = &j
 }
 
 func map6(m map[*int]*int) { // ERROR "m does not escape"
        if m != nil {
                m = make(map[*int]*int) // ERROR "make\(map\[\*int\]\*int\) does not escape"
        }
-       i := 0     // ERROR "moved to heap: i"
-       j := 0     // ERROR "moved to heap: j"
-       m[&i] = &j // ERROR "&i escapes to heap" "&j escapes to heap"
+       i := 0 // ERROR "moved to heap: i"
+       j := 0 // ERROR "moved to heap: j"
+       m[&i] = &j
 }
 
 func map7() {
@@ -87,21 +87,21 @@ func map7() {
        i := 0 // ERROR "moved to heap: i"
        // BAD: j should not escape
        j := 0                     // ERROR "moved to heap: j"
-       m := map[*int]*int{&i: &j} // ERROR "&i escapes to heap" "&j escapes to heap" "literal does not escape"
+       m := map[*int]*int{&i: &j} // ERROR "map\[\*int\]\*int{...} does not escape"
        _ = m
 }
 
 func map8() {
        i := 0                     // ERROR "moved to heap: i"
        j := 0                     // ERROR "moved to heap: j"
-       m := map[*int]*int{&i: &j} // ERROR "&i escapes to heap" "&j escapes to heap" "literal escapes to heap"
-       sink = m // ERROR "m escapes to heap"
+       m := map[*int]*int{&i: &j} // ERROR "map\[\*int\]\*int{...} escapes to heap"
+       sink = m
 }
 
 func map9() *int {
        // BAD: i should not escape
        i := 0                     // ERROR "moved to heap: i"
        j := 0                     // ERROR "moved to heap: j"
-       m := map[*int]*int{&i: &j} // ERROR "&i escapes to heap" "&j escapes to heap" "literal does not escape"
+       m := map[*int]*int{&i: &j} // ERROR "map\[\*int\]\*int{...} does not escape"
        return m[nil]
 }