diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/live.go | 12 | ||||
-rw-r--r-- | test/live1.go | 28 |
2 files changed, 34 insertions, 6 deletions
diff --git a/test/live.go b/test/live.go index 9c4e754c1..077a9b676 100644 --- a/test/live.go +++ b/test/live.go @@ -182,3 +182,15 @@ func f12() *int { return nil } } + +// incorrectly placed VARDEF annotations can cause missing liveness annotations. +// this used to be missing the fact that s is live during the call to g13 (because it is +// needed for the call to h13). + +func f13() { + s := "hello" + s = h13(s, g13(s)) // ERROR "live at call to g13: s" +} + +func g13(string) string +func h13(string, string) string diff --git a/test/live1.go b/test/live1.go index d0a2d0ecf..b05ec1f59 100644 --- a/test/live1.go +++ b/test/live1.go @@ -7,18 +7,22 @@ // Test that code compiles without // "internal error: ... recorded as live on entry" errors // from the liveness code. +// +// This code contains methods or other construct that +// trigger the generation of wrapper functions with no +// clear line number (they end up using line 1), and those +// would have annotations printed if we used -live=1, +// like the live.go test does. +// Instead, this test relies on the fact that the liveness +// analysis turns any non-live parameter on entry into +// a compile error. Compiling successfully means that bug +// has been avoided. package main // The liveness analysis used to get confused by the tail return // instruction in the wrapper methods generated for T1.M and (*T1).M, // causing a spurious "live at entry: ~r1" for the return result. -// This test is checking that there is no such message. -// We cannot use live.go because it runs with -live on, which will -// generate (correct) messages about the wrapper's receivers -// being live on entry, but those messages correspond to no -// source line in the file, so they are given at line 1, which we -// cannot annotate. Not using -live here avoids that problem. type T struct { } @@ -28,3 +32,15 @@ func (t *T) M() *int type T1 struct { *T } + +// Liveness analysis used to have the VARDEFs in the wrong place, +// causing a temporary to appear live on entry. + +func f1(pkg, typ, meth string) { + panic("value method " + pkg + "." + typ + "." + meth + " called using nil *" + typ + " pointer") +} + +func f2() interface{} { + return new(int) +} + |