aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2010-08-31 07:34:01 -0700
committerIan Lance Taylor <iant@golang.org>2010-08-31 07:34:01 -0700
commit5309fae1a344b8a0d4e73a8505bc47e290496ee7 (patch)
treebf2b2e637f5c4a8394b0fed5dc82e773b4766a5f
parent0f61f0140d4380df86a135d5d8ea89edff9fb278 (diff)
downloadgo-5309fae1a344b8a0d4e73a8505bc47e290496ee7.tar.xz
test: don't assign address of array to slice.
R=rsc CC=golang-dev https://golang.org/cl/2084042
-rw-r--r--test/convert3.go4
-rw-r--r--test/fixedbugs/bug045.go2
-rw-r--r--test/fixedbugs/bug059.go2
-rw-r--r--test/fixedbugs/bug146.go2
-rw-r--r--test/ken/array.go8
-rw-r--r--test/ken/slicearray.go4
-rw-r--r--test/nilptr/arraytoslice.go2
-rw-r--r--test/nilptr/arraytoslice1.go2
-rw-r--r--test/nilptr/arraytoslice2.go2
9 files changed, 14 insertions, 14 deletions
diff --git a/test/convert3.go b/test/convert3.go
index 5f1f0dd94e..be68c95b36 100644
--- a/test/convert3.go
+++ b/test/convert3.go
@@ -13,8 +13,8 @@ var d1 chan<- int = c
var d2 = (chan<- int)(c)
var e *[4]int
-var f1 []int = e
-var f2 = []int(e)
+var f1 []int = e[0:]
+var f2 = []int(e[0:])
var g = []int(nil)
diff --git a/test/fixedbugs/bug045.go b/test/fixedbugs/bug045.go
index d8a712c6da..94888c40e2 100644
--- a/test/fixedbugs/bug045.go
+++ b/test/fixedbugs/bug045.go
@@ -13,7 +13,7 @@ type T struct {
func main() {
var ta []*T;
- ta = new([1]*T);
+ ta = new([1]*T)[0:];
ta[0] = nil;
}
/*
diff --git a/test/fixedbugs/bug059.go b/test/fixedbugs/bug059.go
index b190d4f26d..6a77367d67 100644
--- a/test/fixedbugs/bug059.go
+++ b/test/fixedbugs/bug059.go
@@ -25,7 +25,7 @@ func main() {
as := new([2]string);
as[0] = "0";
as[1] = "1";
- m["0"] = as;
+ m["0"] = as[0:];
a := m["0"];
a[0] = "x";
diff --git a/test/fixedbugs/bug146.go b/test/fixedbugs/bug146.go
index bfb7529d6a..16324c741a 100644
--- a/test/fixedbugs/bug146.go
+++ b/test/fixedbugs/bug146.go
@@ -9,7 +9,7 @@ package main
func main() {
type Slice []byte;
a := [...]byte{ 0 };
- b := Slice(&a); // This should be OK.
+ b := Slice(a[0:]); // This should be OK.
c := Slice(a); // ERROR "invalid|illegal|cannot"
_, _ = b, c;
}
diff --git a/test/ken/array.go b/test/ken/array.go
index 7785cdf8f6..40209f5da3 100644
--- a/test/ken/array.go
+++ b/test/ken/array.go
@@ -81,8 +81,8 @@ func testpfpf() {
// call ptr dynamic with ptr fixed from new
func testpdpf1() {
a := new([40]int)
- setpd(a)
- res(sumpd(a), 0, 40)
+ setpd(a[0:])
+ res(sumpd(a[0:]), 0, 40)
b := (*a)[5:30]
res(sumpd(b), 5, 30)
@@ -92,8 +92,8 @@ func testpdpf1() {
func testpdpf2() {
var a [80]int
- setpd(&a)
- res(sumpd(&a), 0, 80)
+ setpd(a[0:])
+ res(sumpd(a[0:]), 0, 80)
}
// generate bounds error with ptr dynamic
diff --git a/test/ken/slicearray.go b/test/ken/slicearray.go
index 76ec809310..536bbf56b3 100644
--- a/test/ken/slicearray.go
+++ b/test/ken/slicearray.go
@@ -16,12 +16,12 @@ var t int
func main() {
lb = 0
hb = 10
- by = &bx
+ by = bx[0:]
tstb()
lb = 0
hb = 10
- fy = &fx
+ fy = fx[0:]
tstf()
// width 1 (byte)
diff --git a/test/nilptr/arraytoslice.go b/test/nilptr/arraytoslice.go
index 65b2f8a765..06c862d0d9 100644
--- a/test/nilptr/arraytoslice.go
+++ b/test/nilptr/arraytoslice.go
@@ -33,5 +33,5 @@ func main() {
// usual len and cap, we require the *array -> slice
// conversion to do the check.
var p *[1<<30]byte = nil;
- f(p); // should crash
+ f(p[0:]); // should crash
}
diff --git a/test/nilptr/arraytoslice1.go b/test/nilptr/arraytoslice1.go
index b5240a803a..286572a4d2 100644
--- a/test/nilptr/arraytoslice1.go
+++ b/test/nilptr/arraytoslice1.go
@@ -29,6 +29,6 @@ func main() {
// usual len and cap, we require the *array -> slice
// conversion to do the check.
var p *[1<<30]byte = nil;
- var x []byte = p; // should crash
+ var x []byte = p[0:]; // should crash
_ = x;
}
diff --git a/test/nilptr/arraytoslice2.go b/test/nilptr/arraytoslice2.go
index 38e1a5cb28..4ac97f13e8 100644
--- a/test/nilptr/arraytoslice2.go
+++ b/test/nilptr/arraytoslice2.go
@@ -31,5 +31,5 @@ func main() {
// conversion to do the check.
var x []byte;
var y = &x;
- *y = q; // should crash (uses arraytoslice runtime routine)
+ *y = q[0:]; // should crash (uses arraytoslice runtime routine)
}