summaryrefslogtreecommitdiff
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
commita1ca80f6980d59055a0692b02285da7db666f83f (patch)
treee48982a73781dac3929c615fc717bf8bcee699cd
parent717ac1f25bf7229239c53170974f9fb4e2a758e1 (diff)
downloadgo-a1ca80f6980d59055a0692b02285da7db666f83f.tar.gz
test: don't assign address of array to slice.
R=rsc CC=golang-dev http://codereview.appspot.com/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 5f1f0dd94..be68c95b3 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 d8a712c6d..94888c40e 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 b190d4f26..6a77367d6 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 bfb7529d6..16324c741 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 7785cdf8f..40209f5da 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 76ec80931..536bbf56b 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 65b2f8a76..06c862d0d 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 b5240a803..286572a4d 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 38e1a5cb2..4ac97f13e 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)
}