aboutsummaryrefslogtreecommitdiffstats
path: root/test/fixedbugs
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2018-02-27 19:36:27 -0800
committerDan Willemsen <dwillemsen@google.com>2018-02-27 19:36:27 -0800
commite1b3b188ff03c41213dca621c46c39702d79f3ee (patch)
tree67ab03d7ee51c5fafa1602c28e0d9033a8e3f26d /test/fixedbugs
parent3c27c3f6c42dbb890c67820f2897812e16f01be1 (diff)
downloadplatform_prebuilts_go_linux-x86-e1b3b188ff03c41213dca621c46c39702d79f3ee.tar.gz
platform_prebuilts_go_linux-x86-e1b3b188ff03c41213dca621c46c39702d79f3ee.tar.bz2
platform_prebuilts_go_linux-x86-e1b3b188ff03c41213dca621c46c39702d79f3ee.zip
Test: m -j blueprint_tools Change-Id: I12d0286a2978fcbafa50880625700ba69c4581d8
Diffstat (limited to 'test/fixedbugs')
-rw-r--r--test/fixedbugs/bug289.go4
-rw-r--r--test/fixedbugs/bug388.go2
-rw-r--r--test/fixedbugs/bug487.go4
-rw-r--r--test/fixedbugs/bug503.go16
-rw-r--r--test/fixedbugs/bug504.dir/a.go7
-rw-r--r--test/fixedbugs/bug504.dir/b.go11
-rw-r--r--test/fixedbugs/bug504.dir/c.go9
-rw-r--r--test/fixedbugs/bug504.dir/main.go11
-rw-r--r--test/fixedbugs/bug504.go10
-rw-r--r--test/fixedbugs/bug505.go20
-rw-r--r--test/fixedbugs/issue13265.go15
-rw-r--r--test/fixedbugs/issue14006.go3
-rw-r--r--test/fixedbugs/issue14540.go20
-rw-r--r--test/fixedbugs/issue15747.go6
-rw-r--r--test/fixedbugs/issue15747b.go2
-rw-r--r--test/fixedbugs/issue18902.go12
-rw-r--r--test/fixedbugs/issue19137.go16
-rw-r--r--test/fixedbugs/issue19261.dir/p.go24
-rw-r--r--test/fixedbugs/issue19261.dir/q.go17
-rw-r--r--test/fixedbugs/issue19261.go7
-rw-r--r--test/fixedbugs/issue20250.go10
-rw-r--r--test/fixedbugs/issue20739.go16
-rw-r--r--test/fixedbugs/issue20812.go15
-rw-r--r--test/fixedbugs/issue21253.go27
-rw-r--r--test/fixedbugs/issue21256.go9
-rw-r--r--test/fixedbugs/issue21273.go28
-rw-r--r--test/fixedbugs/issue21317.go60
-rw-r--r--test/fixedbugs/issue21655.go62
-rw-r--r--test/fixedbugs/issue21687.go68
-rw-r--r--test/fixedbugs/issue21709.go37
-rw-r--r--test/fixedbugs/issue21770.go20
-rw-r--r--test/fixedbugs/issue21808.go17
-rw-r--r--test/fixedbugs/issue21808.out3
-rw-r--r--test/fixedbugs/issue21879.go37
-rw-r--r--test/fixedbugs/issue21879.out2
-rw-r--r--test/fixedbugs/issue21882.go9
-rw-r--r--test/fixedbugs/issue21887.go25
-rw-r--r--test/fixedbugs/issue21887.out2
-rw-r--r--test/fixedbugs/issue21963.go27
-rw-r--r--test/fixedbugs/issue21988.go17
-rw-r--r--test/fixedbugs/issue22063.go17
-rw-r--r--test/fixedbugs/issue22076.go25
-rw-r--r--test/fixedbugs/issue22083.go41
-rw-r--r--test/fixedbugs/issue22164.go26
-rw-r--r--test/fixedbugs/issue22198.go18
-rw-r--r--test/fixedbugs/issue22200.go20
-rw-r--r--test/fixedbugs/issue22200b.go28
-rw-r--r--test/fixedbugs/issue22351.go11
-rw-r--r--test/fixedbugs/issue22389.go18
-rw-r--r--test/fixedbugs/issue22429.go18
-rw-r--r--test/fixedbugs/issue22458.go26
-rw-r--r--test/fixedbugs/issue22581.go27
-rw-r--r--test/fixedbugs/issue22605.go26
-rw-r--r--test/fixedbugs/issue22660.go50
-rw-r--r--test/fixedbugs/issue22683.go30
-rw-r--r--test/fixedbugs/issue22683.out1
-rw-r--r--test/fixedbugs/issue22781.go29
-rw-r--r--test/fixedbugs/issue22794.go20
-rw-r--r--test/fixedbugs/issue22877.dir/p.go14
-rw-r--r--test/fixedbugs/issue22877.dir/p.s8
-rw-r--r--test/fixedbugs/issue22877.go7
-rw-r--r--test/fixedbugs/issue22881.go72
-rw-r--r--test/fixedbugs/issue22904.go19
-rw-r--r--test/fixedbugs/issue22941.dir/a.go7
-rw-r--r--test/fixedbugs/issue22941.dir/b.go30
-rw-r--r--test/fixedbugs/issue22941.dir/main.go15
-rw-r--r--test/fixedbugs/issue22941.go7
-rw-r--r--test/fixedbugs/issue22962.dir/a.go11
-rw-r--r--test/fixedbugs/issue22962.dir/b.go9
-rw-r--r--test/fixedbugs/issue22962.go7
-rw-r--r--test/fixedbugs/issue23093.go9
-rw-r--r--test/fixedbugs/issue23179.dir/a.go13
-rw-r--r--test/fixedbugs/issue23179.dir/b.go11
-rw-r--r--test/fixedbugs/issue23179.go7
-rw-r--r--test/fixedbugs/issue23305.go28
-rw-r--r--test/fixedbugs/issue23522.go46
-rw-r--r--test/fixedbugs/issue23545.go35
-rw-r--r--test/fixedbugs/issue23719.go42
-rw-r--r--test/fixedbugs/issue23812.go34
-rw-r--r--test/fixedbugs/issue4388.go56
-rw-r--r--test/fixedbugs/issue7525.go4
-rw-r--r--test/fixedbugs/issue7525d.go15
-rw-r--r--test/fixedbugs/issue7525e.go15
83 files changed, 1586 insertions, 73 deletions
diff --git a/test/fixedbugs/bug289.go b/test/fixedbugs/bug289.go
index a3f72955..3fc7fb2e 100644
--- a/test/fixedbugs/bug289.go
+++ b/test/fixedbugs/bug289.go
@@ -9,14 +9,14 @@
package main
func f1() {
- a, b := f() // ERROR "cannot assign|does not match"
+ a, b := f() // ERROR "assignment mismatch|does not match"
_ = a
_ = b
}
func f2() {
var a, b int
- a, b = f() // ERROR "cannot assign|does not match"
+ a, b = f() // ERROR "assignment mismatch|does not match"
_ = a
_ = b
}
diff --git a/test/fixedbugs/bug388.go b/test/fixedbugs/bug388.go
index af0c9d9c..2d508501 100644
--- a/test/fixedbugs/bug388.go
+++ b/test/fixedbugs/bug388.go
@@ -14,7 +14,7 @@ func foo(runtime.UintType, i int) { // ERROR "cannot declare name runtime.UintT
}
func bar(i int) {
- runtime.UintType := i // ERROR "cannot declare name runtime.UintType|non-name on left side|undefined identifier"
+ runtime.UintType := i // ERROR "non-name runtime.UintType|non-name on left side|undefined identifier"
println(runtime.UintType) // GCCGO_ERROR "invalid use of type|undefined identifier"
}
diff --git a/test/fixedbugs/bug487.go b/test/fixedbugs/bug487.go
index 60a4ea98..ab61a19a 100644
--- a/test/fixedbugs/bug487.go
+++ b/test/fixedbugs/bug487.go
@@ -14,8 +14,8 @@ func G() (int, int, int) {
}
func F() {
- a, b := G() // ERROR "cannot assign"
- a, b = G() // ERROR "cannot assign"
+ a, b := G() // ERROR "assignment mismatch"
+ a, b = G() // ERROR "assignment mismatch"
_, _ = a, b
}
diff --git a/test/fixedbugs/bug503.go b/test/fixedbugs/bug503.go
new file mode 100644
index 00000000..7bbc7981
--- /dev/null
+++ b/test/fixedbugs/bug503.go
@@ -0,0 +1,16 @@
+// compile
+
+// Copyright 2017 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.
+
+// gccgo crashed compiling this file, due to failing to correctly emit
+// the type descriptor for a named alias.
+
+package p
+
+type entry = struct {
+ a, b, c int
+}
+
+var V entry
diff --git a/test/fixedbugs/bug504.dir/a.go b/test/fixedbugs/bug504.dir/a.go
new file mode 100644
index 00000000..ac0be937
--- /dev/null
+++ b/test/fixedbugs/bug504.dir/a.go
@@ -0,0 +1,7 @@
+// Copyright 2017 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 MyInt = int
diff --git a/test/fixedbugs/bug504.dir/b.go b/test/fixedbugs/bug504.dir/b.go
new file mode 100644
index 00000000..e8f8da9a
--- /dev/null
+++ b/test/fixedbugs/bug504.dir/b.go
@@ -0,0 +1,11 @@
+// Copyright 2017 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 b
+
+import "./a"
+
+func F() a.MyInt {
+ return 0
+}
diff --git a/test/fixedbugs/bug504.dir/c.go b/test/fixedbugs/bug504.dir/c.go
new file mode 100644
index 00000000..5a6e8899
--- /dev/null
+++ b/test/fixedbugs/bug504.dir/c.go
@@ -0,0 +1,9 @@
+// Copyright 2017 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 c
+
+import "./b"
+
+var V = b.F()
diff --git a/test/fixedbugs/bug504.dir/main.go b/test/fixedbugs/bug504.dir/main.go
new file mode 100644
index 00000000..bdbd95c7
--- /dev/null
+++ b/test/fixedbugs/bug504.dir/main.go
@@ -0,0 +1,11 @@
+// Copyright 2017 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 "./c"
+
+func main() {
+ println(c.V)
+}
diff --git a/test/fixedbugs/bug504.go b/test/fixedbugs/bug504.go
new file mode 100644
index 00000000..ae1f2e52
--- /dev/null
+++ b/test/fixedbugs/bug504.go
@@ -0,0 +1,10 @@
+// compiledir
+
+// Copyright 2017 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.
+
+// Gccgo mishandled a reference to a type alias in a package that was
+// not directly imported.
+
+package ignored
diff --git a/test/fixedbugs/bug505.go b/test/fixedbugs/bug505.go
new file mode 100644
index 00000000..062a0871
--- /dev/null
+++ b/test/fixedbugs/bug505.go
@@ -0,0 +1,20 @@
+// compile
+
+// Copyright 2017 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.
+
+// gccgo crashed compiling this file with a failed conversion to the
+// alias type when constructing the composite literal.
+
+package p
+
+type I interface{ M() }
+type A = I
+type S struct {
+ f A
+}
+
+func F(i I) S {
+ return S{f: i}
+}
diff --git a/test/fixedbugs/issue13265.go b/test/fixedbugs/issue13265.go
new file mode 100644
index 00000000..3036ba7c
--- /dev/null
+++ b/test/fixedbugs/issue13265.go
@@ -0,0 +1,15 @@
+// errorcheck -0 -race
+
+// Copyright 2017 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 13265: nil pointer deref.
+
+package p
+
+func f() {
+ var c chan chan chan int
+ for ; ; <-<-<-c {
+ }
+}
diff --git a/test/fixedbugs/issue14006.go b/test/fixedbugs/issue14006.go
index d69bdd48..02041cc2 100644
--- a/test/fixedbugs/issue14006.go
+++ b/test/fixedbugs/issue14006.go
@@ -50,7 +50,10 @@ func f() {
labelname: // ERROR "missing statement after label"
case false:
}
+}
+func g() {
+ var z bool
switch {
case z:
labelname: // ERROR "label labelname defined and not used"
diff --git a/test/fixedbugs/issue14540.go b/test/fixedbugs/issue14540.go
new file mode 100644
index 00000000..62b17a04
--- /dev/null
+++ b/test/fixedbugs/issue14540.go
@@ -0,0 +1,20 @@
+// errorcheck
+
+// Copyright 2017 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
+
+func f(x int) {
+ switch x {
+ case 0:
+ fallthrough
+ ; // ok
+ case 1:
+ fallthrough // ERROR "fallthrough statement out of place"
+ {}
+ case 2:
+ fallthrough // ERROR "cannot fallthrough"
+ }
+}
diff --git a/test/fixedbugs/issue15747.go b/test/fixedbugs/issue15747.go
index 836d0eab..decabc75 100644
--- a/test/fixedbugs/issue15747.go
+++ b/test/fixedbugs/issue15747.go
@@ -1,4 +1,4 @@
-// errorcheck -0 -live
+// errorcheck -0 -live -d=eagerwb
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
@@ -7,6 +7,10 @@
// Issue 15747: liveness analysis was marking heap-escaped params live too much,
// and worse was using the wrong bitmap bits to do so.
+// TODO(austin): This expects function calls to the write barrier, so
+// we enable the legacy eager write barrier. Fix this once the
+// buffered write barrier works on all arches.
+
package p
var global *[]byte
diff --git a/test/fixedbugs/issue15747b.go b/test/fixedbugs/issue15747b.go
index 9620d3d0..bdb2a940 100644
--- a/test/fixedbugs/issue15747b.go
+++ b/test/fixedbugs/issue15747b.go
@@ -4,7 +4,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Issue 15747: If a ODCL is dropped, for example when inlining,
+// Issue 15747: If an ODCL is dropped, for example when inlining,
// then it's easy to end up not initializing the '&x' pseudo-variable
// to point to an actual allocation. The liveness analysis will detect
// this and abort the computation, so this test just checks that the
diff --git a/test/fixedbugs/issue18902.go b/test/fixedbugs/issue18902.go
index f5bca16a..78c92187 100644
--- a/test/fixedbugs/issue18902.go
+++ b/test/fixedbugs/issue18902.go
@@ -50,13 +50,16 @@ func main() {
testarch := os.Getenv("TESTARCH") // Targets other platform in test compilation.
debug := os.Getenv("TESTDEBUG") != "" // Output the relevant assembly language.
- cmd := exec.Command("go", "build", "-gcflags", "-S", "fixedbugs/issue18902b.go")
+ cmd := exec.Command("go", "tool", "compile", "-S", "fixedbugs/issue18902b.go")
var buf bytes.Buffer
cmd.Stdout = &buf
cmd.Stderr = &buf
cmd.Env = os.Environ()
- updateEnv(&cmd.Env, "GOARCH", testarch)
+ if testarch != "" {
+ updateEnv(&cmd.Env, "GOARCH", testarch)
+ updateEnv(&cmd.Env, "GOOS", "linux") // Simplify multi-arch testing
+ }
err := cmd.Run()
if err != nil {
@@ -89,8 +92,9 @@ func main() {
i = strings.Index(line, beforeLineNumber)
if i < 0 {
// Done reading lines
- if scannedCount < 200 { // When test was written, 251 lines observed on amd64
- fmt.Printf("Scanned only %d lines, was expecting more than 200", scannedCount)
+ const minLines = 150
+ if scannedCount <= minLines { // When test was written, 251 lines observed on amd64; arm64 now obtains 184
+ fmt.Printf("Scanned only %d lines, was expecting more than %d\n", int(scannedCount), minLines)
return
}
// Note: when test was written, before changes=92, after=50 (was 62 w/o rematerialization NoXPos in *Value.copyInto())
diff --git a/test/fixedbugs/issue19137.go b/test/fixedbugs/issue19137.go
index 946f029b..0539a850 100644
--- a/test/fixedbugs/issue19137.go
+++ b/test/fixedbugs/issue19137.go
@@ -33,3 +33,19 @@ func zero() ([20]byte, [20]byte) {
_ = x
return [20]byte{}, [20]byte{} // the second return value is not 8-byte aligned to SP
}
+
+// Issue 21992: unaligned offset between 256 and 504 and handled
+// incorrectly.
+type T2 struct {
+ a [257]byte
+ // fields below are not 8-, 4-, 2-byte aligned
+ b [8]byte
+ c [4]byte
+ d [2]byte
+}
+
+func f2(x *T2) {
+ x.b = [8]byte{}
+ x.c = [4]byte{}
+ x.d = [2]byte{}
+}
diff --git a/test/fixedbugs/issue19261.dir/p.go b/test/fixedbugs/issue19261.dir/p.go
new file mode 100644
index 00000000..1c44d8a3
--- /dev/null
+++ b/test/fixedbugs/issue19261.dir/p.go
@@ -0,0 +1,24 @@
+// Copyright 2017 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
+
+func F() { // ERROR "can inline F"
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+}
+
+func G() {
+ F() // ERROR "inlining call to F"
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+}
diff --git a/test/fixedbugs/issue19261.dir/q.go b/test/fixedbugs/issue19261.dir/q.go
new file mode 100644
index 00000000..9f3550ab
--- /dev/null
+++ b/test/fixedbugs/issue19261.dir/q.go
@@ -0,0 +1,17 @@
+// Copyright 2017 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 q
+
+import "./p"
+
+func H() {
+ p.F() // ERROR "inlining call to p.F"
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+}
diff --git a/test/fixedbugs/issue19261.go b/test/fixedbugs/issue19261.go
new file mode 100644
index 00000000..61cff6e1
--- /dev/null
+++ b/test/fixedbugs/issue19261.go
@@ -0,0 +1,7 @@
+// errorcheckdir -0 -m
+
+// Copyright 2017 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 ignored
diff --git a/test/fixedbugs/issue20250.go b/test/fixedbugs/issue20250.go
index f24710a0..525192a4 100644
--- a/test/fixedbugs/issue20250.go
+++ b/test/fixedbugs/issue20250.go
@@ -1,4 +1,4 @@
-// errorcheck -0 -live -d=compilelater
+// errorcheck -0 -live -l -d=compilelater,eagerwb
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
@@ -8,6 +8,10 @@
// due to propagation of addrtaken to outer variables for
// closure variables.
+// TODO(austin): This expects function calls to the write barrier, so
+// we enable the legacy eager write barrier. Fix this once the
+// buffered write barrier works on all arches.
+
package p
type T struct {
@@ -16,8 +20,8 @@ type T struct {
func f(a T) { // ERROR "live at entry to f: a"
var e interface{}
- func() { // ERROR "live at entry to f.func1: &e a"
- e = a.s // ERROR "live at call to convT2Estring: &e a" "live at call to writebarrierptr: a"
+ func() { // ERROR "live at entry to f.func1: a &e"
+ e = a.s // ERROR "live at call to convT2Estring: a &e" "live at call to writebarrierptr: a"
}() // ERROR "live at call to f.func1: e$"
// Before the fix, both a and e were live at the previous line.
_ = e
diff --git a/test/fixedbugs/issue20739.go b/test/fixedbugs/issue20739.go
new file mode 100644
index 00000000..b71a25dc
--- /dev/null
+++ b/test/fixedbugs/issue20739.go
@@ -0,0 +1,16 @@
+// compile
+
+// Copyright 2017 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
+
+func F() {
+ var x struct {
+ x *int
+ w [1e9][1e9][1e9][0]*int
+ y *int
+ }
+ println(&x)
+}
diff --git a/test/fixedbugs/issue20812.go b/test/fixedbugs/issue20812.go
new file mode 100644
index 00000000..0175eede
--- /dev/null
+++ b/test/fixedbugs/issue20812.go
@@ -0,0 +1,15 @@
+// errorcheck
+
+// Copyright 2017 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
+
+func f() {
+ _ = int("1") // ERROR "cannot convert"
+ _ = bool(0) // ERROR "cannot convert"
+ _ = bool("false") // ERROR "cannot convert"
+ _ = int(false) // ERROR "cannot convert"
+ _ = string(true) // ERROR "cannot convert"
+}
diff --git a/test/fixedbugs/issue21253.go b/test/fixedbugs/issue21253.go
new file mode 100644
index 00000000..3531b2b8
--- /dev/null
+++ b/test/fixedbugs/issue21253.go
@@ -0,0 +1,27 @@
+// compile
+
+// Copyright 2017 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.
+
+// Gccgo crashed compiling this code due to failing to finalize
+// interfaces in the right order.
+
+package p
+
+type s1 struct {
+ f m
+ I
+}
+
+type m interface {
+ Mm(*s2)
+}
+
+type s2 struct {
+ *s1
+}
+
+type I interface {
+ MI()
+}
diff --git a/test/fixedbugs/issue21256.go b/test/fixedbugs/issue21256.go
new file mode 100644
index 00000000..3d361247
--- /dev/null
+++ b/test/fixedbugs/issue21256.go
@@ -0,0 +1,9 @@
+// errorcheck
+
+// Copyright 2017 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
+
+var main = func() {} // ERROR "must be func"
diff --git a/test/fixedbugs/issue21273.go b/test/fixedbugs/issue21273.go
new file mode 100644
index 00000000..7a790d14
--- /dev/null
+++ b/test/fixedbugs/issue21273.go
@@ -0,0 +1,28 @@
+// errorcheck
+
+// Copyright 2017 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
+
+type T0 T0 // ERROR "invalid recursive type"
+type _ map[T0]int
+
+type T1 struct{ T1 } // ERROR "invalid recursive type"
+type _ map[T1]int
+
+func f() {
+ type T2 T2 // ERROR "invalid recursive type"
+ type _ map[T2]int
+}
+
+func g() {
+ type T3 struct{ T3 } // ERROR "invalid recursive type"
+ type _ map[T3]int
+}
+
+func h() {
+ type T4 struct{ m map[T4]int } // ERROR "invalid map key"
+ type _ map[T4]int // ERROR "invalid map key"
+}
diff --git a/test/fixedbugs/issue21317.go b/test/fixedbugs/issue21317.go
new file mode 100644
index 00000000..ae0e0b55
--- /dev/null
+++ b/test/fixedbugs/issue21317.go
@@ -0,0 +1,60 @@
+// run
+
+// Copyright 2017 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.
+
+// As of "Mon 6 Nov 2017", run.go doesn't yet have proper
+// column matching so instead match the output manually
+// by exec-ing
+
+package main
+
+import (
+ "fmt"
+ "io/ioutil"
+ "log"
+ "os"
+ "os/exec"
+ "runtime"
+ "strings"
+)
+
+func main() {
+ if runtime.Compiler != "gc" || runtime.GOOS == "nacl" {
+ return
+ }
+
+ f, err := ioutil.TempFile("", "issue21317.go")
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Fprintf(f, `
+package main
+
+import "fmt"
+
+func main() {
+ n, err := fmt.Println(1)
+}
+`)
+ f.Close()
+ defer os.RemoveAll(f.Name())
+
+ // compile and test output
+ cmd := exec.Command("go", "tool", "compile", f.Name())
+ out, err := cmd.CombinedOutput()
+ if err == nil {
+ log.Fatalf("expected cmd/compile to fail")
+ }
+ wantErrs := []string{
+ "7:9: n declared and not used",
+ "7:12: err declared and not used",
+ }
+ outStr := string(out)
+ for _, want := range wantErrs {
+ if !strings.Contains(outStr, want) {
+ log.Fatalf("failed to match %q\noutput: %q", want, outStr)
+ }
+ }
+}
diff --git a/test/fixedbugs/issue21655.go b/test/fixedbugs/issue21655.go
new file mode 100644
index 00000000..66d4e3a7
--- /dev/null
+++ b/test/fixedbugs/issue21655.go
@@ -0,0 +1,62 @@
+// compile
+
+// Copyright 2017 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.
+
+// Make sure assembly offsets don't get too large.
+
+// To trigger issue21655, the index offset needs to be small
+// enough to fit into an int32 (to get rewritten to an ADDQconst)
+// but large enough to overflow an int32 after multiplying by the stride.
+
+package main
+
+func f1(a []int64, i int64) int64 {
+ return a[i+1<<30]
+}
+func f2(a []int32, i int64) int32 {
+ return a[i+1<<30]
+}
+func f3(a []int16, i int64) int16 {
+ return a[i+1<<30]
+}
+func f4(a []int8, i int64) int8 {
+ return a[i+1<<31]
+}
+func f5(a []float64, i int64) float64 {
+ return a[i+1<<30]
+}
+func f6(a []float32, i int64) float32 {
+ return a[i+1<<30]
+}
+
+// Note: Before the fix for issue 21655, f{1,2,5,6} made
+// the compiler crash. f3 silently generated the wrong
+// code, using an offset of -1<<31 instead of 1<<31.
+// (This is due to the assembler accepting offsets
+// like 0x80000000 and silently using them as
+// signed 32 bit offsets.)
+// f4 was ok, but testing it can't hurt.
+
+func f7(ss []*string, i int) string {
+ const offset = 3 << 29 // 3<<29 * 4 = 3<<31 = 1<<31 mod 1<<32.
+ if i > offset {
+ return *ss[i-offset]
+ }
+ return ""
+}
+func f8(ss []*string, i int) string {
+ const offset = 3<<29 + 10
+ if i > offset {
+ return *ss[i-offset]
+ }
+ return ""
+}
+func f9(ss []*string, i int) string {
+ const offset = 3<<29 - 10
+ if i > offset {
+ return *ss[i-offset]
+ }
+ return ""
+}
diff --git a/test/fixedbugs/issue21687.go b/test/fixedbugs/issue21687.go
new file mode 100644
index 00000000..9b4c03fe
--- /dev/null
+++ b/test/fixedbugs/issue21687.go
@@ -0,0 +1,68 @@
+// run
+
+// Copyright 2017 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 21687: cmd/compile evaluates x twice in "x op= y", which was
+// detectable if evaluating y affects x.
+
+package main
+
+func ptrs() (int, int) {
+ one := 1
+ two := 2
+
+ x := &one
+ *x += func() int {
+ x = &two
+ return 0
+ }()
+
+ return one, two
+}
+
+func slices() (int, int) {
+ one := []int{1}
+ two := []int{2}
+
+ x := one
+ x[0] += func() int {
+ x = two
+ return 0
+ }()
+
+ return one[0], two[0]
+}
+
+func maps() (int, int) {
+ one := map[int]int{0: 1}
+ two := map[int]int{0: 2}
+
+ x := one
+ x[0] += func() int {
+ x = two
+ return 0
+ }()
+
+ return one[0], two[0]
+}
+
+var tests = [...]func() (int, int){
+ ptrs,
+ slices,
+ maps,
+}
+
+func main() {
+ bad := 0
+ for i, f := range tests {
+ if a, b := f(); a+b != 3 {
+ println(i, a, b)
+ bad++
+ }
+ }
+ if bad != 0 {
+ panic(bad)
+ }
+}
diff --git a/test/fixedbugs/issue21709.go b/test/fixedbugs/issue21709.go
new file mode 100644
index 00000000..bf5d9d23
--- /dev/null
+++ b/test/fixedbugs/issue21709.go
@@ -0,0 +1,37 @@
+// errorcheck -0 -l -m
+
+// Copyright 2017 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 21709: range expression overly escapes.
+
+package p
+
+type S struct{}
+
+func (s *S) Inc() {} // ERROR "\(\*S\).Inc s does not escape"
+var N int
+
+func F1() {
+ var s S // ERROR "moved to heap: s"
+ for i := 0; i < N; i++ {
+ fs := []func(){ // ERROR "F1 \[\]func\(\) literal does not escape"
+ s.Inc, // ERROR "F1 s.Inc does not escape" "s escapes to heap"
+ }
+ for _, f := range fs {
+ f()
+ }
+ }
+}
+
+func F2() {
+ var s S // ERROR "moved to heap: s"
+ for i := 0; i < N; i++ {
+ for _, f := range []func(){ // ERROR "F2 \[\]func\(\) literal does not escape"
+ s.Inc, // ERROR "F2 s.Inc does not escape" "s escapes to heap"
+ } {
+ f()
+ }
+ }
+}
diff --git a/test/fixedbugs/issue21770.go b/test/fixedbugs/issue21770.go
new file mode 100644
index 00000000..2f07d640
--- /dev/null
+++ b/test/fixedbugs/issue21770.go
@@ -0,0 +1,20 @@
+// errorcheck
+
+// Copyright 2017 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 21770: gccgo incorrectly accepts "p.f = 0" where p is **struct
+
+package p
+
+type PP **struct{ f int }
+
+func f() {
+ // anonymous type
+ var p **struct{ f int }
+ p.f = 0 // ERROR "field"
+ // named type
+ var p2 PP
+ p2.f = 0 // ERROR "field"
+}
diff --git a/test/fixedbugs/issue21808.go b/test/fixedbugs/issue21808.go
new file mode 100644
index 00000000..d146200e
--- /dev/null
+++ b/test/fixedbugs/issue21808.go
@@ -0,0 +1,17 @@
+// run
+
+// Copyright 2017 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.
+
+// Make sure println() prints a blank line.
+
+package main
+
+import "fmt"
+
+func main() {
+ fmt.Println("A")
+ println()
+ fmt.Println("B")
+}
diff --git a/test/fixedbugs/issue21808.out b/test/fixedbugs/issue21808.out
new file mode 100644
index 00000000..655da036
--- /dev/null
+++ b/test/fixedbugs/issue21808.out
@@ -0,0 +1,3 @@
+A
+
+B
diff --git a/test/fixedbugs/issue21879.go b/test/fixedbugs/issue21879.go
new file mode 100644
index 00000000..1029ca04
--- /dev/null
+++ b/test/fixedbugs/issue21879.go
@@ -0,0 +1,37 @@
+// run
+
+// Copyright 2017 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 (
+ "runtime"
+)
+
+func main() {
+ println(caller().frame.Function)
+
+ // Used to erroneously print "main.call.name" instead of
+ // "main.main".
+ println(caller().name())
+}
+
+func caller() call {
+ var pcs [3]uintptr
+ n := runtime.Callers(1, pcs[:])
+ frames := runtime.CallersFrames(pcs[:n])
+ frame, _ := frames.Next()
+ frame, _ = frames.Next()
+
+ return call{frame: frame}
+}
+
+type call struct {
+ frame runtime.Frame
+}
+
+func (c call) name() string {
+ return c.frame.Function
+}
diff --git a/test/fixedbugs/issue21879.out b/test/fixedbugs/issue21879.out
new file mode 100644
index 00000000..066f1a83
--- /dev/null
+++ b/test/fixedbugs/issue21879.out
@@ -0,0 +1,2 @@
+main.main
+main.main
diff --git a/test/fixedbugs/issue21882.go b/test/fixedbugs/issue21882.go
new file mode 100644
index 00000000..f77e0469
--- /dev/null
+++ b/test/fixedbugs/issue21882.go
@@ -0,0 +1,9 @@
+// errorcheck
+
+// Copyright 2017 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
+
+type T [2]T // ERROR "invalid recursive type"
diff --git a/test/fixedbugs/issue21887.go b/test/fixedbugs/issue21887.go
new file mode 100644
index 00000000..9e3e91fc
--- /dev/null
+++ b/test/fixedbugs/issue21887.go
@@ -0,0 +1,25 @@
+// cmpout
+
+// Copyright 2017 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 21887: println(^uint(0)) fails to compile
+
+package main
+
+import "strconv"
+
+func main() {
+ if strconv.IntSize == 32 {
+ println(^uint(0))
+ } else {
+ println(^uint32(0))
+ }
+
+ if strconv.IntSize == 64 {
+ println(^uint(0))
+ } else {
+ println(^uint64(0))
+ }
+}
diff --git a/test/fixedbugs/issue21887.out b/test/fixedbugs/issue21887.out
new file mode 100644
index 00000000..664b67d7
--- /dev/null
+++ b/test/fixedbugs/issue21887.out
@@ -0,0 +1,2 @@
+4294967295
+18446744073709551615
diff --git a/test/fixedbugs/issue21963.go b/test/fixedbugs/issue21963.go
new file mode 100644
index 00000000..996bd63d
--- /dev/null
+++ b/test/fixedbugs/issue21963.go
@@ -0,0 +1,27 @@
+// run
+
+// Copyright 2017 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 (
+ "fmt"
+ "runtime"
+)
+
+//go:noinline
+func f(x []int32, y *int8) int32 {
+ c := int32(int16(*y))
+ runtime.GC()
+ return x[0] * c
+}
+
+func main() {
+ var x = [1]int32{5}
+ var y int8 = -1
+ if got, want := f(x[:], &y), int32(-5); got != want {
+ panic(fmt.Sprintf("wanted %d, got %d", want, got))
+ }
+}
diff --git a/test/fixedbugs/issue21988.go b/test/fixedbugs/issue21988.go
new file mode 100644
index 00000000..850e0398
--- /dev/null
+++ b/test/fixedbugs/issue21988.go
@@ -0,0 +1,17 @@
+// errorcheck
+
+// Copyright 2017 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 21988: panic on switch case with invalid value
+
+package p
+
+const X = Wrong(0) // ERROR "undefined: Wrong"
+
+func _() {
+ switch 0 {
+ case X:
+ }
+}
diff --git a/test/fixedbugs/issue22063.go b/test/fixedbugs/issue22063.go
new file mode 100644
index 00000000..bfdb2e00
--- /dev/null
+++ b/test/fixedbugs/issue22063.go
@@ -0,0 +1,17 @@
+// errorcheck
+
+// Copyright 2017 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 22063: panic on interface switch case with invalid name
+
+package p
+
+const X = Wrong(0) // ERROR "undefined: Wrong"
+
+func _() {
+ switch interface{}(nil) {
+ case X:
+ }
+}
diff --git a/test/fixedbugs/issue22076.go b/test/fixedbugs/issue22076.go
new file mode 100644
index 00000000..5d628b96
--- /dev/null
+++ b/test/fixedbugs/issue22076.go
@@ -0,0 +1,25 @@
+// compile
+
+// Copyright 2017 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 22076: Couldn't use ":=" to declare names that refer to
+// dot-imported symbols.
+
+package p
+
+import . "bytes"
+
+var _ Reader // use "bytes" import
+
+func _() {
+ Buffer := 0
+ _ = Buffer
+}
+
+func _() {
+ for Buffer := range []int{} {
+ _ = Buffer
+ }
+}
diff --git a/test/fixedbugs/issue22083.go b/test/fixedbugs/issue22083.go
new file mode 100644
index 00000000..a385102d
--- /dev/null
+++ b/test/fixedbugs/issue22083.go
@@ -0,0 +1,41 @@
+// run
+
+// Copyright 2017 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.
+
+// The compiler was panicking on the wrong line number, where
+// the panic was occurring in an inlined call.
+
+package main
+
+import (
+ "runtime/debug"
+ "strings"
+)
+
+type Wrapper struct {
+ a []int
+}
+
+func (w Wrapper) Get(i int) int {
+ return w.a[i]
+}
+
+func main() {
+ defer func() {
+ e := recover()
+ if e == nil {
+ panic("bounds check didn't fail")
+ }
+ stk := string(debug.Stack())
+ if !strings.Contains(stk, "issue22083.go:40") {
+ panic("wrong stack trace: " + stk)
+ }
+ }()
+ foo := Wrapper{a: []int{0, 1, 2}}
+ _ = foo.Get(0)
+ _ = foo.Get(1)
+ _ = foo.Get(2)
+ _ = foo.Get(3) // stack trace should mention this line
+}
diff --git a/test/fixedbugs/issue22164.go b/test/fixedbugs/issue22164.go
new file mode 100644
index 00000000..fad78e23
--- /dev/null
+++ b/test/fixedbugs/issue22164.go
@@ -0,0 +1,26 @@
+// errorcheck
+
+// Copyright 2017 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.
+
+// Test error recovery after missing closing parentheses in lists.
+
+package p
+
+func f() {
+ x := f(g() // ERROR "unexpected newline"
+ y := 1
+}
+
+func g() {
+}
+
+func h() {
+ x := f(g() // ERROR "unexpected newline"
+}
+
+func i() {
+ x := []int{1, 2, 3 // ERROR "unexpected newline"
+ y := 0
+} \ No newline at end of file
diff --git a/test/fixedbugs/issue22198.go b/test/fixedbugs/issue22198.go
new file mode 100644
index 00000000..c874c1ca
--- /dev/null
+++ b/test/fixedbugs/issue22198.go
@@ -0,0 +1,18 @@
+// compile
+
+// Copyright 2017 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 issue22198
+
+func f(a *bool, b bool) {
+ if b {
+ return
+ }
+ c := '\n'
+ if b {
+ c = ' '
+ }
+ *a = c == '\n'
+}
diff --git a/test/fixedbugs/issue22200.go b/test/fixedbugs/issue22200.go
new file mode 100644
index 00000000..66b9538e
--- /dev/null
+++ b/test/fixedbugs/issue22200.go
@@ -0,0 +1,20 @@
+// errorcheck
+
+// Copyright 2017 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
+
+func f1(x *[1<<30 - 1e6]byte) byte {
+ for _, b := range *x {
+ return b
+ }
+ return 0
+}
+func f2(x *[1<<30 + 1e6]byte) byte { // ERROR "stack frame too large"
+ for _, b := range *x {
+ return b
+ }
+ return 0
+}
diff --git a/test/fixedbugs/issue22200b.go b/test/fixedbugs/issue22200b.go
new file mode 100644
index 00000000..8d4515eb
--- /dev/null
+++ b/test/fixedbugs/issue22200b.go
@@ -0,0 +1,28 @@
+// errorcheck
+
+// Copyright 2017 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.
+
+// +build !386,!amd64p32,!arm,!mips,!mipsle
+
+package p
+
+func f3(x *[1 << 31]byte) byte { // ERROR "stack frame too large"
+ for _, b := range *x {
+ return b
+ }
+ return 0
+}
+func f4(x *[1 << 32]byte) byte { // ERROR "stack frame too large"
+ for _, b := range *x {
+ return b
+ }
+ return 0
+}
+func f5(x *[1 << 33]byte) byte { // ERROR "stack frame too large"
+ for _, b := range *x {
+ return b
+ }
+ return 0
+}
diff --git a/test/fixedbugs/issue22351.go b/test/fixedbugs/issue22351.go
new file mode 100644
index 00000000..e46a0fb2
--- /dev/null
+++ b/test/fixedbugs/issue22351.go
@@ -0,0 +1,11 @@
+// errorcheck
+
+// Copyright 2017 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 "unsafe"
+
+const _ = uint64(unsafe.Offsetof(T{}.F)) // ERROR "undefined"
diff --git a/test/fixedbugs/issue22389.go b/test/fixedbugs/issue22389.go
new file mode 100644
index 00000000..706b4494
--- /dev/null
+++ b/test/fixedbugs/issue22389.go
@@ -0,0 +1,18 @@
+// errorcheck
+
+// Copyright 2017 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
+
+type Foo struct{}
+
+func (f *Foo) Call(cb func(*Foo)) {
+ cb(f)
+}
+
+func main() {
+ f := &Foo{}
+ f.Call(func(f) {}) // ERROR "f is not a type"
+}
diff --git a/test/fixedbugs/issue22429.go b/test/fixedbugs/issue22429.go
new file mode 100644
index 00000000..289b434a
--- /dev/null
+++ b/test/fixedbugs/issue22429.go
@@ -0,0 +1,18 @@
+// compile
+
+// Copyright 2017 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.
+
+// Make sure SSA->assembly pass can handle SP as an index register.
+
+package p
+
+type T struct {
+ a,b,c,d float32
+}
+
+func f(a *[8]T, i,j,k int) float32 {
+ b := *a
+ return b[i].a + b[j].b + b[k].c
+}
diff --git a/test/fixedbugs/issue22458.go b/test/fixedbugs/issue22458.go
new file mode 100644
index 00000000..5c899295
--- /dev/null
+++ b/test/fixedbugs/issue22458.go
@@ -0,0 +1,26 @@
+// compile
+
+// Copyright 2017 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.
+
+// Make sure KeepAlive introduces a use of the spilled variable.
+
+package main
+
+import "runtime"
+
+type node struct {
+ next *node
+}
+
+var x bool
+
+func main() {
+ var head *node
+ for x {
+ head = &node{head}
+ }
+
+ runtime.KeepAlive(head)
+}
diff --git a/test/fixedbugs/issue22581.go b/test/fixedbugs/issue22581.go
new file mode 100644
index 00000000..2b637f2e
--- /dev/null
+++ b/test/fixedbugs/issue22581.go
@@ -0,0 +1,27 @@
+// errorcheck
+
+// Copyright 2017 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
+
+func f() {
+ if i := g()); i == j { // ERROR "unexpected \)"
+ }
+
+ if i == g()] { // ERROR "unexpected \]"
+ }
+
+ switch i := g()); i { // ERROR "unexpected \)"
+ }
+
+ switch g()] { // ERROR "unexpected \]"
+ }
+
+ for i := g()); i < y; { // ERROR "unexpected \)"
+ }
+
+ for g()] { // ERROR "unexpected \]"
+ }
+}
diff --git a/test/fixedbugs/issue22605.go b/test/fixedbugs/issue22605.go
new file mode 100644
index 00000000..9e726f35
--- /dev/null
+++ b/test/fixedbugs/issue22605.go
@@ -0,0 +1,26 @@
+// run
+
+// Copyright 2017 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.
+
+// We were picking up a special noalg type from typelinks.
+
+package main
+
+import "reflect"
+
+func f(m map[string]int) int {
+ return m["a"]
+}
+
+func g(m map[[8]string]int) int {
+ t := reflect.ArrayOf(8, reflect.TypeOf(""))
+ a := reflect.New(t).Elem()
+ return m[a.Interface().([8]string)]
+}
+
+func main() {
+ m := map[[8]string]int{}
+ g(m)
+}
diff --git a/test/fixedbugs/issue22660.go b/test/fixedbugs/issue22660.go
new file mode 100644
index 00000000..48686fef
--- /dev/null
+++ b/test/fixedbugs/issue22660.go
@@ -0,0 +1,50 @@
+// run
+
+// Copyright 2017 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 (
+ "bytes"
+ "fmt"
+ "io/ioutil"
+ "log"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "strings"
+)
+
+func main() {
+ if runtime.GOOS == "nacl" {
+ return // no file system available on builders
+ }
+
+ f, err := ioutil.TempFile("", "issue22660.go")
+ if err != nil {
+ log.Fatal(err)
+ }
+ f.Close()
+ defer os.Remove(f.Name())
+
+ // path must appear in error messages even if we strip them with -trimpath
+ path := filepath.Join("users", "xxx", "go")
+ var src bytes.Buffer
+ fmt.Fprintf(&src, "//line %s:1\n", filepath.Join(path, "foo.go"))
+
+ if err := ioutil.WriteFile(f.Name(), src.Bytes(), 0660); err != nil {
+ log.Fatal(err)
+ }
+
+ out, err := exec.Command("go", "tool", "compile", fmt.Sprintf("-trimpath=%s", path), f.Name()).CombinedOutput()
+ if err == nil {
+ log.Fatalf("expected compiling %s to fail", f.Name())
+ }
+
+ if !strings.HasPrefix(string(out), path) {
+ log.Fatalf("expected full path (%s) in error message, got:\n%s", path, out)
+ }
+}
diff --git a/test/fixedbugs/issue22683.go b/test/fixedbugs/issue22683.go
new file mode 100644
index 00000000..a59a0eda
--- /dev/null
+++ b/test/fixedbugs/issue22683.go
@@ -0,0 +1,30 @@
+// cmpout
+
+// Copyright 2017 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 (
+ "fmt"
+)
+
+type foo struct {
+ bar [1]*int
+}
+
+func main() {
+ ch := make(chan foo, 2)
+ var a int
+ var b [1]*int
+ b[0] = &a
+ ch <- foo{bar: b}
+ close(ch)
+
+ for v := range ch {
+ for i := 0; i < 1; i++ {
+ fmt.Println(v.bar[0] != nil)
+ }
+ }
+}
diff --git a/test/fixedbugs/issue22683.out b/test/fixedbugs/issue22683.out
new file mode 100644
index 00000000..27ba77dd
--- /dev/null
+++ b/test/fixedbugs/issue22683.out
@@ -0,0 +1 @@
+true
diff --git a/test/fixedbugs/issue22781.go b/test/fixedbugs/issue22781.go
new file mode 100644
index 00000000..5ad82398
--- /dev/null
+++ b/test/fixedbugs/issue22781.go
@@ -0,0 +1,29 @@
+// run
+
+// Copyright 2017 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 "runtime/debug"
+
+type T struct {
+ // >= 16 bytes to avoid tiny alloc.
+ a, b int
+}
+
+func main() {
+ debug.SetGCPercent(1)
+ for i := 0; i < 100000; i++ {
+ m := make(map[*T]struct{}, 0)
+ for j := 0; j < 20; j++ {
+ // During the call to mapassign_fast64, the key argument
+ // was incorrectly treated as a uint64. If the stack was
+ // scanned during that call, the only pointer to k was
+ // missed, leading to *k being collected prematurely.
+ k := new(T)
+ m[k] = struct{}{}
+ }
+ }
+}
diff --git a/test/fixedbugs/issue22794.go b/test/fixedbugs/issue22794.go
new file mode 100644
index 00000000..c7e9eb12
--- /dev/null
+++ b/test/fixedbugs/issue22794.go
@@ -0,0 +1,20 @@
+// errorcheck
+
+// Copyright 2017 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
+
+type it struct {
+ Floats bool
+ inner string
+}
+
+func main() {
+ i1 := it{Floats: true}
+ if i1.floats { // ERROR "(type it .* field or method floats, but does have Floats)"
+ }
+ i2 := &it{floats: false} // ERROR "(but does have Floats)"
+ _ = &it{InneR: "foo"} // ERROR "(but does have inner)"
+}
diff --git a/test/fixedbugs/issue22877.dir/p.go b/test/fixedbugs/issue22877.dir/p.go
new file mode 100644
index 00000000..fc86cb9e
--- /dev/null
+++ b/test/fixedbugs/issue22877.dir/p.go
@@ -0,0 +1,14 @@
+// Copyright 2017 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
+
+type S struct{ i int }
+type SS = S
+
+func sub()
+
+func main() {
+ sub()
+}
diff --git a/test/fixedbugs/issue22877.dir/p.s b/test/fixedbugs/issue22877.dir/p.s
new file mode 100644
index 00000000..8b14358c
--- /dev/null
+++ b/test/fixedbugs/issue22877.dir/p.s
@@ -0,0 +1,8 @@
+// Copyright 2017 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.
+
+#include "go_asm.h"
+
+TEXT ·sub(SB), 0, $0
+ RET
diff --git a/test/fixedbugs/issue22877.go b/test/fixedbugs/issue22877.go
new file mode 100644
index 00000000..284b6807
--- /dev/null
+++ b/test/fixedbugs/issue22877.go
@@ -0,0 +1,7 @@
+// builddir
+
+// Copyright 2017 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 ignored
diff --git a/test/fixedbugs/issue22881.go b/test/fixedbugs/issue22881.go
new file mode 100644
index 00000000..61e99a28
--- /dev/null
+++ b/test/fixedbugs/issue22881.go
@@ -0,0 +1,72 @@
+// run
+
+// Copyright 2017 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.
+
+// Test to make sure RHS is evaluated before map insert is started.
+// The RHS panics in all of these cases.
+
+package main
+
+import "fmt"
+
+func main() {
+ for i, f := range []func(map[int]int){
+ f0, f1, f2, f3, f4, f5, f6, f7,
+ } {
+ m := map[int]int{}
+ func() { // wrapper to scope the defer.
+ defer func() {
+ recover()
+ }()
+ f(m) // Will panic. Shouldn't modify m.
+ fmt.Printf("RHS didn't panic, case f%d\n", i)
+ }()
+ if len(m) != 0 {
+ fmt.Printf("map insert happened, case f%d\n", i)
+ }
+ }
+}
+
+func f0(m map[int]int) {
+ var p *int
+ m[0] = *p
+}
+
+func f1(m map[int]int) {
+ var p *int
+ m[0] += *p
+}
+
+func f2(m map[int]int) {
+ var p *int
+ sink, m[0] = sink, *p
+}
+
+func f3(m map[int]int) {
+ var p *chan int
+ m[0], sink = <-(*p)
+}
+
+func f4(m map[int]int) {
+ var p *interface{}
+ m[0], sink = (*p).(int)
+}
+
+func f5(m map[int]int) {
+ var p *map[int]int
+ m[0], sink = (*p)[0]
+}
+
+func f6(m map[int]int) {
+ var z int
+ m[0] /= z
+}
+
+func f7(m map[int]int) {
+ var a []int
+ m[0] = a[0]
+}
+
+var sink bool
diff --git a/test/fixedbugs/issue22904.go b/test/fixedbugs/issue22904.go
new file mode 100644
index 00000000..46cb7c04
--- /dev/null
+++ b/test/fixedbugs/issue22904.go
@@ -0,0 +1,19 @@
+// errorcheck
+
+// Copyright 2017 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 22904: Make sure the compiler emits a proper error message about
+// invalid recursive types rather than crashing.
+
+package p
+
+type a struct{ b }
+type b struct{ a } // ERROR "invalid recursive type"
+
+var x interface{}
+
+func f() {
+ x = a{}
+}
diff --git a/test/fixedbugs/issue22941.dir/a.go b/test/fixedbugs/issue22941.dir/a.go
new file mode 100644
index 00000000..7a4ede43
--- /dev/null
+++ b/test/fixedbugs/issue22941.dir/a.go
@@ -0,0 +1,7 @@
+// Copyright 2017 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 q
+
+type P int
diff --git a/test/fixedbugs/issue22941.dir/b.go b/test/fixedbugs/issue22941.dir/b.go
new file mode 100644
index 00000000..87d59a67
--- /dev/null
+++ b/test/fixedbugs/issue22941.dir/b.go
@@ -0,0 +1,30 @@
+// Copyright 2017 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 q "./a"
+
+type T struct {
+ X *q.P
+}
+
+func F(in, out *T) {
+ *out = *in
+ if in.X != nil {
+ in, out := &in.X, &out.X
+ if *in == nil {
+ *out = nil
+ } else {
+ *out = new(q.P)
+ **out = **in
+ }
+ }
+ return
+}
+
+//go:noinline
+func G(x, y *T) {
+ F(x, y)
+}
diff --git a/test/fixedbugs/issue22941.dir/main.go b/test/fixedbugs/issue22941.dir/main.go
new file mode 100644
index 00000000..84666adf
--- /dev/null
+++ b/test/fixedbugs/issue22941.dir/main.go
@@ -0,0 +1,15 @@
+// Copyright 2017 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 p "./b"
+
+var G int
+
+func main() {
+ if G == 101 {
+ p.G(nil, nil)
+ }
+}
diff --git a/test/fixedbugs/issue22941.go b/test/fixedbugs/issue22941.go
new file mode 100644
index 00000000..c3732c31
--- /dev/null
+++ b/test/fixedbugs/issue22941.go
@@ -0,0 +1,7 @@
+// rundir
+
+// Copyright 2017 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 ignored
diff --git a/test/fixedbugs/issue22962.dir/a.go b/test/fixedbugs/issue22962.dir/a.go
new file mode 100644
index 00000000..7257d7df
--- /dev/null
+++ b/test/fixedbugs/issue22962.dir/a.go
@@ -0,0 +1,11 @@
+// Copyright 2017 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
+
+func F() {
+ if x := 0; false {
+ _ = x
+ }
+}
diff --git a/test/fixedbugs/issue22962.dir/b.go b/test/fixedbugs/issue22962.dir/b.go
new file mode 100644
index 00000000..e1568c8f
--- /dev/null
+++ b/test/fixedbugs/issue22962.dir/b.go
@@ -0,0 +1,9 @@
+// Copyright 2017 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 b
+
+import "a"
+
+var V = func() { a.F() }
diff --git a/test/fixedbugs/issue22962.go b/test/fixedbugs/issue22962.go
new file mode 100644
index 00000000..8000a522
--- /dev/null
+++ b/test/fixedbugs/issue22962.go
@@ -0,0 +1,7 @@
+// compiledir
+
+// Copyright 2017 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 ignored
diff --git a/test/fixedbugs/issue23093.go b/test/fixedbugs/issue23093.go
new file mode 100644
index 00000000..2fd7d5ff
--- /dev/null
+++ b/test/fixedbugs/issue23093.go
@@ -0,0 +1,9 @@
+// errorcheck
+
+// Copyright 2017 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
+
+var f = func() { f() } // ERROR "initialization loop"
diff --git a/test/fixedbugs/issue23179.dir/a.go b/test/fixedbugs/issue23179.dir/a.go
new file mode 100644
index 00000000..3d2816fc
--- /dev/null
+++ b/test/fixedbugs/issue23179.dir/a.go
@@ -0,0 +1,13 @@
+// Copyright 2017 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 Large struct {
+ x [256]int
+}
+
+func F(x int, _ int, _ bool, _ Large) int {
+ return x
+}
diff --git a/test/fixedbugs/issue23179.dir/b.go b/test/fixedbugs/issue23179.dir/b.go
new file mode 100644
index 00000000..bec3d15e
--- /dev/null
+++ b/test/fixedbugs/issue23179.dir/b.go
@@ -0,0 +1,11 @@
+// Copyright 2017 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 b
+
+import "a"
+
+func G(x int) int {
+ return a.F(x, 1, false, a.Large{})
+}
diff --git a/test/fixedbugs/issue23179.go b/test/fixedbugs/issue23179.go
new file mode 100644
index 00000000..8000a522
--- /dev/null
+++ b/test/fixedbugs/issue23179.go
@@ -0,0 +1,7 @@
+// compiledir
+
+// Copyright 2017 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 ignored
diff --git a/test/fixedbugs/issue23305.go b/test/fixedbugs/issue23305.go
new file mode 100644
index 00000000..28f400c5
--- /dev/null
+++ b/test/fixedbugs/issue23305.go
@@ -0,0 +1,28 @@
+// run
+
+// Copyright 2018 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
+
+func mask1(a, b uint64) uint64 {
+ op1 := int32(a)
+ op2 := int32(b)
+ return uint64(uint32(op1 / op2))
+}
+
+var mask2 = mask1
+
+func main() {
+ res1 := mask1(0x1, 0xfffffffeffffffff)
+ res2 := mask2(0x1, 0xfffffffeffffffff)
+ if res1 != 0xffffffff {
+ println("got", res1, "want", 0xffffffff)
+ panic("FAIL")
+ }
+ if res2 != 0xffffffff {
+ println("got", res2, "want", 0xffffffff)
+ panic("FAIL")
+ }
+}
diff --git a/test/fixedbugs/issue23522.go b/test/fixedbugs/issue23522.go
new file mode 100644
index 00000000..cace86c8
--- /dev/null
+++ b/test/fixedbugs/issue23522.go
@@ -0,0 +1,46 @@
+// run
+
+// Copyright 2018 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 (
+ "math"
+)
+
+type S struct {
+ u int64
+ n int32
+}
+
+func F1(f float64) *S {
+ s := f
+ pf := math.Copysign(f, 1)
+ u := math.Floor(pf)
+ return &S{
+ u: int64(math.Copysign(u, s)),
+ n: int32(math.Copysign((pf-u)*1e9, s)),
+ }
+}
+
+func F2(f float64) *S {
+ s := f
+ f = math.Copysign(f, 1)
+ u := math.Floor(f)
+ return &S{
+ u: int64(math.Copysign(u, s)),
+ n: int32(math.Copysign((f-u)*1e9, s)),
+ }
+}
+
+func main() {
+ s1 := F1(-1)
+ s2 := F2(-1)
+ if *s1 != *s2 {
+ println("F1:", s1.u, s1.n)
+ println("F2:", s2.u, s2.n)
+ panic("different")
+ }
+}
diff --git a/test/fixedbugs/issue23545.go b/test/fixedbugs/issue23545.go
new file mode 100644
index 00000000..24485c11
--- /dev/null
+++ b/test/fixedbugs/issue23545.go
@@ -0,0 +1,35 @@
+// run
+
+// Copyright 2018 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.
+
+// +build gccgo
+
+// Issue 23545: gccgo didn't lower array comparison to
+// proper equality function in some case.
+// TODO: build only on gccgo for now, as it hits issue
+// #23546.
+
+package main
+
+func main() {
+ if a := Get(); a != dummyID(1234) {
+ panic("FAIL")
+ }
+}
+
+func dummyID(x int) [Size]interface{} {
+ var out [Size]interface{}
+ out[0] = x
+ return out
+}
+
+const Size = 32
+
+type OutputID [Size]interface{}
+
+//go:noinline
+func Get() OutputID {
+ return dummyID(1234)
+}
diff --git a/test/fixedbugs/issue23719.go b/test/fixedbugs/issue23719.go
new file mode 100644
index 00000000..c97e6363
--- /dev/null
+++ b/test/fixedbugs/issue23719.go
@@ -0,0 +1,42 @@
+// run
+
+// Copyright 2018 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
+
+func main() {
+ v1 := [2]int32{-1, 88}
+ v2 := [2]int32{-1, 99}
+ if v1 == v2 {
+ panic("bad comparison")
+ }
+
+ w1 := [2]int16{-1, 88}
+ w2 := [2]int16{-1, 99}
+ if w1 == w2 {
+ panic("bad comparison")
+ }
+ x1 := [4]int16{-1, 88, 88, 88}
+ x2 := [4]int16{-1, 99, 99, 99}
+ if x1 == x2 {
+ panic("bad comparison")
+ }
+
+ a1 := [2]int8{-1, 88}
+ a2 := [2]int8{-1, 99}
+ if a1 == a2 {
+ panic("bad comparison")
+ }
+ b1 := [4]int8{-1, 88, 88, 88}
+ b2 := [4]int8{-1, 99, 99, 99}
+ if b1 == b2 {
+ panic("bad comparison")
+ }
+ c1 := [8]int8{-1, 88, 88, 88, 88, 88, 88, 88}
+ c2 := [8]int8{-1, 99, 99, 99, 99, 99, 99, 99}
+ if c1 == c2 {
+ panic("bad comparison")
+ }
+}
diff --git a/test/fixedbugs/issue23812.go b/test/fixedbugs/issue23812.go
new file mode 100644
index 00000000..0a40deb2
--- /dev/null
+++ b/test/fixedbugs/issue23812.go
@@ -0,0 +1,34 @@
+// run
+
+// Copyright 2018 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 "fmt"
+
+func main() {
+ want := int32(0x3edae8)
+ got := foo(1)
+ if want != got {
+ panic(fmt.Sprintf("want %x, got %x", want, got))
+ }
+}
+
+func foo(a int32) int32 {
+ return shr1(int32(shr2(int64(0x14ff6e2207db5d1f), int(a))), 4)
+}
+
+func shr1(n int32, m int) int32 { return n >> uint(m) }
+
+func shr2(n int64, m int) int64 {
+ if m < 0 {
+ m = -m
+ }
+ if m >= 64 {
+ return n
+ }
+
+ return n >> uint(m)
+}
diff --git a/test/fixedbugs/issue4388.go b/test/fixedbugs/issue4388.go
deleted file mode 100644
index 5bb05eb4..00000000
--- a/test/fixedbugs/issue4388.go
+++ /dev/null
@@ -1,56 +0,0 @@
-// run
-
-// Copyright 2014 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 (
- "fmt"
- "io"
- "runtime"
-)
-
-type T struct {
- io.Closer
-}
-
-func f1() {
- // The 5 here and below depends on the number of internal runtime frames
- // that sit between a deferred function called during panic and
- // the original frame. If that changes, this test will start failing and
- // the number here will need to be updated.
- defer checkLine(5)
- var t *T
- var c io.Closer = t
- c.Close()
-}
-
-func f2() {
- defer checkLine(5)
- var t T
- var c io.Closer = t
- c.Close()
-}
-
-func main() {
- f1()
- f2()
-}
-
-func checkLine(n int) {
- if err := recover(); err == nil {
- panic("did not panic")
- }
- var file string
- var line int
- for i := 1; i <= n; i++ {
- _, file, line, _ = runtime.Caller(i)
- if file != "<autogenerated>" || line != 1 {
- continue
- }
- return
- }
- panic(fmt.Sprintf("expected <autogenerated>:1 have %s:%d", file, line))
-}
diff --git a/test/fixedbugs/issue7525.go b/test/fixedbugs/issue7525.go
index 6e695931..fcfab723 100644
--- a/test/fixedbugs/issue7525.go
+++ b/test/fixedbugs/issue7525.go
@@ -11,7 +11,5 @@ package main
import "unsafe"
var x struct {
- a [unsafe.Sizeof(x.a)]int // ERROR "array bound|typechecking loop|invalid expression"
- b [unsafe.Offsetof(x.b)]int // ERROR "array bound"
- c [unsafe.Alignof(x.c)]int // ERROR "array bound|invalid expression"
+ a [unsafe.Sizeof(x.a)]int // ERROR "array bound|typechecking loop|invalid expression"
}
diff --git a/test/fixedbugs/issue7525d.go b/test/fixedbugs/issue7525d.go
new file mode 100644
index 00000000..141d6752
--- /dev/null
+++ b/test/fixedbugs/issue7525d.go
@@ -0,0 +1,15 @@
+// errorcheck
+
+// Copyright 2017 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 7525: self-referential array types.
+
+package main
+
+import "unsafe"
+
+var x struct {
+ b [unsafe.Offsetof(x.b)]int // ERROR "array bound|typechecking loop|invalid array"
+}
diff --git a/test/fixedbugs/issue7525e.go b/test/fixedbugs/issue7525e.go
new file mode 100644
index 00000000..c13194ca
--- /dev/null
+++ b/test/fixedbugs/issue7525e.go
@@ -0,0 +1,15 @@
+// errorcheck
+
+// Copyright 2017 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 7525: self-referential array types.
+
+package main
+
+import "unsafe"
+
+var x struct {
+ c [unsafe.Alignof(x.c)]int // ERROR "array bound|typechecking loop|invalid array"
+}