summaryrefslogtreecommitdiff
path: root/test/fixedbugs
diff options
context:
space:
mode:
Diffstat (limited to 'test/fixedbugs')
-rw-r--r--test/fixedbugs/bug016.go2
-rw-r--r--test/fixedbugs/bug055.go29
-rw-r--r--test/fixedbugs/bug069.go21
-rw-r--r--test/fixedbugs/bug076.go10
-rw-r--r--test/fixedbugs/bug077.go5
-rw-r--r--test/fixedbugs/bug081.go2
-rw-r--r--test/fixedbugs/bug091.go11
-rw-r--r--test/fixedbugs/bug137.go19
-rw-r--r--test/fixedbugs/bug140.go13
-rw-r--r--test/fixedbugs/bug177.go25
-rw-r--r--test/fixedbugs/bug178.go18
-rw-r--r--test/fixedbugs/bug179.go14
-rw-r--r--test/fixedbugs/bug196.go7
-rw-r--r--test/fixedbugs/bug234.go26
-rw-r--r--test/fixedbugs/bug242.go8
-rw-r--r--test/fixedbugs/bug243.go37
-rw-r--r--test/fixedbugs/bug252.go4
-rw-r--r--test/fixedbugs/bug274.go3
-rw-r--r--test/fixedbugs/bug323.go6
-rw-r--r--test/fixedbugs/bug325.go1
-rw-r--r--test/fixedbugs/bug326.go41
-rw-r--r--test/fixedbugs/bug327.go24
22 files changed, 226 insertions, 100 deletions
diff --git a/test/fixedbugs/bug016.go b/test/fixedbugs/bug016.go
index 1cdd8df08..4fbfd48fd 100644
--- a/test/fixedbugs/bug016.go
+++ b/test/fixedbugs/bug016.go
@@ -8,7 +8,7 @@ package main
func main() {
var i int = 100
- i = i << -3 // ERROR "overflows"
+ i = i << -3 // ERROR "overflows|negative"
}
/*
diff --git a/test/fixedbugs/bug055.go b/test/fixedbugs/bug055.go
index 0326d828f..861739610 100644
--- a/test/fixedbugs/bug055.go
+++ b/test/fixedbugs/bug055.go
@@ -7,16 +7,21 @@
package main
func main() {
- var i int;
- var j int;
- if true {}
- { return }
- i = 0;
- if true {} else i++;
- type s struct {};
- i = 0;
- type s2 int;
- var k = func (a int) int { return a+1 }(3);
- _, _ = j, k;
-ro: ;
+ var i int
+ var j int
+ if true {
+ }
+ {
+ return
+ }
+ i = 0
+ if true {
+ } else {
+ i++
+ }
+ type s struct{}
+ i = 0
+ type s2 int
+ var k = func(a int) int { return a + 1 }(3)
+ _, _ = j, k
}
diff --git a/test/fixedbugs/bug069.go b/test/fixedbugs/bug069.go
index bf7316313..9038387ac 100644
--- a/test/fixedbugs/bug069.go
+++ b/test/fixedbugs/bug069.go
@@ -7,15 +7,14 @@
package main
func main() {
- //TODO(rsc): uncomment when this syntax is valid for receive+check closed
- // c := make(chan int);
- // ok := false;
- // var i int;
- //
- // i, ok = <-c; // works
- // _, _ = i, ok;
- //
- // ca := new([2]chan int);
- // i, ok = <-(ca[0]); // fails: c.go:11: bad shape across assignment - cr=1 cl=2
- // _, _ = i, ok;
+ c := make(chan int);
+ ok := false;
+ var i int;
+
+ i, ok = <-c; // works
+ _, _ = i, ok;
+
+ ca := new([2]chan int);
+ i, ok = <-(ca[0]); // fails: c.go:11: bad shape across assignment - cr=1 cl=2
+ _, _ = i, ok;
}
diff --git a/test/fixedbugs/bug076.go b/test/fixedbugs/bug076.go
index 065cecc01..2ca518d76 100644
--- a/test/fixedbugs/bug076.go
+++ b/test/fixedbugs/bug076.go
@@ -1,4 +1,4 @@
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// $G $D/$F.go && $L $F.$A
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
@@ -7,12 +7,16 @@
package main
func f() {
-exit: ;
+exit:
+ ;
+ goto exit
}
func main() {
-exit: ; // this should be legal (labels not properly scoped?)
+exit:
+ ; // this should be legal (labels not properly scoped?)
+ goto exit
}
/*
diff --git a/test/fixedbugs/bug077.go b/test/fixedbugs/bug077.go
index 08028ab10..2cbf96d98 100644
--- a/test/fixedbugs/bug077.go
+++ b/test/fixedbugs/bug077.go
@@ -7,7 +7,8 @@
package main
func main() {
- var exit int;
+ var exit int
exit:
- _ = exit;
+ _ = exit
+ goto exit
}
diff --git a/test/fixedbugs/bug081.go b/test/fixedbugs/bug081.go
index 8d3d538c8..026ce8002 100644
--- a/test/fixedbugs/bug081.go
+++ b/test/fixedbugs/bug081.go
@@ -6,7 +6,7 @@
package main
-const x x = 2 // ERROR "loop"
+const x x = 2 // ERROR "loop|type"
/*
bug081.go:3: first constant must evaluate an expression
diff --git a/test/fixedbugs/bug091.go b/test/fixedbugs/bug091.go
index cfbb09cd8..c2ede7153 100644
--- a/test/fixedbugs/bug091.go
+++ b/test/fixedbugs/bug091.go
@@ -7,18 +7,19 @@
package main
func f1() {
- exit:
- print("hi\n");
+exit:
+ print("hi\n")
+ goto exit
}
func f2() {
- const c = 1234;
+ const c = 1234
}
func f3() {
- i := c; // ERROR "undef"
+ i := c // ERROR "undef"
}
func main() {
- f3();
+ f3()
}
diff --git a/test/fixedbugs/bug137.go b/test/fixedbugs/bug137.go
index 152792411..9d43f431b 100644
--- a/test/fixedbugs/bug137.go
+++ b/test/fixedbugs/bug137.go
@@ -8,16 +8,21 @@ package main
func main() {
L1:
-L2: for i := 0; i < 10; i++ {
- print(i);
- break L2;
+L2:
+ for i := 0; i < 10; i++ {
+ print(i)
+ break L2
}
-L3: ;
-L4: for i := 0; i < 10; i++ {
- print(i);
- break L4;
+L3:
+ ;
+L4:
+ for i := 0; i < 10; i++ {
+ print(i)
+ break L4
}
+ goto L1
+ goto L3
}
/*
diff --git a/test/fixedbugs/bug140.go b/test/fixedbugs/bug140.go
index 298081663..e27b370e7 100644
--- a/test/fixedbugs/bug140.go
+++ b/test/fixedbugs/bug140.go
@@ -7,8 +7,17 @@
package main
func main() {
- if true {} else L1: ;
- if true {} else L2: main() ;
+ if true {
+ } else {
+ L1:
+ }
+ if true {
+ } else {
+ L2:
+ main()
+ }
+ goto L1
+ goto L2
}
/*
diff --git a/test/fixedbugs/bug177.go b/test/fixedbugs/bug177.go
index 84ff59d2f..aec382388 100644
--- a/test/fixedbugs/bug177.go
+++ b/test/fixedbugs/bug177.go
@@ -5,23 +5,26 @@
// license that can be found in the LICENSE file.
package main
+
import "reflect"
-type S1 struct { i int }
-type S2 struct { S1 }
+
+type S1 struct{ i int }
+type S2 struct{ S1 }
+
func main() {
- typ := reflect.Typeof(S2{}).(*reflect.StructType);
- f := typ.Field(0);
+ typ := reflect.Typeof(S2{})
+ f := typ.Field(0)
if f.Name != "S1" || f.Anonymous != true {
- println("BUG: ", f.Name, f.Anonymous);
- return;
+ println("BUG: ", f.Name, f.Anonymous)
+ return
}
- f, ok := typ.FieldByName("S1");
+ f, ok := typ.FieldByName("S1")
if !ok {
- println("BUG: missing S1");
- return;
+ println("BUG: missing S1")
+ return
}
if !f.Anonymous {
- println("BUG: S1 is not anonymous");
- return;
+ println("BUG: S1 is not anonymous")
+ return
}
}
diff --git a/test/fixedbugs/bug178.go b/test/fixedbugs/bug178.go
index 4f586342b..205961024 100644
--- a/test/fixedbugs/bug178.go
+++ b/test/fixedbugs/bug178.go
@@ -9,19 +9,25 @@ package main
func main() {
L:
for i := 0; i < 1; i++ {
-L1:
+ L1:
for {
- break L;
+ break L
}
- panic("BUG: not reached - break");
+ panic("BUG: not reached - break")
}
L2:
for i := 0; i < 1; i++ {
-L3:
+ L3:
for {
- continue L2;
+ continue L2
}
- panic("BUG: not reached - continue");
+ panic("BUG: not reached - continue")
+ }
+ if false {
+ goto L1
+ }
+ if false {
+ goto L3
}
}
diff --git a/test/fixedbugs/bug179.go b/test/fixedbugs/bug179.go
index 67548733c..3347613d8 100644
--- a/test/fixedbugs/bug179.go
+++ b/test/fixedbugs/bug179.go
@@ -10,16 +10,18 @@ func main() {
L:
for {
for {
- break L2; // ERROR "L2"
- continue L2; // ERROR "L2"
+ break L2 // ERROR "L2"
+ continue L2 // ERROR "L2"
}
}
L1:
- x := 1;
- _ = x;
+ x := 1
+ _ = x
for {
- break L1; // ERROR "L1"
- continue L1; // ERROR "L1"
+ break L1 // ERROR "L1"
+ continue L1 // ERROR "L1"
}
+
+ goto L
}
diff --git a/test/fixedbugs/bug196.go b/test/fixedbugs/bug196.go
index 8cb9c9990..ea8ab0dc1 100644
--- a/test/fixedbugs/bug196.go
+++ b/test/fixedbugs/bug196.go
@@ -13,12 +13,11 @@ var i int
func multi() (int, int) { return 1, 2 }
func xxx() {
- //TODO(rsc): uncomment when this syntax is valid for receive+check closed
- // var c chan int
- // x, ok := <-c
+ var c chan int
+ x, ok := <-c
var m map[int]int
- x, ok := m[1]
+ x, ok = m[1]
var i interface{}
var xx int
diff --git a/test/fixedbugs/bug234.go b/test/fixedbugs/bug234.go
index 9affad043..562109a05 100644
--- a/test/fixedbugs/bug234.go
+++ b/test/fixedbugs/bug234.go
@@ -7,17 +7,17 @@
package main
func main() {
- //TODO(rsc): uncomment when this syntax is valid for receive+check closed
- // c := make(chan int, 1)
- // c <- 100
- // x, ok := <-c
- // if x != 100 || !ok {
- // println("x=", x, " ok=", ok, " want 100, true")
- // panic("fail")
- // }
- // x, ok = <-c
- // if x != 0 || ok {
- // println("x=", x, " ok=", ok, " want 0, false")
- // panic("fail")
- // }
+ c := make(chan int, 1)
+ c <- 100
+ x, ok := <-c
+ if x != 100 || !ok {
+ println("x=", x, " ok=", ok, " want 100, true")
+ panic("fail")
+ }
+ close(c)
+ x, ok = <-c
+ if x != 0 || ok {
+ println("x=", x, " ok=", ok, " want 0, false")
+ panic("fail")
+ }
}
diff --git a/test/fixedbugs/bug242.go b/test/fixedbugs/bug242.go
index ad1cef8df..839dccd37 100644
--- a/test/fixedbugs/bug242.go
+++ b/test/fixedbugs/bug242.go
@@ -101,13 +101,11 @@ func main() {
c := make(chan byte, 1)
c <- 'C'
- //TODO(rsc): uncomment when this syntax is valid for receive+check closed
// 15 16
- // *f(), p1 = <-e1(c, 16)
- *f(), p1 = <-e1(c, 16), true // delete uncommenting above
+ *f(), p1 = <-e1(c, 16)
+ close(c)
// 17 18
- // *f(), p2 = <-e1(c, 18)
- *f(), p2, _ = 0, false, e1(c, 18) // delete when uncommenting above
+ *f(), p2 = <-e1(c, 18)
a[17] += '0'
if !p1 || p2 {
println("bad chan check", i, p1, p2)
diff --git a/test/fixedbugs/bug243.go b/test/fixedbugs/bug243.go
index 236c14402..0c531968e 100644
--- a/test/fixedbugs/bug243.go
+++ b/test/fixedbugs/bug243.go
@@ -6,12 +6,14 @@
package main
-import (
- "net"
-)
+import "os"
+
+// Issue 481: closures and var declarations
+// with multiple variables assigned from one
+// function call.
func main() {
- var listen, _ = net.Listen("tcp", "127.0.0.1:0")
+ var listen, _ = Listen("tcp", "127.0.0.1:0")
go func() {
for {
@@ -20,6 +22,31 @@ func main() {
}
}()
- var conn, _ = net.Dial("tcp", "", listen.Addr().String())
+ var conn, _ = Dial("tcp", "", listen.Addr().String())
_ = conn
}
+
+// Simulated net interface to exercise bug
+// without involving a real network.
+type T chan int
+
+var global T
+
+func Listen(x, y string) (T, string) {
+ global = make(chan int)
+ return global, y
+}
+
+func (t T) Addr() os.Error {
+ return os.ErrorString("stringer")
+}
+
+func (t T) Accept() (int, string) {
+ return <-t, ""
+}
+
+func Dial(x, y, z string) (int, string) {
+ global <- 1
+ return 0, ""
+}
+
diff --git a/test/fixedbugs/bug252.go b/test/fixedbugs/bug252.go
index 5615f84fa..a2c1dab9d 100644
--- a/test/fixedbugs/bug252.go
+++ b/test/fixedbugs/bug252.go
@@ -7,9 +7,9 @@
package main
func f(args ...int) {
- g(args) // ERROR "[.][.][.]"
+ g(args)
}
func g(args ...interface{}) {
- f(args) // ERROR "[.][.][.]"
+ f(args) // ERROR "cannot use|incompatible"
}
diff --git a/test/fixedbugs/bug274.go b/test/fixedbugs/bug274.go
index 621f31eed..348aed429 100644
--- a/test/fixedbugs/bug274.go
+++ b/test/fixedbugs/bug274.go
@@ -24,6 +24,7 @@ func main() {
case 1:
L1: // ERROR "statement"
default:
- L2: // correct since no semicolon is required before a '}'
+ // correct since no semicolon is required before a '}'
+ L2: // GCCGO_ERROR "not used"
}
}
diff --git a/test/fixedbugs/bug323.go b/test/fixedbugs/bug323.go
index bfb528318..23e2be660 100644
--- a/test/fixedbugs/bug323.go
+++ b/test/fixedbugs/bug323.go
@@ -15,6 +15,6 @@ func (t T) Meth2() {}
func main() {
t := &T{}
p := P(t)
- p.Meth() // ERROR "undefined \(type P"
- p.Meth2() // ERROR "undefined \(type P"
-} \ No newline at end of file
+ p.Meth() // ERROR "undefined"
+ p.Meth2() // ERROR "undefined"
+}
diff --git a/test/fixedbugs/bug325.go b/test/fixedbugs/bug325.go
index 23dbc8b3c..b86740fff 100644
--- a/test/fixedbugs/bug325.go
+++ b/test/fixedbugs/bug325.go
@@ -11,4 +11,5 @@ import "unsafe"
func main() {
var x unsafe.Pointer
println(*x) // ERROR "invalid indirect.*unsafe.Pointer"
+ var _ = (unsafe.Pointer)(nil).foo // ERROR "foo"
}
diff --git a/test/fixedbugs/bug326.go b/test/fixedbugs/bug326.go
new file mode 100644
index 000000000..efdd0ef71
--- /dev/null
+++ b/test/fixedbugs/bug326.go
@@ -0,0 +1,41 @@
+// errchk $G $D/$F.go
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+import "os"
+
+func f() (_ int, err os.Error) {
+ return
+}
+
+func g() (x int, _ os.Error) {
+ return
+}
+
+func h() (_ int, _ os.Error) {
+ return
+}
+
+func i() (int, os.Error) {
+ return // ERROR "not enough arguments to return"
+}
+
+func f1() (_ int, err os.Error) {
+ return 1, nil
+}
+
+func g1() (x int, _ os.Error) {
+ return 1, nil
+}
+
+func h1() (_ int, _ os.Error) {
+ return 1, nil
+}
+
+func ii() (int, os.Error) {
+ return 1, nil
+}
diff --git a/test/fixedbugs/bug327.go b/test/fixedbugs/bug327.go
new file mode 100644
index 000000000..4ba5f6072
--- /dev/null
+++ b/test/fixedbugs/bug327.go
@@ -0,0 +1,24 @@
+// $G $D/$F.go && $L $F.$A && ./$A.out
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Conversion between identical interfaces.
+// Issue 1647.
+
+// The compiler used to not realize this was a no-op,
+// so it generated a call to the non-existent function runtime.convE2E.
+
+package main
+
+type (
+ a interface{}
+ b interface{}
+)
+
+func main() {
+ x := a(1)
+ z := b(x)
+ _ = z
+}