summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2013-08-13 13:44:24 +0200
committerMichael Stapelberg <michael@stapelberg.de>2013-08-13 13:44:24 +0200
commitb901efe83e212f0c34c769c079e41373da12d723 (patch)
treeae9d79e0fe6e4972cdd46aa196327cde714dd4f8
parent09f84a75bc63a6316d575f531489d69ec8ade2e8 (diff)
downloadgolang-b901efe83e212f0c34c769c079e41373da12d723.tar.gz
Imported Upstream version 1.1.2upstream/1.1.2
-rw-r--r--VERSION2
-rw-r--r--doc/devel/release.html11
-rw-r--r--misc/cgo/test/callback.go4
-rw-r--r--src/cmd/6g/peep.c1
-rw-r--r--src/cmd/8g/ggen.c2
-rw-r--r--src/cmd/8g/peep.c1
-rw-r--r--src/cmd/cgo/out.go68
-rw-r--r--src/cmd/gc/closure.c7
-rw-r--r--src/cmd/gc/export.c5
-rw-r--r--src/cmd/gc/fmt.c2
-rw-r--r--src/cmd/gc/walk.c7
-rw-r--r--src/pkg/bufio/bufio.go17
-rw-r--r--src/pkg/bufio/bufio_test.go22
-rw-r--r--src/pkg/runtime/proc.c2
-rw-r--r--src/pkg/runtime/time.goc5
-rw-r--r--src/pkg/syscall/rlimit_linux_test.go41
-rw-r--r--src/pkg/syscall/syscall_linux_386.go4
-rw-r--r--src/pkg/syscall/syscall_linux_arm.go4
-rw-r--r--src/pkg/time/sleep_test.go20
-rw-r--r--test/fixedbugs/bug465.dir/a.go15
-rw-r--r--test/fixedbugs/bug465.dir/b.go2
-rw-r--r--test/fixedbugs/issue5753.go29
-rw-r--r--test/fixedbugs/issue5755.dir/a.go60
-rw-r--r--test/fixedbugs/issue5755.dir/main.go23
-rw-r--r--test/fixedbugs/issue5755.go10
-rw-r--r--test/fixedbugs/issue5809.go27
-rw-r--r--test/fixedbugs/issue5820.go18
-rw-r--r--test/fixedbugs/issue5841.go16
28 files changed, 404 insertions, 21 deletions
diff --git a/VERSION b/VERSION
index c9c892df1..58a850386 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-go1.1.1 \ No newline at end of file
+go1.1.2 \ No newline at end of file
diff --git a/doc/devel/release.html b/doc/devel/release.html
index babd6e280..d31f79359 100644
--- a/doc/devel/release.html
+++ b/doc/devel/release.html
@@ -28,6 +28,17 @@ go1.1.1 (released 2013/06/13) includes several compiler and runtime bug fixes.
See the <a href="https://code.google.com/p/go/source/list?name=release-branch.go1.1&r=43c4a41d24382a56a90e924800c681e435d9e399">change history</a> for details.
</p>
+<p>
+go1.1.2 (released 2013/08/13) includes fixes to the <code>gc</code> compiler
+and <code>cgo</code>, and the <code>bufio</code>, <code>runtime</code>,
+<code>syscall</code>, and <code>time</code> packages.
+See the <a href="https://code.google.com/p/go/source/list?name=release-branch.go1.1&r=a6a9792f94acd4ff686b2bc57383d163608b91cf">change history</a> for details.
+If you use package syscall's <code>Getrlimit</code> and <code>Setrlimit</code>
+functions under Linux on the ARM or 386 architectures, please note change
+<a href="http://golang.org/change/55ac276af5a7">55ac276af5a7</a>
+that fixes <a href="http://golang.org/issue/5949">issue 5949</a>.
+</p>
+
<h2 id="go1">go1 (released 2012/03/28)</h2>
<p>
diff --git a/misc/cgo/test/callback.go b/misc/cgo/test/callback.go
index b6e2e3c1c..c642d5f0f 100644
--- a/misc/cgo/test/callback.go
+++ b/misc/cgo/test/callback.go
@@ -142,6 +142,10 @@ func testBlocking(t *testing.T) {
// Test that the stack can be unwound through a call out and call back
// into Go.
func testCallbackCallers(t *testing.T) {
+ if runtime.Compiler != "gc" {
+ // The exact function names are not going to be the same.
+ t.Skip("skipping for non-gc toolchain")
+ }
pc := make([]uintptr, 100)
n := 0
name := []string{
diff --git a/src/cmd/6g/peep.c b/src/cmd/6g/peep.c
index bb24d4144..cd2881ec4 100644
--- a/src/cmd/6g/peep.c
+++ b/src/cmd/6g/peep.c
@@ -152,6 +152,7 @@ peep(void)
case ALEAQ:
if(regtyp(&p->to))
if(p->from.sym != S)
+ if(p->from.index == D_NONE || p->from.index == D_CONST)
conprop(r);
break;
diff --git a/src/cmd/8g/ggen.c b/src/cmd/8g/ggen.c
index 70148106c..b0154bb80 100644
--- a/src/cmd/8g/ggen.c
+++ b/src/cmd/8g/ggen.c
@@ -78,9 +78,9 @@ clearfat(Node *nl)
c = w % 4; // bytes
q = w / 4; // quads
- gconreg(AMOVL, 0, D_AX);
nodreg(&n1, types[tptr], D_DI);
agen(nl, &n1);
+ gconreg(AMOVL, 0, D_AX);
if(q >= 4) {
gconreg(AMOVL, q, D_CX);
diff --git a/src/cmd/8g/peep.c b/src/cmd/8g/peep.c
index e5a3149cf..b8a1eaa08 100644
--- a/src/cmd/8g/peep.c
+++ b/src/cmd/8g/peep.c
@@ -145,6 +145,7 @@ peep(void)
case ALEAL:
if(regtyp(&p->to))
if(p->from.sym != S)
+ if(p->from.index == D_NONE || p->from.index == D_CONST)
conprop(r);
break;
diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go
index ee1d89142..7fb818168 100644
--- a/src/cmd/cgo/out.go
+++ b/src/cmd/cgo/out.go
@@ -318,6 +318,9 @@ func (p *Package) writeDefsFunc(fc, fgo2 *os.File, n *Name) {
Type: gtype,
}
+ // Builtins defined in the C prolog.
+ inProlog := name == "CString" || name == "GoString" || name == "GoStringN" || name == "GoBytes"
+
if *gccgo {
// Gccgo style hooks.
fmt.Fprint(fgo2, "\n")
@@ -331,8 +334,10 @@ func (p *Package) writeDefsFunc(fc, fgo2 *os.File, n *Name) {
conf.Fprint(fgo2, fset, d)
fmt.Fprint(fgo2, " {\n")
- fmt.Fprint(fgo2, "\tdefer syscall.CgocallDone()\n")
- fmt.Fprint(fgo2, "\tsyscall.Cgocall()\n")
+ if !inProlog {
+ fmt.Fprint(fgo2, "\tdefer syscall.CgocallDone()\n")
+ fmt.Fprint(fgo2, "\tsyscall.Cgocall()\n")
+ }
if n.AddError {
fmt.Fprint(fgo2, "\tsyscall.SetErrno(0)\n")
}
@@ -363,7 +368,11 @@ func (p *Package) writeDefsFunc(fc, fgo2 *os.File, n *Name) {
fmt.Fprint(fgo2, "}\n")
// declare the C function.
- fmt.Fprintf(fgo2, "//extern %s\n", n.C)
+ if inProlog {
+ fmt.Fprintf(fgo2, "//extern %s\n", n.C)
+ } else {
+ fmt.Fprintf(fgo2, "//extern _cgo%s%s\n", cPrefix, n.Mangle)
+ }
d.Name = ast.NewIdent(cname)
if n.AddError {
l := d.Type.Results.List
@@ -377,8 +386,7 @@ func (p *Package) writeDefsFunc(fc, fgo2 *os.File, n *Name) {
conf.Fprint(fgo2, fset, d)
fmt.Fprint(fgo2, "\n")
- if name == "CString" || name == "GoString" || name == "GoStringN" || name == "GoBytes" {
- // The builtins are already defined in the C prolog.
+ if inProlog {
return
}
@@ -466,7 +474,7 @@ func (p *Package) writeOutputFunc(fgcc *os.File, n *Name) {
p.Written[name] = true
if *gccgo {
- // we don't use wrappers with gccgo.
+ p.writeGccgoOutputFunc(fgcc, n)
return
}
@@ -518,6 +526,54 @@ func (p *Package) writeOutputFunc(fgcc *os.File, n *Name) {
fmt.Fprintf(fgcc, "\n")
}
+// Write out a wrapper for a function when using gccgo. This is a
+// simple wrapper that just calls the real function. We only need a
+// wrapper to support static functions in the prologue--without a
+// wrapper, we can't refer to the function, since the reference is in
+// a different file.
+func (p *Package) writeGccgoOutputFunc(fgcc *os.File, n *Name) {
+ if t := n.FuncType.Result; t != nil {
+ fmt.Fprintf(fgcc, "%s\n", t.C.String())
+ } else {
+ fmt.Fprintf(fgcc, "void\n")
+ }
+ fmt.Fprintf(fgcc, "_cgo%s%s(", cPrefix, n.Mangle)
+ for i, t := range n.FuncType.Params {
+ if i > 0 {
+ fmt.Fprintf(fgcc, ", ")
+ }
+ c := t.Typedef
+ if c == "" {
+ c = t.C.String()
+ }
+ fmt.Fprintf(fgcc, "%s p%d", c, i)
+ }
+ fmt.Fprintf(fgcc, ")\n")
+ fmt.Fprintf(fgcc, "{\n")
+ fmt.Fprintf(fgcc, "\t")
+ if t := n.FuncType.Result; t != nil {
+ fmt.Fprintf(fgcc, "return ")
+ // Cast to void* to avoid warnings due to omitted qualifiers.
+ if c := t.C.String(); c[len(c)-1] == '*' {
+ fmt.Fprintf(fgcc, "(void*)")
+ }
+ }
+ fmt.Fprintf(fgcc, "%s(", n.C)
+ for i, t := range n.FuncType.Params {
+ if i > 0 {
+ fmt.Fprintf(fgcc, ", ")
+ }
+ // Cast to void* to avoid warnings due to omitted qualifiers.
+ if c := t.C.String(); c[len(c)-1] == '*' {
+ fmt.Fprintf(fgcc, "(void*)")
+ }
+ fmt.Fprintf(fgcc, "p%d", i)
+ }
+ fmt.Fprintf(fgcc, ");\n")
+ fmt.Fprintf(fgcc, "}\n")
+ fmt.Fprintf(fgcc, "\n")
+}
+
// Write out the various stubs we need to support functions exported
// from Go so that they are callable from C.
func (p *Package) writeExports(fgo2, fc, fm *os.File) {
diff --git a/src/cmd/gc/closure.c b/src/cmd/gc/closure.c
index d81c5281d..996504a11 100644
--- a/src/cmd/gc/closure.c
+++ b/src/cmd/gc/closure.c
@@ -280,7 +280,7 @@ typecheckpartialcall(Node *fn, Node *sym)
static Node*
makepartialcall(Node *fn, Type *t0, Node *meth)
{
- Node *ptr, *n, *fld, *call, *xtype, *xfunc, *cv;
+ Node *ptr, *n, *fld, *call, *xtype, *xfunc, *cv, *savecurfn;
Type *rcvrtype, *basetype, *t;
NodeList *body, *l, *callargs, *retargs;
char *p;
@@ -304,6 +304,9 @@ makepartialcall(Node *fn, Type *t0, Node *meth)
if(sym->flags & SymUniq)
return sym->def;
sym->flags |= SymUniq;
+
+ savecurfn = curfn;
+ curfn = N;
xtype = nod(OTFUNC, N, N);
i = 0;
@@ -311,6 +314,7 @@ makepartialcall(Node *fn, Type *t0, Node *meth)
callargs = nil;
ddd = 0;
xfunc = nod(ODCLFUNC, N, N);
+ curfn = xfunc;
for(t = getinargx(t0)->type; t; t = t->down) {
snprint(namebuf, sizeof namebuf, "a%d", i++);
n = newname(lookup(namebuf));
@@ -385,6 +389,7 @@ makepartialcall(Node *fn, Type *t0, Node *meth)
typecheck(&xfunc, Etop);
sym->def = xfunc;
xtop = list(xtop, xfunc);
+ curfn = savecurfn;
return xfunc;
}
diff --git a/src/cmd/gc/export.c b/src/cmd/gc/export.c
index 4a9b8c8ba..caac330d5 100644
--- a/src/cmd/gc/export.c
+++ b/src/cmd/gc/export.c
@@ -161,6 +161,11 @@ reexportdep(Node *n)
case OCONV:
case OCONVIFACE:
case OCONVNOP:
+ case ORUNESTR:
+ case OARRAYBYTESTR:
+ case OARRAYRUNESTR:
+ case OSTRARRAYBYTE:
+ case OSTRARRAYRUNE:
case ODOTTYPE:
case ODOTTYPE2:
case OSTRUCTLIT:
diff --git a/src/cmd/gc/fmt.c b/src/cmd/gc/fmt.c
index 35f01a5c2..b5f6a9b8f 100644
--- a/src/cmd/gc/fmt.c
+++ b/src/cmd/gc/fmt.c
@@ -1218,7 +1218,7 @@ exprfmt(Fmt *f, Node *n, int prec)
}
if(fmtmode == FExp && ptrlit)
// typecheck has overwritten OIND by OTYPE with pointer type.
- return fmtprint(f, "&%T{ %,H }", n->right->type->type, n->list);
+ return fmtprint(f, "(&%T{ %,H })", n->right->type->type, n->list);
return fmtprint(f, "(%N{ %,H })", n->right, n->list);
case OPTRLIT:
diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c
index d9c6341b4..e8ebd2892 100644
--- a/src/cmd/gc/walk.c
+++ b/src/cmd/gc/walk.c
@@ -1338,6 +1338,13 @@ walkexpr(Node **np, NodeList **init)
fatal("missing switch %O", n->op);
ret:
+ // Expressions that are constant at run time but not
+ // considered const by the language spec are not turned into
+ // constants until walk. For example, if n is y%1 == 0, the
+ // walk of y%1 may have replaced it by 0.
+ // Check whether n with its updated args is itself now a constant.
+ evconst(n);
+
ullmancalc(n);
if(debug['w'] && n != N)
diff --git a/src/pkg/bufio/bufio.go b/src/pkg/bufio/bufio.go
index df3501f2c..10e12d42b 100644
--- a/src/pkg/bufio/bufio.go
+++ b/src/pkg/bufio/bufio.go
@@ -585,23 +585,28 @@ func (b *Writer) ReadFrom(r io.Reader) (n int64, err error) {
}
var m int
for {
+ if b.Available() == 0 {
+ if err1 := b.Flush(); err1 != nil {
+ return n, err1
+ }
+ }
m, err = r.Read(b.buf[b.n:])
if m == 0 {
break
}
b.n += m
n += int64(m)
- if b.Available() == 0 {
- if err1 := b.Flush(); err1 != nil {
- return n, err1
- }
- }
if err != nil {
break
}
}
if err == io.EOF {
- err = nil
+ // If we filled the buffer exactly, flush pre-emptively.
+ if b.Available() == 0 {
+ err = b.Flush()
+ } else {
+ err = nil
+ }
}
return n, err
}
diff --git a/src/pkg/bufio/bufio_test.go b/src/pkg/bufio/bufio_test.go
index 79ed0f178..9fcbfda68 100644
--- a/src/pkg/bufio/bufio_test.go
+++ b/src/pkg/bufio/bufio_test.go
@@ -847,6 +847,10 @@ func TestWriterReadFrom(t *testing.T) {
t.Errorf("ws[%d],rs[%d]: w.ReadFrom(r) = %d, %v, want %d, nil", wi, ri, n, err, len(input))
continue
}
+ if err := w.Flush(); err != nil {
+ t.Errorf("Flush returned %v", err)
+ continue
+ }
if got, want := b.String(), string(input); got != want {
t.Errorf("ws[%d], rs[%d]:\ngot %q\nwant %q\n", wi, ri, got, want)
}
@@ -1003,6 +1007,24 @@ func TestReaderClearError(t *testing.T) {
}
}
+// Test for golang.org/issue/5947
+func TestWriterReadFromWhileFull(t *testing.T) {
+ buf := new(bytes.Buffer)
+ w := NewWriterSize(buf, 10)
+
+ // Fill buffer exactly.
+ n, err := w.Write([]byte("0123456789"))
+ if n != 10 || err != nil {
+ t.Fatalf("Write returned (%v, %v), want (10, nil)", n, err)
+ }
+
+ // Use ReadFrom to read in some data.
+ n2, err := w.ReadFrom(strings.NewReader("abcdef"))
+ if n2 != 6 || err != nil {
+ t.Fatalf("ReadFrom returned (%v, %v), want (6, nil)", n, err)
+ }
+}
+
// An onlyReader only implements io.Reader, no matter what other methods the underlying implementation may have.
type onlyReader struct {
r io.Reader
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c
index 31876b62a..5734509e0 100644
--- a/src/pkg/runtime/proc.c
+++ b/src/pkg/runtime/proc.c
@@ -1371,6 +1371,8 @@ runtime·exitsyscall(void)
runtime·unlock(&runtime·sched);
if(p) {
acquirep(p);
+ m->p->tick++;
+ g->status = Grunning;
g->gcstack = (uintptr)nil;
g->gcsp = (uintptr)nil;
return;
diff --git a/src/pkg/runtime/time.goc b/src/pkg/runtime/time.goc
index 6de989f51..be0c1f83d 100644
--- a/src/pkg/runtime/time.goc
+++ b/src/pkg/runtime/time.goc
@@ -131,6 +131,11 @@ runtime·deltimer(Timer *t)
{
int32 i;
+ // Dereference t so that any panic happens before the lock is held.
+ // Discard result, because t might be moving in the heap.
+ i = t->i;
+ USED(i);
+
runtime·lock(&timers);
// t may not be registered anymore and may have
diff --git a/src/pkg/syscall/rlimit_linux_test.go b/src/pkg/syscall/rlimit_linux_test.go
new file mode 100644
index 000000000..4ec720e93
--- /dev/null
+++ b/src/pkg/syscall/rlimit_linux_test.go
@@ -0,0 +1,41 @@
+// Copyright 2013 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 syscall_test
+
+import (
+ "syscall"
+ "testing"
+)
+
+func TestRlimit(t *testing.T) {
+ var rlimit, zero syscall.Rlimit
+ err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlimit)
+ if err != nil {
+ t.Fatalf("Getrlimit: save failed: %v", err)
+ }
+ if zero == rlimit {
+ t.Fatalf("Getrlimit: save failed: got zero value %#v", rlimit)
+ }
+ set := rlimit
+ set.Cur = set.Max - 1
+ err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &set)
+ if err != nil {
+ t.Fatalf("Setrlimit: set failed: %#v %v", set, err)
+ }
+ var get syscall.Rlimit
+ err = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &get)
+ if err != nil {
+ t.Fatalf("Getrlimit: get failed: %v", err)
+ }
+ set = rlimit
+ set.Cur = set.Max - 1
+ if set != get {
+ t.Fatalf("Rlimit: change failed: wanted %#v got %#v", set, get)
+ }
+ err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlimit)
+ if err != nil {
+ t.Fatalf("Setrlimit: restore failed: %#v %v", rlimit, err)
+ }
+}
diff --git a/src/pkg/syscall/syscall_linux_386.go b/src/pkg/syscall/syscall_linux_386.go
index a0ded43dc..a61695676 100644
--- a/src/pkg/syscall/syscall_linux_386.go
+++ b/src/pkg/syscall/syscall_linux_386.go
@@ -78,7 +78,7 @@ const rlimInf32 = ^uint32(0)
const rlimInf64 = ^uint64(0)
func Getrlimit(resource int, rlim *Rlimit) (err error) {
- err = prlimit(0, resource, rlim, nil)
+ err = prlimit(0, resource, nil, rlim)
if err != ENOSYS {
return err
}
@@ -106,7 +106,7 @@ func Getrlimit(resource int, rlim *Rlimit) (err error) {
//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT
func Setrlimit(resource int, rlim *Rlimit) (err error) {
- err = prlimit(0, resource, nil, rlim)
+ err = prlimit(0, resource, rlim, nil)
if err != ENOSYS {
return err
}
diff --git a/src/pkg/syscall/syscall_linux_arm.go b/src/pkg/syscall/syscall_linux_arm.go
index 7839d5288..4aadf9e4c 100644
--- a/src/pkg/syscall/syscall_linux_arm.go
+++ b/src/pkg/syscall/syscall_linux_arm.go
@@ -119,7 +119,7 @@ const rlimInf32 = ^uint32(0)
const rlimInf64 = ^uint64(0)
func Getrlimit(resource int, rlim *Rlimit) (err error) {
- err = prlimit(0, resource, rlim, nil)
+ err = prlimit(0, resource, nil, rlim)
if err != ENOSYS {
return err
}
@@ -147,7 +147,7 @@ func Getrlimit(resource int, rlim *Rlimit) (err error) {
//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT
func Setrlimit(resource int, rlim *Rlimit) (err error) {
- err = prlimit(0, resource, nil, rlim)
+ err = prlimit(0, resource, rlim, nil)
if err != ENOSYS {
return err
}
diff --git a/src/pkg/time/sleep_test.go b/src/pkg/time/sleep_test.go
index 1322f0611..603adc9b8 100644
--- a/src/pkg/time/sleep_test.go
+++ b/src/pkg/time/sleep_test.go
@@ -314,3 +314,23 @@ func TestOverflowSleep(t *testing.T) {
t.Fatalf("negative timeout didn't fire")
}
}
+
+// Test that a panic while deleting a timer does not leave
+// the timers mutex held, deadlocking a ticker.Stop in a defer.
+func TestIssue5745(t *testing.T) {
+ ticker := NewTicker(Hour)
+ defer func() {
+ // would deadlock here before the fix due to
+ // lock taken before the segfault.
+ ticker.Stop()
+
+ if r := recover(); r == nil {
+ t.Error("Expected panic, but none happened.")
+ }
+ }()
+
+ // cause a panic due to a segfault
+ var timer *Timer
+ timer.Stop()
+ t.Error("Should be unreachable.")
+}
diff --git a/test/fixedbugs/bug465.dir/a.go b/test/fixedbugs/bug465.dir/a.go
index c5d410de4..a9a8614bb 100644
--- a/test/fixedbugs/bug465.dir/a.go
+++ b/test/fixedbugs/bug465.dir/a.go
@@ -59,3 +59,18 @@ func F7() int {
}
return 0
}
+
+func F8() int {
+ if a := (&T{1, 1}); a != nil {
+ return 1
+ }
+ return 0
+}
+
+func F9() int {
+ var a *T
+ if a = (&T{1, 1}); a != nil {
+ return 1
+ }
+ return 0
+}
diff --git a/test/fixedbugs/bug465.dir/b.go b/test/fixedbugs/bug465.dir/b.go
index 0f4909f4d..c84c6836d 100644
--- a/test/fixedbugs/bug465.dir/b.go
+++ b/test/fixedbugs/bug465.dir/b.go
@@ -9,7 +9,7 @@ import "./a"
func main() {
for _, f := range []func() int{
a.F1, a.F2, a.F3, a.F4,
- a.F5, a.F6, a.F7} {
+ a.F5, a.F6, a.F7, a.F8, a.F9} {
if f() > 1 {
panic("f() > 1")
}
diff --git a/test/fixedbugs/issue5753.go b/test/fixedbugs/issue5753.go
new file mode 100644
index 000000000..230a1e8c3
--- /dev/null
+++ b/test/fixedbugs/issue5753.go
@@ -0,0 +1,29 @@
+// run
+
+// Copyright 2013 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.
+
+// issue 5753: bad typecheck info causes escape analysis to
+// not run on method thunks.
+
+package main
+
+type Thing struct{}
+
+func (t *Thing) broken(s string) []string {
+ foo := [1]string{s}
+ return foo[:]
+}
+
+func main() {
+ t := &Thing{}
+
+ f := t.broken
+ s := f("foo")
+ _ = f("bar")
+ if s[0] != "foo" {
+ panic(`s[0] != "foo"`)
+ }
+
+}
diff --git a/test/fixedbugs/issue5755.dir/a.go b/test/fixedbugs/issue5755.dir/a.go
new file mode 100644
index 000000000..aa398e82b
--- /dev/null
+++ b/test/fixedbugs/issue5755.dir/a.go
@@ -0,0 +1,60 @@
+// Copyright 2013 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 a
+
+type I interface {
+ F()
+}
+
+type foo1 []byte
+type foo2 []rune
+type foo3 []uint8
+type foo4 []int32
+type foo5 string
+type foo6 string
+type foo7 string
+type foo8 string
+type foo9 string
+
+func (f foo1) F() { return }
+func (f foo2) F() { return }
+func (f foo3) F() { return }
+func (f foo4) F() { return }
+func (f foo5) F() { return }
+func (f foo6) F() { return }
+func (f foo7) F() { return }
+func (f foo8) F() { return }
+func (f foo9) F() { return }
+
+func Test1(s string) I { return foo1(s) }
+func Test2(s string) I { return foo2(s) }
+func Test3(s string) I { return foo3(s) }
+func Test4(s string) I { return foo4(s) }
+func Test5(s []byte) I { return foo5(s) }
+func Test6(s []rune) I { return foo6(s) }
+func Test7(s []uint8) I { return foo7(s) }
+func Test8(s []int32) I { return foo8(s) }
+func Test9(s int) I { return foo9(s) }
+
+type bar map[int]int
+
+func (b bar) F() { return }
+
+func TestBar() I { return bar{1: 2} }
+
+type baz int
+
+func IsBaz(x interface{}) bool { _, ok := x.(baz); return ok }
+
+type baz2 int
+
+func IsBaz2(x interface{}) bool {
+ switch x.(type) {
+ case baz2:
+ return true
+ default:
+ return false
+ }
+}
diff --git a/test/fixedbugs/issue5755.dir/main.go b/test/fixedbugs/issue5755.dir/main.go
new file mode 100644
index 000000000..6d515f26a
--- /dev/null
+++ b/test/fixedbugs/issue5755.dir/main.go
@@ -0,0 +1,23 @@
+// Copyright 2013 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 main
+
+import "./a"
+
+func main() {
+ a.Test1("frumious")
+ a.Test2("frumious")
+ a.Test3("frumious")
+ a.Test4("frumious")
+
+ a.Test5(nil)
+ a.Test6(nil)
+ a.Test7(nil)
+ a.Test8(nil)
+ a.Test9(0)
+
+ a.TestBar()
+ a.IsBaz(nil)
+}
diff --git a/test/fixedbugs/issue5755.go b/test/fixedbugs/issue5755.go
new file mode 100644
index 000000000..fa7ea4d20
--- /dev/null
+++ b/test/fixedbugs/issue5755.go
@@ -0,0 +1,10 @@
+// compiledir
+
+// Copyright 2013 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.
+
+// Issue 5755: exported data for inlining may miss
+// named types when used in string conversions.
+
+package ignored
diff --git a/test/fixedbugs/issue5809.go b/test/fixedbugs/issue5809.go
new file mode 100644
index 000000000..ca060b55d
--- /dev/null
+++ b/test/fixedbugs/issue5809.go
@@ -0,0 +1,27 @@
+// run
+
+// Copyright 2013 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.
+
+// issue 5809: 6g and 8g attempted to constant propagate indexed LEA
+
+package main
+
+import "fmt"
+
+func main() {
+ const d16 = "0123456789ABCDEF"
+ k := 0x1234
+ var x [4]byte
+
+ x[0] = d16[k>>12&0xf]
+ x[1] = d16[k>>8&0xf]
+ x[2] = d16[k>>4&0xf]
+ x[3] = d16[k&0xf]
+
+ if x != [4]byte{'1','2','3','4'} {
+ fmt.Println(x)
+ panic("x != [4]byte{'1','2','3','4'}")
+ }
+}
diff --git a/test/fixedbugs/issue5820.go b/test/fixedbugs/issue5820.go
new file mode 100644
index 000000000..94de06d57
--- /dev/null
+++ b/test/fixedbugs/issue5820.go
@@ -0,0 +1,18 @@
+// run
+
+// Copyright 2013 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.
+
+// issue 5820: register clobber when clearfat and 64 bit arithmetic is interleaved.
+
+package main
+
+func main() {
+ array := make([][]int, 2)
+ index := uint64(1)
+ array[index] = nil
+ if array[1] != nil {
+ panic("array[1] != nil")
+ }
+}
diff --git a/test/fixedbugs/issue5841.go b/test/fixedbugs/issue5841.go
new file mode 100644
index 000000000..cfc4a504c
--- /dev/null
+++ b/test/fixedbugs/issue5841.go
@@ -0,0 +1,16 @@
+// build
+
+// Copyright 2013 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.
+
+// Issue 5841: 8g produces invalid CMPL $0, $0.
+// Similar to issue 5002, used to fail at link time.
+
+package main
+
+func main() {
+ var y int
+ if y%1 == 0 {
+ }
+}