Files
clang-p2996/llgo/third_party/gotools/go/pointer/testdata/panic.go
Peter Collingbourne 56109b78c7 Roll gotools to 47f2109c.
At the same time, perform a number of simplifications:

- Rename go.tools directory to gotools.

- Import only the go directory; all required Go analysis code and
  its dependencies have now been moved to this directory.

llvm-svn: 225825
2015-01-13 20:45:08 +00:00

37 lines
659 B
Go

// +build ignore
package main
// Test of value flow from panic() to recover().
// We model them as stores/loads of a global location.
// We ignore concrete panic types originating from the runtime.
var someval int
type myPanic struct{}
func f(int) {}
func g() string { return "" }
func deadcode() {
panic(123) // not reached
}
func main() {
switch someval {
case 0:
panic("oops")
case 1:
panic(myPanic{})
case 2:
panic(f)
case 3:
panic(g)
}
ex := recover()
print(ex) // @types myPanic | string | func(int) | func() string
print(ex.(func(int))) // @pointsto main.f
print(ex.(func() string)) // @pointsto main.g
}