mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
Semi-regular merge from tip into dev.ssa. Change-Id: I1627d7c7e6892cd4f1f5da5f3e07389ff1d677ce
This commit is contained in:
commit
b386c34ef9
700 changed files with 23857 additions and 22716 deletions
18
test/fixedbugs/bug13343.go
Normal file
18
test/fixedbugs/bug13343.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2015 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 (
|
||||
a, b = f() // ERROR "initialization loop|depends upon itself"
|
||||
c = b
|
||||
)
|
||||
|
||||
func f() (int, int) {
|
||||
return c, c
|
||||
}
|
||||
|
||||
func main() {}
|
||||
29
test/fixedbugs/bug496.go
Normal file
29
test/fixedbugs/bug496.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// compile
|
||||
|
||||
// Copyright 2015 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 used to give an error:
|
||||
// <built-in>: error: redefinition of ‘s$F$hash’
|
||||
// <built-in>: note: previous definition of ‘s$F$hash’ was here
|
||||
// <built-in>: error: redefinition of ‘s$F$equal’
|
||||
// <built-in>: note: previous definition of ‘s$F$equal’ was here
|
||||
|
||||
package p
|
||||
|
||||
type T1 int
|
||||
|
||||
func (t T1) F() {
|
||||
type s struct {
|
||||
f string
|
||||
}
|
||||
}
|
||||
|
||||
type T2 int
|
||||
|
||||
func (t T2) F() {
|
||||
type s struct {
|
||||
f string
|
||||
}
|
||||
}
|
||||
28
test/fixedbugs/bug497.go
Normal file
28
test/fixedbugs/bug497.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// run
|
||||
|
||||
// Copyright 2015 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 used to miscompile passing a global variable with a
|
||||
// zero-sized type to a function.
|
||||
|
||||
package main
|
||||
|
||||
type T struct {
|
||||
field s
|
||||
}
|
||||
|
||||
type s struct{}
|
||||
|
||||
var X T
|
||||
|
||||
func F(_ T, c interface{}) int {
|
||||
return len(c.(string))
|
||||
}
|
||||
|
||||
func main() {
|
||||
if v := F(X, "hi"); v != 2 {
|
||||
panic(v)
|
||||
}
|
||||
}
|
||||
|
|
@ -18,14 +18,14 @@ func main() {
|
|||
|
||||
// Any implementation must be able to handle these constants at
|
||||
// compile time (even though they cannot be assigned to a float64).
|
||||
var _ = 1e646456992 // ERROR "1.00000e\+646456992 overflows float64"
|
||||
var _ = 1e64645699 // ERROR "1.00000e\+64645699 overflows float64"
|
||||
var _ = 1e6464569 // ERROR "1.00000e\+6464569 overflows float64"
|
||||
var _ = 1e646456 // ERROR "1.00000e\+646456 overflows float64"
|
||||
var _ = 1e64645 // ERROR "1.00000e\+64645 overflows float64"
|
||||
var _ = 1e6464 // ERROR "1.00000e\+6464 overflows float64"
|
||||
var _ = 1e646 // ERROR "1.00000e\+646 overflows float64"
|
||||
var _ = 1e309 // ERROR "1.00000e\+309 overflows float64"
|
||||
var _ = 1e646456992 // ERROR "1e\+646456992 overflows float64"
|
||||
var _ = 1e64645699 // ERROR "1e\+64645699 overflows float64"
|
||||
var _ = 1e6464569 // ERROR "1e\+6464569 overflows float64"
|
||||
var _ = 1e646456 // ERROR "1e\+646456 overflows float64"
|
||||
var _ = 1e64645 // ERROR "1e\+64645 overflows float64"
|
||||
var _ = 1e6464 // ERROR "1e\+6464 overflows float64"
|
||||
var _ = 1e646 // ERROR "1e\+646 overflows float64"
|
||||
var _ = 1e309 // ERROR "1e\+309 overflows float64"
|
||||
|
||||
var _ = 1e308
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ package p
|
|||
|
||||
var _ = int8(4) * 300 // ERROR "constant 300 overflows int8" "constant 1200 overflows int8"
|
||||
var _ = complex64(1) * 1e200 // ERROR "constant 1e\+200 overflows complex64"
|
||||
var _ = complex128(1) * 1e500 // ERROR "constant 1\.00000e\+500 overflows complex128"
|
||||
var _ = complex128(1) * 1e500 // ERROR "constant 1e\+500 overflows complex128"
|
||||
|
|
|
|||
17
test/fixedbugs/issue11610.go
Normal file
17
test/fixedbugs/issue11610.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2015 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 an internal compiler error on ? symbol in declaration
|
||||
// following an empty import.
|
||||
|
||||
package a
|
||||
import"" // ERROR "import path is empty"
|
||||
var? // ERROR "invalid declaration"
|
||||
|
||||
var x int // ERROR "unexpected var"
|
||||
|
||||
func main() {
|
||||
}
|
||||
26
test/fixedbugs/issue11614.go
Normal file
26
test/fixedbugs/issue11614.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2015 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 that incorrect expressions involving wrong anonymous interface
|
||||
// do not generate panics in Type Stringer.
|
||||
// Does not compile.
|
||||
|
||||
package main
|
||||
|
||||
type I interface {
|
||||
int // ERROR "interface contains embedded non-interface int"
|
||||
}
|
||||
|
||||
func n() {
|
||||
(I) // ERROR "type I is not an expression"
|
||||
}
|
||||
|
||||
func m() {
|
||||
(interface{int}) // ERROR "interface contains embedded non-interface int" "type interface { int } is not an expression"
|
||||
}
|
||||
|
||||
func main() {
|
||||
}
|
||||
17
test/fixedbugs/issue11737.go
Normal file
17
test/fixedbugs/issue11737.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2015 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 11737 - invalid == not being caught until generated switch code was compiled
|
||||
|
||||
package p
|
||||
|
||||
func f()
|
||||
|
||||
func s(x interface{}) {
|
||||
switch x {
|
||||
case f: // ERROR "invalid case f \(type func\(\)\) in switch \(incomparable type\)"
|
||||
}
|
||||
}
|
||||
24
test/fixedbugs/issue12411.go
Normal file
24
test/fixedbugs/issue12411.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// +build !386
|
||||
// run
|
||||
|
||||
// Copyright 2015 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 12411. Loss of AX during %.
|
||||
|
||||
package main
|
||||
|
||||
func main() {
|
||||
x := f(4)
|
||||
if x != 0 {
|
||||
println("BUG: x=", x)
|
||||
}
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func f(x int) int {
|
||||
// AX was live on entry to one of the % code generations,
|
||||
// and the % code generation smashed it.
|
||||
return ((2 * x) % 3) % (2 % ((x << 2) ^ (x % 3)))
|
||||
}
|
||||
8
test/fixedbugs/issue12677.dir/p.go
Normal file
8
test/fixedbugs/issue12677.dir/p.go
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright 2015 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 Baz(f int) float64 {
|
||||
return 1 / float64(int(1)<<(uint(f)))
|
||||
}
|
||||
7
test/fixedbugs/issue12677.dir/q.go
Normal file
7
test/fixedbugs/issue12677.dir/q.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright 2015 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 f() { println(p.Baz(2)) }
|
||||
9
test/fixedbugs/issue12677.go
Normal file
9
test/fixedbugs/issue12677.go
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// compiledir
|
||||
|
||||
// Copyright 2015 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 12677: Type loss during export/import of inlined function body.
|
||||
|
||||
package ignored
|
||||
16
test/fixedbugs/issue12686.go
Normal file
16
test/fixedbugs/issue12686.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// compile
|
||||
|
||||
// Copyright 2015 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.
|
||||
|
||||
// golang.org/issue/12686.
|
||||
// interesting because it's a non-constant but ideal value
|
||||
// and we used to incorrectly attach a constant Val to the Node.
|
||||
|
||||
package p
|
||||
|
||||
func f(i uint) uint {
|
||||
x := []uint{1 << i}
|
||||
return x[0]
|
||||
}
|
||||
13
test/fixedbugs/issue13248.go
Normal file
13
test/fixedbugs/issue13248.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2015 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.
|
||||
|
||||
// This program caused an infinite loop with the recursive-descent parser.
|
||||
|
||||
package main
|
||||
|
||||
func main() {
|
||||
foo(
|
||||
} // ERROR "unexpected }"
|
||||
29
test/fixedbugs/issue13261.go
Normal file
29
test/fixedbugs/issue13261.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// compile
|
||||
|
||||
// Copyright 2015 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.
|
||||
|
||||
// Taking the address of a parenthesized composite literal is permitted.
|
||||
|
||||
package main
|
||||
|
||||
type T struct{}
|
||||
|
||||
func main() {
|
||||
_ = &T{}
|
||||
_ = &(T{})
|
||||
_ = &((T{}))
|
||||
|
||||
_ = &struct{}{}
|
||||
_ = &(struct{}{})
|
||||
_ = &((struct{}{}))
|
||||
|
||||
switch (&T{}) {}
|
||||
switch &(T{}) {}
|
||||
switch &((T{})) {}
|
||||
|
||||
switch &struct{}{} {}
|
||||
switch &(struct{}{}) {}
|
||||
switch &((struct{}{})) {}
|
||||
}
|
||||
10
test/fixedbugs/issue13266.go
Normal file
10
test/fixedbugs/issue13266.go
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2015 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.
|
||||
|
||||
// Offending character % must not be interpreted as
|
||||
// start of format verb when emitting error message.
|
||||
|
||||
package% // ERROR "unexpected %"
|
||||
48
test/fixedbugs/issue13268.go
Normal file
48
test/fixedbugs/issue13268.go
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
// run
|
||||
|
||||
// Copyright 2015 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 message when EOF is encountered in the
|
||||
// middle of a BOM.
|
||||
//
|
||||
// Since the error requires an EOF, we cannot use the
|
||||
// errorcheckoutput mechanism.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// cannot use temp file on nacl via child process
|
||||
if runtime.GOOS == "nacl" {
|
||||
return
|
||||
}
|
||||
|
||||
// create source
|
||||
f, err := ioutil.TempFile("", "issue13268-")
|
||||
if err != nil {
|
||||
log.Fatalf("could not create source file: %v", err)
|
||||
}
|
||||
f.Write([]byte("package p\n\nfunc \xef\xef")) // if this fails, we will die later
|
||||
f.Close()
|
||||
defer os.Remove(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")
|
||||
}
|
||||
if strings.HasPrefix(string(out), "illegal UTF-8 sequence") {
|
||||
log.Fatalf("error %q not found", out)
|
||||
}
|
||||
}
|
||||
55
test/fixedbugs/issue13273.go
Normal file
55
test/fixedbugs/issue13273.go
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2015 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.
|
||||
|
||||
// Check that we correctly construct (and report errors)
|
||||
// for unary expressions of the form <-x where we only
|
||||
// know after parsing x whether <-x is a receive operation
|
||||
// or a channel type.
|
||||
|
||||
package n
|
||||
|
||||
func f() {
|
||||
// test case from issue 13273
|
||||
<-chan int((chan int)(nil))
|
||||
|
||||
<-chan int(nil)
|
||||
<-chan chan int(nil)
|
||||
<-chan chan chan int(nil)
|
||||
<-chan chan chan chan int(nil)
|
||||
<-chan chan chan chan chan int(nil)
|
||||
|
||||
<-chan<-chan int(nil)
|
||||
<-chan<-chan<-chan int(nil)
|
||||
<-chan<-chan<-chan<-chan int(nil)
|
||||
<-chan<-chan<-chan<-chan<-chan int(nil)
|
||||
|
||||
<-chan (<-chan int)(nil)
|
||||
<-chan (<-chan (<-chan int))(nil)
|
||||
<-chan (<-chan (<-chan (<-chan int)))(nil)
|
||||
<-chan (<-chan (<-chan (<-chan (<-chan int))))(nil)
|
||||
|
||||
<-(<-chan int)(nil)
|
||||
<-(<-chan chan int)(nil)
|
||||
<-(<-chan chan chan int)(nil)
|
||||
<-(<-chan chan chan chan int)(nil)
|
||||
<-(<-chan chan chan chan chan int)(nil)
|
||||
|
||||
<-(<-chan<-chan int)(nil)
|
||||
<-(<-chan<-chan<-chan int)(nil)
|
||||
<-(<-chan<-chan<-chan<-chan int)(nil)
|
||||
<-(<-chan<-chan<-chan<-chan<-chan int)(nil)
|
||||
|
||||
<-(<-chan (<-chan int))(nil)
|
||||
<-(<-chan (<-chan (<-chan int)))(nil)
|
||||
<-(<-chan (<-chan (<-chan (<-chan int))))(nil)
|
||||
<-(<-chan (<-chan (<-chan (<-chan (<-chan int)))))(nil)
|
||||
|
||||
type _ <-<-chan int // ERROR "unexpected <-, expecting chan"
|
||||
<-<-chan int // ERROR "unexpected <-, expecting chan|expecting {" (new parser: same error as for type decl)
|
||||
|
||||
type _ <-chan<-int // ERROR "unexpected int, expecting chan|expecting chan"
|
||||
<-chan<-int // ERROR "unexpected int, expecting chan|expecting {" (new parser: same error as for type decl)
|
||||
}
|
||||
11
test/fixedbugs/issue13274.go
Normal file
11
test/fixedbugs/issue13274.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2015 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.
|
||||
|
||||
// Check that we don't ignore EOF.
|
||||
|
||||
package p
|
||||
|
||||
var f = func() { // ERROR "unexpected EOF"
|
||||
18
test/fixedbugs/issue13319.go
Normal file
18
test/fixedbugs/issue13319.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2015 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 f(int, int) {
|
||||
switch x {
|
||||
case 1:
|
||||
f(1, g() // ERROR "expecting \)|expecting comma or \)"
|
||||
case 2:
|
||||
f()
|
||||
case 3:
|
||||
f(1, g() // ERROR "expecting \)|expecting comma or \)"
|
||||
}
|
||||
}
|
||||
25
test/fixedbugs/issue13365.go
Normal file
25
test/fixedbugs/issue13365.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2015 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 13365: confusing error message (array vs slice)
|
||||
|
||||
package main
|
||||
|
||||
var t struct{}
|
||||
|
||||
func main() {
|
||||
_ = []int{-1: 0} // ERROR "index must be non\-negative integer constant"
|
||||
_ = [10]int{-1: 0} // ERROR "index must be non\-negative integer constant"
|
||||
_ = [...]int{-1: 0} // ERROR "index must be non\-negative integer constant"
|
||||
|
||||
_ = []int{100: 0}
|
||||
_ = [10]int{100: 0} // ERROR "array index 100 out of bounds"
|
||||
_ = [...]int{100: 0}
|
||||
|
||||
_ = []int{t} // ERROR "cannot use .* as type int in array or slice literal"
|
||||
_ = [10]int{t} // ERROR "cannot use .* as type int in array or slice literal"
|
||||
_ = [...]int{t} // ERROR "cannot use .* as type int in array or slice literal"
|
||||
}
|
||||
19
test/fixedbugs/issue13415.go
Normal file
19
test/fixedbugs/issue13415.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2015 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.
|
||||
|
||||
// Verify that error message regarding := appears on
|
||||
// correct line (and not on the line of the 2nd :=).
|
||||
|
||||
package p
|
||||
|
||||
func f() {
|
||||
select {
|
||||
case x, x := <-func() chan int { // ERROR "x repeated on left side of :="
|
||||
c := make(chan int)
|
||||
return c
|
||||
}():
|
||||
}
|
||||
}
|
||||
25
test/fixedbugs/issue13471.go
Normal file
25
test/fixedbugs/issue13471.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2015 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.
|
||||
|
||||
// Tests for golang.org/issue/13471
|
||||
|
||||
package main
|
||||
|
||||
func main() {
|
||||
const _ int64 = 1e646456992 // ERROR "1e\+646456992 overflows integer"
|
||||
const _ int32 = 1e64645699 // ERROR "1e\+64645699 overflows integer"
|
||||
const _ int16 = 1e6464569 // ERROR "1e\+6464569 overflows integer"
|
||||
const _ int8 = 1e646456 // ERROR "1e\+646456 overflows integer"
|
||||
const _ int = 1e64645 // ERROR "1e\+64645 overflows integer"
|
||||
|
||||
const _ uint64 = 1e646456992 // ERROR "1e\+646456992 overflows integer"
|
||||
const _ uint32 = 1e64645699 // ERROR "1e\+64645699 overflows integer"
|
||||
const _ uint16 = 1e6464569 // ERROR "1e\+6464569 overflows integer"
|
||||
const _ uint8 = 1e646456 // ERROR "1e\+646456 overflows integer"
|
||||
const _ uint = 1e64645 // ERROR "1e\+64645 overflows integer"
|
||||
|
||||
const _ rune = 1e64645 // ERROR "1e\+64645 overflows integer"
|
||||
}
|
||||
38
test/fixedbugs/issue13480.go
Normal file
38
test/fixedbugs/issue13480.go
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2015 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.
|
||||
|
||||
// Verify that comparisons of slice/map/func values against converted nil
|
||||
// values are properly rejected.
|
||||
|
||||
package p
|
||||
|
||||
func bug() {
|
||||
type S []byte
|
||||
type M map[int]int
|
||||
type F func()
|
||||
|
||||
var s S
|
||||
var m M
|
||||
var f F
|
||||
|
||||
_ = s == S(nil) // ERROR "compare.*to nil"
|
||||
_ = S(nil) == s // ERROR "compare.*to nil"
|
||||
switch s {
|
||||
case S(nil): // ERROR "compare.*to nil"
|
||||
}
|
||||
|
||||
_ = m == M(nil) // ERROR "compare.*to nil"
|
||||
_ = M(nil) == m // ERROR "compare.*to nil"
|
||||
switch m {
|
||||
case M(nil): // ERROR "compare.*to nil"
|
||||
}
|
||||
|
||||
_ = f == F(nil) // ERROR "compare.*to nil"
|
||||
_ = F(nil) == f // ERROR "compare.*to nil"
|
||||
switch f {
|
||||
case F(nil): // ERROR "compare.*to nil"
|
||||
}
|
||||
}
|
||||
20
test/fixedbugs/issue13539.go
Normal file
20
test/fixedbugs/issue13539.go
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2015 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.
|
||||
|
||||
// Verify that a label named like a package is recognized
|
||||
// as a label rather than a package and that the package
|
||||
// remains unused.
|
||||
|
||||
package main
|
||||
|
||||
import "math" // ERROR "imported and not used"
|
||||
|
||||
func main() {
|
||||
math:
|
||||
for {
|
||||
break math
|
||||
}
|
||||
}
|
||||
89
test/fixedbugs/issue13559.go
Normal file
89
test/fixedbugs/issue13559.go
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2015 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.
|
||||
|
||||
// Verify that error messages print meaningful values
|
||||
// for various extreme floating-point constants.
|
||||
|
||||
package p
|
||||
|
||||
// failure case in issue
|
||||
const _ int64 = 1e-10000 // ERROR "1e\-10000 truncated"
|
||||
|
||||
const (
|
||||
_ int64 = 1e10000000 // ERROR "1e\+10000000 overflows"
|
||||
_ int64 = 1e1000000 // ERROR "1e\+1000000 overflows"
|
||||
_ int64 = 1e100000 // ERROR "1e\+100000 overflows"
|
||||
_ int64 = 1e10000 // ERROR "1e\+10000 overflows"
|
||||
_ int64 = 1e1000 // ERROR "1e\+1000 overflows"
|
||||
_ int64 = 1e100 // ERROR "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 overflows"
|
||||
_ int64 = 1e10
|
||||
_ int64 = 1e1
|
||||
_ int64 = 1e0
|
||||
_ int64 = 1e-1 // ERROR "0\.1 truncated"
|
||||
_ int64 = 1e-10 // ERROR "1e\-10 truncated"
|
||||
_ int64 = 1e-100 // ERROR "1e\-100 truncated"
|
||||
_ int64 = 1e-1000 // ERROR "1e\-1000 truncated"
|
||||
_ int64 = 1e-10000 // ERROR "1e\-10000 truncated"
|
||||
_ int64 = 1e-100000 // ERROR "1e\-100000 truncated"
|
||||
_ int64 = 1e-1000000 // ERROR "1e\-1000000 truncated"
|
||||
)
|
||||
|
||||
const (
|
||||
_ int64 = -1e10000000 // ERROR "\-1e\+10000000 overflows"
|
||||
_ int64 = -1e1000000 // ERROR "\-1e\+1000000 overflows"
|
||||
_ int64 = -1e100000 // ERROR "\-1e\+100000 overflows"
|
||||
_ int64 = -1e10000 // ERROR "\-1e\+10000 overflows"
|
||||
_ int64 = -1e1000 // ERROR "\-1e\+1000 overflows"
|
||||
_ int64 = -1e100 // ERROR "\-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 overflows"
|
||||
_ int64 = -1e10
|
||||
_ int64 = -1e1
|
||||
_ int64 = -1e0
|
||||
_ int64 = -1e-1 // ERROR "\-0\.1 truncated"
|
||||
_ int64 = -1e-10 // ERROR "\-1e\-10 truncated"
|
||||
_ int64 = -1e-100 // ERROR "\-1e\-100 truncated"
|
||||
_ int64 = -1e-1000 // ERROR "\-1e\-1000 truncated"
|
||||
_ int64 = -1e-10000 // ERROR "\-1e\-10000 truncated"
|
||||
_ int64 = -1e-100000 // ERROR "\-1e\-100000 truncated"
|
||||
_ int64 = -1e-1000000 // ERROR "\-1e\-1000000 truncated"
|
||||
)
|
||||
|
||||
const (
|
||||
_ int64 = 1.23456789e10000000 // ERROR "1\.23457e\+10000000 overflows"
|
||||
_ int64 = 1.23456789e1000000 // ERROR "1\.23457e\+1000000 overflows"
|
||||
_ int64 = 1.23456789e100000 // ERROR "1\.23457e\+100000 overflows"
|
||||
_ int64 = 1.23456789e10000 // ERROR "1\.23457e\+10000 overflows"
|
||||
_ int64 = 1.23456789e1000 // ERROR "1\.23457e\+1000 overflows"
|
||||
_ int64 = 1.23456789e100 // ERROR "12345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 overflows"
|
||||
_ int64 = 1.23456789e10
|
||||
_ int64 = 1.23456789e1 // ERROR "12\.3457 truncated"
|
||||
_ int64 = 1.23456789e0 // ERROR "1\.23457 truncated"
|
||||
_ int64 = 1.23456789e-1 // ERROR "0\.123457 truncated"
|
||||
_ int64 = 1.23456789e-10 // ERROR "1\.23457e\-10 truncated"
|
||||
_ int64 = 1.23456789e-100 // ERROR "1\.23457e\-100 truncated"
|
||||
_ int64 = 1.23456789e-1000 // ERROR "1\.23457e\-1000 truncated"
|
||||
_ int64 = 1.23456789e-10000 // ERROR "1\.23457e\-10000 truncated"
|
||||
_ int64 = 1.23456789e-100000 // ERROR "1\.23457e\-100000 truncated"
|
||||
_ int64 = 1.23456789e-1000000 // ERROR "1\.23457e\-1000000 truncated"
|
||||
)
|
||||
|
||||
const (
|
||||
_ int64 = -1.23456789e10000000 // ERROR "\-1\.23457e\+10000000 overflows"
|
||||
_ int64 = -1.23456789e1000000 // ERROR "\-1\.23457e\+1000000 overflows"
|
||||
_ int64 = -1.23456789e100000 // ERROR "\-1\.23457e\+100000 overflows"
|
||||
_ int64 = -1.23456789e10000 // ERROR "\-1\.23457e\+10000 overflows"
|
||||
_ int64 = -1.23456789e1000 // ERROR "\-1\.23457e\+1000 overflows"
|
||||
_ int64 = -1.23456789e100 // ERROR "\-12345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 overflows"
|
||||
_ int64 = -1.23456789e10
|
||||
_ int64 = -1.23456789e1 // ERROR "\-12\.3457 truncated"
|
||||
_ int64 = -1.23456789e0 // ERROR "\-1\.23457 truncated"
|
||||
_ int64 = -1.23456789e-1 // ERROR "\-0\.123457 truncated"
|
||||
_ int64 = -1.23456789e-10 // ERROR "\-1\.23457e\-10 truncated"
|
||||
_ int64 = -1.23456789e-100 // ERROR "\-1\.23457e\-100 truncated"
|
||||
_ int64 = -1.23456789e-1000 // ERROR "\-1\.23457e\-1000 truncated"
|
||||
_ int64 = -1.23456789e-10000 // ERROR "\-1\.23457e\-10000 truncated"
|
||||
_ int64 = -1.23456789e-100000 // ERROR "\-1\.23457e\-100000 truncated"
|
||||
_ int64 = -1.23456789e-1000000 // ERROR "\-1\.23457e\-1000000 truncated"
|
||||
)
|
||||
19
test/fixedbugs/issue13587.go
Normal file
19
test/fixedbugs/issue13587.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// errorcheck -0 -l -d=wb
|
||||
|
||||
// Copyright 2015 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 write barrier for implicit assignments to result parameters
|
||||
// that have escaped to the heap.
|
||||
|
||||
package issue13587
|
||||
|
||||
import "errors"
|
||||
|
||||
func escape(p *error)
|
||||
|
||||
func F() (err error) {
|
||||
escape(&err)
|
||||
return errors.New("error") // ERROR "write barrier"
|
||||
}
|
||||
17
test/fixedbugs/issue13684.go
Normal file
17
test/fixedbugs/issue13684.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// run
|
||||
|
||||
// Copyright 2015 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.
|
||||
|
||||
// Verify that a label name matching a constant name
|
||||
// is permitted.
|
||||
|
||||
package main
|
||||
|
||||
const labelname = 1
|
||||
|
||||
func main() {
|
||||
goto labelname
|
||||
labelname:
|
||||
}
|
||||
19
test/fixedbugs/issue13777.dir/burnin.go
Normal file
19
test/fixedbugs/issue13777.dir/burnin.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package burnin
|
||||
|
||||
type sendCmdFunc func(string)
|
||||
|
||||
func sendCommand(c string) {}
|
||||
|
||||
func NewSomething() {
|
||||
// This works...
|
||||
// var sendCmd sendCmdFunc
|
||||
// sendCmd = sendCommand
|
||||
|
||||
// So does this...
|
||||
//sendCmd := sendCmdFunc(sendCommand)
|
||||
|
||||
// This fails...
|
||||
sendCmd := sendCommand
|
||||
|
||||
_ = sendCmd
|
||||
}
|
||||
11
test/fixedbugs/issue13777.dir/main.go
Normal file
11
test/fixedbugs/issue13777.dir/main.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// build
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
x "./burnin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
x.NewSomething()
|
||||
}
|
||||
7
test/fixedbugs/issue13777.go
Normal file
7
test/fixedbugs/issue13777.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
// rundir
|
||||
|
||||
// Copyright 2015 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
|
||||
15
test/fixedbugs/issue13821.go
Normal file
15
test/fixedbugs/issue13821.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// compile
|
||||
|
||||
// Copyright 2015 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 13821. Compiler rejected "bool(true)" as not a constant.
|
||||
|
||||
package p
|
||||
|
||||
const (
|
||||
A = true
|
||||
B = bool(A)
|
||||
C = bool(true)
|
||||
)
|
||||
22
test/fixedbugs/issue13821b.go
Normal file
22
test/fixedbugs/issue13821b.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2015 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 13821. Additional regress tests.
|
||||
|
||||
package p
|
||||
|
||||
type B bool
|
||||
type B2 bool
|
||||
|
||||
var b B
|
||||
var b2 B2
|
||||
var x1 = b && 1 < 2 // x1 has type B, not ideal bool
|
||||
var x2 = 1 < 2 && b // x2 has type B, not ideal bool
|
||||
var x3 = b && b2 // ERROR "mismatched types B and B2"
|
||||
var x4 = x1 && b2 // ERROR "mismatched types B and B2"
|
||||
var x5 = x2 && b2 // ERROR "mismatched types B and B2"
|
||||
var x6 = b2 && x1 // ERROR "mismatched types B2 and B"
|
||||
var x7 = b2 && x2 // ERROR "mismatched types B2 and B"
|
||||
|
|
@ -19,8 +19,12 @@ type S struct {
|
|||
}
|
||||
|
||||
func F() {
|
||||
go (F()) // ERROR "must be function call"
|
||||
defer (F()) // ERROR "must be function call"
|
||||
go F // ERROR "must be function call"
|
||||
defer F // ERROR "must be function call"
|
||||
go (F) // ERROR "must be function call|must not be parenthesized"
|
||||
defer (F) // ERROR "must be function call|must not be parenthesized"
|
||||
go (F()) // ERROR "must be function call|must not be parenthesized"
|
||||
defer (F()) // ERROR "must be function call|must not be parenthesized"
|
||||
var s S
|
||||
(&s.t).F()
|
||||
go (&s.t).F()
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@
|
|||
package main
|
||||
|
||||
func main() {
|
||||
_ = [0]int{-1: 50} // ERROR "array index must be non-negative integer constant"
|
||||
_ = [0]int{0: 0} // ERROR "array index 0 out of bounds \[0:0\]"
|
||||
_ = [0]int{5: 25} // ERROR "array index 5 out of bounds \[0:0\]"
|
||||
_ = [10]int{2: 10, 15: 30} // ERROR "array index 15 out of bounds \[0:10\]"
|
||||
_ = [10]int{5: 5, 1: 1, 12: 12} // ERROR "array index 12 out of bounds \[0:10\]"
|
||||
_ = [0]int{-1: 50} // ERROR "index must be non-negative integer constant"
|
||||
_ = [0]int{0: 0} // ERROR "index 0 out of bounds \[0:0\]"
|
||||
_ = [0]int{5: 25} // ERROR "index 5 out of bounds \[0:0\]"
|
||||
_ = [10]int{2: 10, 15: 30} // ERROR "index 15 out of bounds \[0:10\]"
|
||||
_ = [10]int{5: 5, 1: 1, 12: 12} // ERROR "index 12 out of bounds \[0:10\]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@
|
|||
|
||||
package p
|
||||
|
||||
var _ = []int{a: true, true} // ERROR "undefined: a" "cannot use true \(type bool\) as type int in array element"
|
||||
var _ = []int{a: true, true} // ERROR "undefined: a" "cannot use true \(type bool\) as type int in array or slice literal"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue