summaryrefslogtreecommitdiff
path: root/test/nilptr.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2013-09-05 23:06:34 -0400
committerRuss Cox <rsc@golang.org>2013-09-05 23:06:34 -0400
commitaf2c16f118faede527f2a8032776775c98d2938f (patch)
treed1b22e81907cd7b38831148637dd3753be0e6d97 /test/nilptr.go
parent6d3711ea3143930f38ee927d7ef421d3ced9266f (diff)
downloadgo-af2c16f118faede527f2a8032776775c98d2938f.tar.gz
test/nilptr: add more tests
These tests were suggested in golang.org/issue/6080. They were fixed as part of the new nil pointer checks that I added a few weeks ago. Recording the tests as part of marking the issue closed. Fixes issue 6080. R=golang-dev, r, bradfitz CC=golang-dev https://codereview.appspot.com/13255049
Diffstat (limited to 'test/nilptr.go')
-rw-r--r--test/nilptr.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/nilptr.go b/test/nilptr.go
index 793e99673..9631d1618 100644
--- a/test/nilptr.go
+++ b/test/nilptr.go
@@ -40,6 +40,10 @@ func main() {
shouldPanic(p10)
shouldPanic(p11)
shouldPanic(p12)
+ shouldPanic(p13)
+ shouldPanic(p14)
+ shouldPanic(p15)
+ shouldPanic(p16)
}
func shouldPanic(f func()) {
@@ -152,3 +156,27 @@ func p12() {
var p *T = nil
println(*(&((*p).i)))
}
+
+// Tests suggested in golang.org/issue/6080.
+
+func p13() {
+ var x *[10]int
+ y := x[:]
+ _ = y
+}
+
+func p14() {
+ println((*[1]int)(nil)[:])
+}
+
+func p15() {
+ for i := range (*[1]int)(nil)[:] {
+ _ = i
+ }
+}
+
+func p16() {
+ for i, v := range (*[1]int)(nil)[:] {
+ _ = i + v
+ }
+}