]> Cypherpunks repositories - gostls13.git/commitdiff
test: re-enable most go/tests that were disabled because of types2 differences
authorDan Scales <danscales@google.com>
Sat, 4 Dec 2021 00:10:10 +0000 (16:10 -0800)
committerDan Scales <danscales@google.com>
Tue, 11 Jan 2022 02:26:58 +0000 (02:26 +0000)
I made the default be that, where there are differences between types2
and -G=0 error messages, we want errorcheck tests to pass types2.
Typically, we can get errorcheck to pass on types2 and -G=0 if they give
the same number of error messages on the same lines, just different
wording. If they give a different number of error messages, then I made
types2 pass. I added an exception list for -G=0 to cover those cases
where -G=0 and types give different numbers of error messages.

Because types2 does not run if there are syntax errors, for several
tests, I had to split the tests into two parts in order to get all the
indicated errors to be reported in types2 (bug228.go, bug388.go,
issue11610.go, issue14520.go)

I tried to preserve the GCCGO labeling correctly (but may have gotten
some wrong). When types2 now matches where a GCCGO error previously
occurred, I transformed GCCGO_ERROR -> ERROR. When types2 no longer
reports an error in a certain place, I transformed ERROR -> GCCGO_ERROR.
When types2 reports an error in a new place, I used GC_ERROR.

The remaining entries in types2Failures are things that I think we
probably still need to fix - either actually missing errors in types2,
or cases where types2 gives worse errors than -G=0.

Change-Id: I7f01e82b322b16094096b67d7ed2bb39b410c34f
Reviewed-on: https://go-review.googlesource.com/c/go/+/372854
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
37 files changed:
test/fixedbugs/bug176.go
test/fixedbugs/bug195.go
test/fixedbugs/bug228.go
test/fixedbugs/bug228a.go [new file with mode: 0644]
test/fixedbugs/bug231.go
test/fixedbugs/bug255.go
test/fixedbugs/bug388.go
test/fixedbugs/bug388a.go [new file with mode: 0644]
test/fixedbugs/bug412.go
test/fixedbugs/issue11590.go
test/fixedbugs/issue11610.go
test/fixedbugs/issue11610a.go [new file with mode: 0644]
test/fixedbugs/issue11614.go
test/fixedbugs/issue14520.go
test/fixedbugs/issue14520a.go [new file with mode: 0644]
test/fixedbugs/issue17038.go
test/fixedbugs/issue19012.go
test/fixedbugs/issue21979.go
test/fixedbugs/issue23732.go
test/fixedbugs/issue25958.go
test/fixedbugs/issue28079b.go
test/fixedbugs/issue28268.go
test/fixedbugs/issue33460.go
test/fixedbugs/issue4232.go
test/fixedbugs/issue4452.go
test/fixedbugs/issue4510.dir/f1.go
test/fixedbugs/issue4510.dir/f2.go
test/fixedbugs/issue7525.go
test/fixedbugs/issue7525b.go
test/fixedbugs/issue7525c.go
test/fixedbugs/issue7525d.go
test/fixedbugs/issue7525e.go
test/import1.go
test/import6.go
test/initializerr.go
test/run.go
test/typecheck.go

index 7001dd081e9ab0c7e23655f081e1105d1ffd726f..61e63c76564b01229cdf386aa50dad879a674a86 100644 (file)
@@ -8,7 +8,6 @@ package main
 
 var x int
 
-var a = []int{ x: 1}   // ERROR "constant"
-var b = [...]int{x: 1} // GCCGO_ERROR "constant"
-var c = map[int]int{ x: 1}
-
+var a = []int{x: 1}    // ERROR "constant"
+var b = [...]int{x: 1} // ERROR "constant"
+var c = map[int]int{x: 1}
index 6d8578d6cb06049eaf2bdc115f0fae0832110394..4a3bf0db81d84094664dff9bd53d2ca6dd641d55 100644 (file)
@@ -11,14 +11,14 @@ type I2 int
 
 type I3 interface{ int } // ERROR "interface"
 
-type S struct {
-       x interface{ S } // ERROR "interface"
+type S struct { // GC_ERROR "invalid recursive type"
+       x interface{ S } // GCCGO_ERROR "interface"
 }
-type I4 interface { // GC_ERROR "invalid recursive type I4\n\tLINE: I4 refers to\n\tLINE: I4$"
+type I4 interface { // GC_ERROR "invalid recursive type I4\n\tLINE:.* I4 refers to\n\tLINE:.* I4$"
        I4 // GCCGO_ERROR "interface"
 }
 
-type I5 interface { // GC_ERROR "invalid recursive type I5\n\tLINE: I5 refers to\n\tLINE+4: I6 refers to\n\tLINE: I5$"
+type I5 interface { // GC_ERROR "invalid recursive type I5\n\tLINE:.* I5 refers to\n\tLINE+4:.* I6 refers to\n\tLINE:.* I5$"
        I6
 }
 
index 50e895917fab26d5e50cdc0ebb10dde58cc98850..5c0e7e5122d40edf879bd040e07b5d4bdef6b67a 100644 (file)
@@ -6,14 +6,10 @@
 
 package main
 
-func f(x int, y ...int)        // ok
+func f(x int, y ...int) // ok
 
 func g(x int, y float32) (...) // ERROR "[.][.][.]"
 
-func h(x, y ...int)            // ERROR "[.][.][.]"
-
-func i(x int, y ...int, z float32)     // ERROR "[.][.][.]"
-
 var x ...int;          // ERROR "[.][.][.]|syntax|type"
 
 type T ...int;         // ERROR "[.][.][.]|syntax|type"
diff --git a/test/fixedbugs/bug228a.go b/test/fixedbugs/bug228a.go
new file mode 100644 (file)
index 0000000..c42b0bf
--- /dev/null
@@ -0,0 +1,13 @@
+// errorcheck
+
+// Copyright 2009 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(x int, y ...int) // ok
+
+func h(x, y ...int) // ERROR "[.][.][.]"
+
+func i(x int, y ...int, z float32) // ERROR "[.][.][.]"
index f64ddc3e757cd0cecd749b32fc684e7c40ba3a55..db0d536db7d01a2c1689598f8c02ee9b7389f5ee 100644 (file)
@@ -6,17 +6,19 @@
 
 package main
 
-type I interface { m() }
-type T struct { m func() }
-type M struct {}
+type I interface{ m() }
+type T struct{ m func() }
+type M struct{}
+
 func (M) m() {}
 
 func main() {
        var t T
        var m M
        var i I
-       
+
        i = m
-       i = t   // ERROR "not a method|has no methods" "does not implement I"
+       // types2 does not give extra error "T.m is a field, not a method"
+       i = t // ERROR "not a method|has no methods|does not implement I"
        _ = i
 }
index 458fb972b20958484e89e011c97a7c179097c14c..38df7813c9d5a1dbee651fd3d421d1f5ddfb7a0d 100644 (file)
@@ -8,13 +8,13 @@ package main
 
 var a [10]int      // ok
 var b [1e1]int     // ok
-var c [1.5]int     // ERROR "truncated"
-var d ["abc"]int   // ERROR "invalid array bound|not numeric"
-var e [nil]int     // ERROR "use of untyped nil|invalid array bound|not numeric"
+var c [1.5]int     // ERROR "truncated|must be integer"
+var d ["abc"]int   // ERROR "invalid array bound|not numeric|must be integer"
+var e [nil]int     // ERROR "use of untyped nil|invalid array bound|not numeric|must be constant"
 var f [e]int       // ok: error already reported for e
-var g [1 << 65]int // ERROR "array bound is too large|overflows"
+var g [1 << 65]int // ERROR "array bound is too large|overflows|must be integer"
 var h [len(a)]int  // ok
 
 func ff() string
 
-var i [len([1]string{ff()})]int // ERROR "non-constant array bound|not constant"
+var i [len([1]string{ff()})]int // ERROR "non-constant array bound|not constant|must be constant"
index 2d508501e07989c7121bc8f0ddb4245268271356..a060c9fd5a75c66e0f676f37f2dbe32665f5eb0f 100644 (file)
@@ -13,16 +13,6 @@ func foo(runtime.UintType, i int) {  // ERROR "cannot declare name runtime.UintT
        println(i, runtime.UintType) // GCCGO_ERROR "undefined identifier"
 }
 
-func bar(i int) {
-       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"
-}
-
-func baz() {
-       main.i := 1     // ERROR "non-name main.i|non-name on left side"
-       println(main.i) // GCCGO_ERROR "no fields or methods"
-}
-
 func qux() {
        var main.i      // ERROR "unexpected [.]|expected type"
        println(main.i)
diff --git a/test/fixedbugs/bug388a.go b/test/fixedbugs/bug388a.go
new file mode 100644 (file)
index 0000000..fca6d9c
--- /dev/null
@@ -0,0 +1,23 @@
+// errorcheck
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 2231
+
+package main
+import "runtime"
+
+func bar(i int) {
+       runtime.UintType := i       // ERROR "non-name runtime.UintType|non-name on left side|undefined"
+       println(runtime.UintType)       // ERROR "invalid use of type|undefined"
+}
+
+func baz() {
+       main.i := 1     // ERROR "non-name main.i|non-name on left side|undefined"
+       println(main.i) // ERROR "no fields or methods|undefined"
+}
+
+func main() {
+}
index 183fb7e4af026b251d70d5f818e52d0063385b56..26ac45fbb40a38440818e99f65831e5df5c86f52 100644 (file)
@@ -7,10 +7,10 @@
 package p
 
 type t struct {
-       x int  // GCCGO_ERROR "duplicate field name .x."
-       x int  // GC_ERROR "duplicate field x"
+       x int // GCCGO_ERROR "duplicate field name .x."
+       x int // GC_ERROR "duplicate field x|x redeclared"
 }
 
 func f(t *t) int {
-       return t.x  // GC_ERROR "ambiguous selector t.x"
+       return t.x
 }
index f2a955f96d06724151f26a210ce509a86647e810..9f8978334314c28afbcdd263521d22421926d8d1 100644 (file)
@@ -6,6 +6,6 @@
 
 package p
 
-var _ = int8(4) * 300         // ERROR "constant 300 overflows int8" "constant 1200 overflows int8|integer constant overflow"
-var _ = complex64(1) * 1e200  // ERROR "constant 1e\+200 overflows complex64|complex real part overflow"
-var _ = complex128(1) * 1e500 // ERROR "constant 1e\+500 overflows complex128|complex real part overflow"
+var _ = int8(4) * 300         // ERROR "overflows int8"
+var _ = complex64(1) * 1e200  // ERROR "complex real part overflow|overflows complex64"
+var _ = complex128(1) * 1e500 // ERROR "complex real part overflow|overflows complex128"
index 7ebfae6709f35d6777aef45c131b36b7e118885d..8d68c98f2d437d543d2294baf34edcf361459455 100644 (file)
@@ -8,7 +8,6 @@
 // following an empty import.
 
 package a
-import""  // ERROR "import path is empty"
 var?      // ERROR "invalid character U\+003F '\?'|invalid character 0x3f in input file"
 
 var x int // ERROR "unexpected var|expected identifier|expected type"
diff --git a/test/fixedbugs/issue11610a.go b/test/fixedbugs/issue11610a.go
new file mode 100644 (file)
index 0000000..bbf60b6
--- /dev/null
@@ -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.
+
+// Test an internal compiler error on ? symbol in declaration
+// following an empty import.
+
+package a
+import""  // ERROR "import path is empty|invalid import path \(empty string\)"
index 6ea463b7fe92ffbbe0ebfc5d7fe8500caacec2a7..e8d6badfb90fc268ab7c34c38bc25ce66eec2320 100644 (file)
 package main
 
 type I interface {
-       int // ERROR "interface contains embedded non-interface"
+       int // ERROR "interface contains embedded non-interface|embedding non-interface type int requires"
 }
 
 func n() {
-       (I)
+       (I) // GC_ERROR "is not an expression"
 }
 
 func m() {
-       (interface{int}) // ERROR "interface contains embedded non-interface" "type interface { int } is not an expression"
+       (interface{int}) // ERROR "interface contains embedded non-interface|embedding non-interface type int requires" "type interface { int } is not an expression|\(interface{int}\) \(type\) is not an expression"
 }
 
 func main() {
index 0b840ff4bee9ad173cfaf8f23f046630a27e1d56..29cc270deb070b83c05a3ec66f9cb77ba82d0dc9 100644 (file)
@@ -6,9 +6,6 @@
 
 package f
 
-import /* // ERROR "import path" */ `
-bogus`
-
 func f(x int /* // GC_ERROR "unexpected newline"
 
 */) // GCCGO_ERROR "expected .*\).*|expected declaration"
diff --git a/test/fixedbugs/issue14520a.go b/test/fixedbugs/issue14520a.go
new file mode 100644 (file)
index 0000000..bb45d7e
--- /dev/null
@@ -0,0 +1,10 @@
+// errorcheck
+
+// Copyright 2016 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 f
+
+import /* // ERROR "import path" */ `
+bogus`
index 4d7422c60c056e5fa5c5aebcaee686d02740359a..1b65ffc1f0eec68f2fdafe403bd64b4054368e15 100644 (file)
@@ -6,4 +6,4 @@
 
 package main
 
-const A = complex(0()) // ERROR "cannot call non-function" "not enough arguments"
+const A = complex(0()) // ERROR "cannot call non-function"
index 158618aa27efcca31f0d4af81c55451cf84936a8..77b22360635eea769edd5132a2b35d0312e5022e 100644 (file)
@@ -13,9 +13,9 @@ package main
 
 func f(x int, y uint) {
        if true {
-               return "a" > 10 // ERROR "^too many arguments to return$|return with value in function with no return|mismatched types"
+               return "a" > 10 // ERROR "^too many arguments to return$|return with value in function with no return|no result values expected|mismatched types"
        }
-       return "gopher" == true, 10 // ERROR "^too many arguments to return$|return with value in function with no return|mismatched types"
+       return "gopher" == true, 10 // ERROR "^too many arguments to return$|return with value in function with no return|no result values expected|mismatched types"
 }
 
 func main() {
index addf786c037a062caacaf378d7d505fb4a5460d3..c6575a3928a4175aceb3c562036c81635ff92c41 100644 (file)
@@ -7,39 +7,40 @@
 package p
 
 func f() {
-       _ = bool("")      // ERROR "cannot convert .. \(type untyped string\) to type bool|invalid type conversion"
-       _ = bool(1)       // ERROR "cannot convert 1 \(type untyped int\) to type bool|invalid type conversion"
-       _ = bool(1.0)     // ERROR "cannot convert 1 \(type untyped float\) to type bool|invalid type conversion"
-       _ = bool(-4 + 2i) // ERROR "cannot convert -4 \+ 2i \(type untyped complex\) to type bool|invalid type conversion"
+       _ = bool("")      // ERROR "cannot convert .. \(.*untyped string.*\) to type bool|invalid type conversion"
+       _ = bool(1)       // ERROR "cannot convert 1 \(.*untyped int.*\) to type bool|invalid type conversion"
+       _ = bool(1.0)     // ERROR "cannot convert 1.* \(.*untyped float.*\) to type bool|invalid type conversion"
+       _ = bool(-4 + 2i) // ERROR "cannot convert -4 \+ 2i \(.*untyped complex.*\) to type bool|invalid type conversion"
 
-       _ = string(true) // ERROR "cannot convert true \(type untyped bool\) to type string|invalid type conversion"
+       _ = string(true) // ERROR "cannot convert true \(.*untyped bool.*\) to type string|invalid type conversion"
        _ = string(-1)
-       _ = string(1.0)     // ERROR "cannot convert 1 \(type untyped float\) to type string|invalid type conversion"
-       _ = string(-4 + 2i) // ERROR "cannot convert -4 \+ 2i \(type untyped complex\) to type string|invalid type conversion"
+       _ = string(1.0)     // ERROR "cannot convert 1.* \(.*untyped float.*\) to type string|invalid type conversion"
+       _ = string(-4 + 2i) // ERROR "cannot convert -4 \+ 2i \(.*untyped complex.*\) to type string|invalid type conversion"
 
-       _ = int("")   // ERROR "cannot convert .. \(type untyped string\) to type int|invalid type conversion"
-       _ = int(true) // ERROR "cannot convert true \(type untyped bool\) to type int|invalid type conversion"
+       _ = int("")   // ERROR "cannot convert .. \(.*untyped string.*\) to type int|invalid type conversion"
+       _ = int(true) // ERROR "cannot convert true \(.*untyped bool.*\) to type int|invalid type conversion"
        _ = int(-1)
        _ = int(1)
        _ = int(1.0)
-       _ = int(-4 + 2i) // ERROR "truncated to integer"
+       _ = int(-4 + 2i) // ERROR "truncated to integer|cannot convert -4 \+ 2i \(.*untyped complex.*\) to type int"
 
-       _ = uint("")   // ERROR "cannot convert .. \(type untyped string\) to type uint|invalid type conversion"
-       _ = uint(true) // ERROR "cannot convert true \(type untyped bool\) to type uint|invalid type conversion"
-       _ = uint(-1)   // ERROR "constant -1 overflows uint|integer constant overflow"
+       _ = uint("")   // ERROR "cannot convert .. \(.*untyped string.*\) to type uint|invalid type conversion"
+       _ = uint(true) // ERROR "cannot convert true \(.*untyped bool.*\) to type uint|invalid type conversion"
+       _ = uint(-1)   // ERROR "constant -1 overflows uint|integer constant overflow|cannot convert -1 \(untyped int constant\) to type uint"
        _ = uint(1)
        _ = uint(1.0)
-       _ = uint(-4 + 2i) // ERROR "constant -4 overflows uint" "truncated to integer"
+       // types1 reports extra error "truncated to integer"
+       _ = uint(-4 + 2i) // ERROR "constant -4 overflows uint|truncated to integer|cannot convert -4 \+ 2i \(untyped complex constant.*\) to type uint"
 
-       _ = float64("")   // ERROR "cannot convert .. \(type untyped string\) to type float64|invalid type conversion"
-       _ = float64(true) // ERROR "cannot convert true \(type untyped bool\) to type float64|invalid type conversion"
+       _ = float64("")   // ERROR "cannot convert .. \(.*untyped string.*\) to type float64|invalid type conversion"
+       _ = float64(true) // ERROR "cannot convert true \(.*untyped bool.*\) to type float64|invalid type conversion"
        _ = float64(-1)
        _ = float64(1)
        _ = float64(1.0)
-       _ = float64(-4 + 2i) // ERROR "truncated to"
+       _ = float64(-4 + 2i) // ERROR "truncated to|cannot convert -4 \+ 2i \(.*untyped complex.*\) to type float64"
 
-       _ = complex128("")   // ERROR "cannot convert .. \(type untyped string\) to type complex128|invalid type conversion"
-       _ = complex128(true) // ERROR "cannot convert true \(type untyped bool\) to type complex128|invalid type conversion"
+       _ = complex128("")   // ERROR "cannot convert .. \(.*untyped string.*\) to type complex128|invalid type conversion"
+       _ = complex128(true) // ERROR "cannot convert true \(.*untyped bool.*\) to type complex128|invalid type conversion"
        _ = complex128(-1)
        _ = complex128(1)
        _ = complex128(1.0)
index db2d182234100e0ef4f485f00289179eda919944..79b60e26df0db0162be417384e4bfc7dced6e0ed 100644 (file)
@@ -24,19 +24,19 @@ func main() {
        _ = Foo{ // GCCGO_ERROR "too few expressions"
                1,
                2,
-               3, // GC_ERROR "too few values in Foo{...}"
-       }
+               3,
+       } // GC_ERROR "too few values in"
 
        _ = Foo{
                1,
                2,
                3,
-               Bar{"A", "B"}, // ERROR "too many values in Bar{...}|too many expressions"
+               Bar{"A", "B"}, // ERROR "too many values in|too many expressions"
        }
 
        _ = Foo{ // GCCGO_ERROR "too few expressions"
                1,
                2,
-               Bar{"A", "B"}, // ERROR "too many values in Bar{...}|too many expressions" "too few values in Foo{...}"
-       }
+               Bar{"A", "B"}, // ERROR "too many values in|too many expressions"
+       } // GC_ERROR "too few values in"
 }
index 90fcee15fd0b900a1f6448df11a048793f4f7667..91358f83fe0ae0d8eee2eca082dd7356015509fc 100644 (file)
@@ -11,7 +11,7 @@ package p
 
 func f(done chan struct{}) {
        select {
-       case done: // ERROR "must be receive|expected .*<-.* or .*=" "not used"
-       case (chan struct{})(done): // ERROR "must be receive|expected .*<-.* or .*="
+       case done: // ERROR "must be receive|expected .*<-.* or .*=|must be send or receive|not used"
+       case (chan struct{})(done): // ERROR "must be receive|expected .*<-.* or .*=|must be send or receive"
        }
 }
index 54c9db994b8fa216f67f42ab653d7741fd3fd331..69d1a2f480897d9be894cb26e7395f5552195385 100644 (file)
@@ -10,8 +10,8 @@ package p
 
 import "unsafe"
 
-type T [uintptr(unsafe.Pointer(nil))]int // ERROR "non-constant array bound|array bound is not constant"
+type T [uintptr(unsafe.Pointer(nil))]int // ERROR "non-constant array bound|array bound is not constant|must be constant"
 
 func f() {
-       _ = complex(1<<uintptr(unsafe.Pointer(nil)), 0) // ERROR "shift of type float64|non-integer type for left operand of shift"
+       _ = complex(1<<uintptr(unsafe.Pointer(nil)), 0) // ERROR "shift of type float64|non-integer type for left operand of shift|must be integer"
 }
index 59a4c57c6727b35cda2538f139432a20c1571387..263b2d1b425b7df9d3476350d81fbe5a3da9df12 100644 (file)
@@ -16,8 +16,8 @@ type T struct {
 
 type E struct{}
 
-func (T) b()  {} // ERROR "field and method named b|redeclares struct field name"
-func (*T) E() {} // ERROR "field and method named E|redeclares struct field name"
+func (T) b()  {} // ERROR "field and method named b|redeclares struct field name|field and method with the same name b"
+func (*T) E() {} // ERROR "field and method named E|redeclares struct field name|field and method with the same name E"
 
 func _() {
        var x T
index d90b0a43489d4baf66681f789cef1f0f9e065abb..dff468a12cc7f92d2cb4ff350f18cac0230b1f64 100644 (file)
@@ -18,11 +18,11 @@ const iii int = 0x3
 func f(v int) {
        switch v {
        case zero, one:
-       case two, one: // ERROR "previous case at LINE-1|duplicate case in switch"
+       case two, one: // ERROR "previous case at LINE-1|duplicate case .*in.* switch"
 
        case three:
-       case 3: // ERROR "previous case at LINE-1|duplicate case in switch"
-       case iii: // ERROR "previous case at LINE-2|duplicate case in switch"
+       case 3: // ERROR "previous case at LINE-1|duplicate case .*in.* switch"
+       case iii: // ERROR "previous case at LINE-2|duplicate case .*in.* switch"
        }
 }
 
@@ -31,7 +31,7 @@ const b = "b"
 var _ = map[string]int{
        "a": 0,
        b:   1,
-       "a": 2, // ERROR "previous key at LINE-2|duplicate key in map literal"
-       "b": 3, // GC_ERROR "previous key at LINE-2"
-       "b": 4, // GC_ERROR "previous key at LINE-3"
+       "a": 2, // ERROR "previous key at LINE-2|duplicate key.*in map literal"
+       "b": 3, // GC_ERROR "previous key at LINE-2|duplicate key.*in map literal"
+       "b": 4, // GC_ERROR "previous key at LINE-3|duplicate key.*in map literal"
 }
index 30d132683a981a4d464c2b9666f7fca55f5e69c8..f49c6152e0c2b5e50f0669e09948b88cb719eafa 100644 (file)
@@ -11,46 +11,46 @@ package p
 
 func f() {
        var a [10]int
-       _ = a[-1]  // ERROR "invalid array index -1|index out of bounds"
-       _ = a[-1:] // ERROR "invalid slice index -1|index out of bounds"
-       _ = a[:-1] // ERROR "invalid slice index -1|index out of bounds"
-       _ = a[10]  // ERROR "invalid array index 10|index out of bounds"
+       _ = a[-1]  // ERROR "invalid array index -1|index out of bounds|must not be negative"
+       _ = a[-1:] // ERROR "invalid slice index -1|index out of bounds|must not be negative"
+       _ = a[:-1] // ERROR "invalid slice index -1|index out of bounds|must not be negative"
+       _ = a[10]  // ERROR "invalid array index 10|index .*out of bounds"
        _ = a[9:10]
        _ = a[10:10]
-       _ = a[9:12]            // ERROR "invalid slice index 12|index out of bounds"
-       _ = a[11:12]           // ERROR "invalid slice index 11|index out of bounds"
-       _ = a[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow" "invalid slice index 1 << 100|index out of bounds"
+       _ = a[9:12]            // ERROR "invalid slice index 12|index .*out of bounds"
+       _ = a[11:12]           // ERROR "invalid slice index 11|index .*out of bounds"
+       _ = a[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow|invalid slice index 1 << 100|index out of bounds"
 
        var s []int
-       _ = s[-1]  // ERROR "invalid slice index -1|index out of bounds"
-       _ = s[-1:] // ERROR "invalid slice index -1|index out of bounds"
-       _ = s[:-1] // ERROR "invalid slice index -1|index out of bounds"
+       _ = s[-1]  // ERROR "invalid slice index -1|index .*out of bounds|must not be negative"
+       _ = s[-1:] // ERROR "invalid slice index -1|index .*out of bounds|must not be negative"
+       _ = s[:-1] // ERROR "invalid slice index -1|index .*out of bounds|must not be negative"
        _ = s[10]
        _ = s[9:10]
        _ = s[10:10]
        _ = s[9:12]
        _ = s[11:12]
-       _ = s[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow" "invalid slice index 1 << 100|index out of bounds"
+       _ = s[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow|invalid slice index 1 << 100|index out of bounds"
 
        const c = "foofoofoof"
-       _ = c[-1]  // ERROR "invalid string index -1|index out of bounds"
-       _ = c[-1:] // ERROR "invalid slice index -1|index out of bounds"
-       _ = c[:-1] // ERROR "invalid slice index -1|index out of bounds"
-       _ = c[10]  // ERROR "invalid string index 10|index out of bounds"
+       _ = c[-1]  // ERROR "invalid string index -1|index out of bounds|must not be negative"
+       _ = c[-1:] // ERROR "invalid slice index -1|index out of bounds|must not be negative"
+       _ = c[:-1] // ERROR "invalid slice index -1|index out of bounds|must not be negative"
+       _ = c[10]  // ERROR "invalid string index 10|index .*out of bounds"
        _ = c[9:10]
        _ = c[10:10]
-       _ = c[9:12]            // ERROR "invalid slice index 12|index out of bounds"
-       _ = c[11:12]           // ERROR "invalid slice index 11|index out of bounds"
-       _ = c[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow" "invalid slice index 1 << 100|index out of bounds"
+       _ = c[9:12]            // ERROR "invalid slice index 12|index .*out of bounds"
+       _ = c[11:12]           // ERROR "invalid slice index 11|index .*out of bounds"
+       _ = c[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow|invalid slice index 1 << 100|index out of bounds"
 
        var t string
-       _ = t[-1]  // ERROR "invalid string index -1|index out of bounds"
-       _ = t[-1:] // ERROR "invalid slice index -1|index out of bounds"
-       _ = t[:-1] // ERROR "invalid slice index -1|index out of bounds"
+       _ = t[-1]  // ERROR "invalid string index -1|index out of bounds|must not be negative"
+       _ = t[-1:] // ERROR "invalid slice index -1|index out of bounds|must not be negative"
+       _ = t[:-1] // ERROR "invalid slice index -1|index out of bounds|must not be negative"
        _ = t[10]
        _ = t[9:10]
        _ = t[10:10]
        _ = t[9:12]
        _ = t[11:12]
-       _ = t[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow" "invalid slice index 1 << 100|index out of bounds"
+       _ = t[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow|invalid slice index 1 << 100|index out of bounds"
 }
index f91bd2c0fbe1b98607bd608fdf87602120bf07b7..c3d9b61ecb654ad12d78ab67639c5aa4e280abae 100644 (file)
@@ -9,5 +9,5 @@
 package main
 
 func main() {
-       _ = [...]int(4) // ERROR "\[\.\.\.\].*outside of array literal"
+       _ = [...]int(4) // ERROR "\[\.\.\.\].*outside of array literal|invalid use of \[\.\.\.\] array"
 }
index 7e2cffa5dd8af79218f9eee978cd34cc773fb1a7..1217106fca4db57046225ec3b0e982a74460c656 100644 (file)
@@ -4,6 +4,6 @@
 
 package p
 
-import "fmt" // ERROR "fmt redeclared|imported"
+import "fmt" // GCCGO_ERROR "fmt redeclared|imported"
 
 var _ = fmt.Printf
index 895fc342ba139f9ad64e53a769b713794d84a70a..1a67153771fa64fc8d11c54ed66999a0d7c65853 100644 (file)
@@ -4,4 +4,4 @@
 
 package p
 
-func fmt() {}
+func fmt() {} // GC_ERROR "fmt already declared through import of package"
index fcfab7236a5edc09150534c9091e796fe3e73b9f..b292d66ff162b84d2e8ac7b4cd444e582fdf962a 100644 (file)
@@ -10,6 +10,6 @@ package main
 
 import "unsafe"
 
-var x struct {
-       a [unsafe.Sizeof(x.a)]int // ERROR "array bound|typechecking loop|invalid expression"
+var x struct { // GC_ERROR "initialization loop for x"
+       a [unsafe.Sizeof(x.a)]int // GCCGO_ERROR "array bound|typechecking loop|invalid expression"
 }
index 20a62ee9633307db8452281d4ab63f0f9f740eef..139408eb79099151055d2bc7d1b8e72cd245aa90 100644 (file)
@@ -8,6 +8,6 @@
 
 package main
 
-var y struct {
-       d [len(y.d)]int // ERROR "array bound|typechecking loop|invalid array"
+var y struct { // GC_ERROR "initialization loop for y"
+       d [len(y.d)]int // GCCGO_ERROR "array bound|typechecking loop|invalid array"
 }
index f633b1cf89ec7675b2d46b45f4a40498eddc37e3..94481597ee1b198a9c076ae521ca36fe4e7d6d32 100644 (file)
@@ -8,6 +8,6 @@
 
 package main
 
-var z struct {
-       e [cap(z.e)]int // ERROR "array bound|typechecking loop|invalid array"
+var z struct { // GC_ERROR "initialization loop for z"
+       e [cap(z.e)]int // GCCGO_ERROR "array bound|typechecking loop|invalid array"
 }
index 141d675246568083467f96300c641b4cf066517a..62d465930a430490f6757a190a6d08d1b5a3f682 100644 (file)
@@ -10,6 +10,6 @@ package main
 
 import "unsafe"
 
-var x struct {
-       b [unsafe.Offsetof(x.b)]int // ERROR "array bound|typechecking loop|invalid array"
+var x struct { // GC_ERROR "initialization loop for x"
+       b [unsafe.Offsetof(x.b)]int // GCCGO_ERROR "array bound|typechecking loop|invalid array"
 }
index c13194ca63cd9b7f52cfb57a5922f94cf26b6636..150df074edad4546bfb32ad609e437563ad80145 100644 (file)
@@ -10,6 +10,6 @@ package main
 
 import "unsafe"
 
-var x struct {
-       c [unsafe.Alignof(x.c)]int // ERROR "array bound|typechecking loop|invalid array"
+var x struct { // GC_ERROR "initialization loop for x"
+       c [unsafe.Alignof(x.c)]int // GCCGO_ERROR "array bound|typechecking loop|invalid array"
 }
index 2433b5f2ad2b479a5346a721289f4e140dc2a234..294ef3a46b23635bd6229062cf09f62310a29f2f 100644 (file)
@@ -9,11 +9,11 @@
 
 package main
 
-import "bufio" // GCCGO_ERROR "previous|not used"
+import "bufio" // ERROR "previous|not used"
 import bufio "os"      // ERROR "redeclared|redefinition|incompatible" "imported and not used"
 
 import (
-       "fmt"   // GCCGO_ERROR "previous|not used"
+       "fmt"   // ERROR "previous|not used"
        fmt "math"      // ERROR "redeclared|redefinition|incompatible" "imported and not used: \x22math\x22 as fmt"
        . "math"        // GC_ERROR "imported and not used: \x22math\x22$"
 )
index c19280f0e0bc3b1ddb7d38a9f3e0d77473102ded..17c7dd4817388a5ba655542463fdc2234cb12823 100644 (file)
@@ -34,5 +34,6 @@ import "\xFFFD"   // ERROR "import path"
 import `\xFFFD`   // ERROR "import path"
 
 // Invalid local imports.
-import "/foo"  // ERROR "import path cannot be absolute path"
-import "c:/foo"  // ERROR "import path contains invalid character"
+// types2 adds extra "not used" error.
+import "/foo"  // ERROR "import path cannot be absolute path|not used"
+import "c:/foo"  // ERROR "import path contains invalid character|invalid character"
index 5e2e9a91a0b2fd75b3ad69014a77dac8de3502e8..aae740da38ffe6838ddf5a85d318aec23a77e111 100644 (file)
@@ -18,24 +18,24 @@ type T struct {
 }
 
 var x = 1
-var a1 = S { 0, X: 1 } // ERROR "mixture|undefined"
-var a2 = S { Y: 3, Z: 2, Y: 3 } // ERROR "duplicate"
-var a3 = T { S{}, 2, 3, 4, 5, 6 }      // ERROR "convert|too many"
-var a4 = [5]byte{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }      // ERROR "index|too many"
-var a5 = []byte { x: 2 }       // ERROR "index"
-var a6 = []byte{1: 1, 2: 2, 1: 3}      // ERROR "duplicate"
+var a1 = S{0, X: 1}                             // ERROR "mixture|undefined" "too few values"
+var a2 = S{Y: 3, Z: 2, Y: 3}                    // ERROR "duplicate"
+var a3 = T{S{}, 2, 3, 4, 5, 6}                  // ERROR "convert|too many"
+var a4 = [5]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} // ERROR "index|too many"
+var a5 = []byte{x: 2}                           // ERROR "index"
+var a6 = []byte{1: 1, 2: 2, 1: 3}               // ERROR "duplicate"
 
-var ok1 = S { }        // should be ok
-var ok2 = T { S: ok1 } // should be ok
+var ok1 = S{}       // should be ok
+var ok2 = T{S: ok1} // should be ok
 
 // These keys can be computed at compile time but they are
 // not constants as defined by the spec, so they do not trigger
 // compile-time errors about duplicate key values.
 // See issue 4555.
 
-type Key struct {X, Y int}
+type Key struct{ X, Y int }
 
 var _ = map[Key]string{
-       Key{1,2}: "hello",
-       Key{1,2}: "world",
+       Key{1, 2}: "hello",
+       Key{1, 2}: "world",
 }
index 37be958959f97a355aeba804dd8cc0fd99131e1d..278d5efce93345656ba89b4856420649a6c11a49 100644 (file)
@@ -350,25 +350,25 @@ func (t *test) initExpectFail(hasGFlag bool) {
                return
        }
 
-       if t.glevel == 0 && !hasGFlag && !unifiedEnabled {
-               // tests should always pass when run w/o types2 (i.e., using the
-               // legacy typechecker, option -G=0).
-               return
-       }
+       var failureSets []map[string]bool
 
-       failureSets := []map[string]bool{types2Failures}
+       if t.glevel == 0 && !hasGFlag && !unifiedEnabled {
+               failureSets = append(failureSets, g0Failures)
+       } else {
+               failureSets = append(failureSets, types2Failures)
 
-       // Note: gccgo supports more 32-bit architectures than this, but
-       // hopefully the 32-bit failures are fixed before this matters.
-       switch goarch {
-       case "386", "arm", "mips", "mipsle":
-               failureSets = append(failureSets, types2Failures32Bit)
-       }
+               // Note: gccgo supports more 32-bit architectures than this, but
+               // hopefully the 32-bit failures are fixed before this matters.
+               switch goarch {
+               case "386", "arm", "mips", "mipsle":
+                       failureSets = append(failureSets, types2Failures32Bit)
+               }
 
-       if unifiedEnabled {
-               failureSets = append(failureSets, unifiedFailures)
-       } else {
-               failureSets = append(failureSets, g3Failures)
+               if unifiedEnabled {
+                       failureSets = append(failureSets, unifiedFailures)
+               } else {
+                       failureSets = append(failureSets, g3Failures)
+               }
        }
 
        filename := strings.Replace(t.goFileName(), "\\", "/", -1) // goFileName() uses \ on Windows
@@ -2115,47 +2115,15 @@ func overlayDir(dstRoot, srcRoot string) error {
 // List of files that the compiler cannot errorcheck with the new typechecker (compiler -G option).
 // Temporary scaffolding until we pass all the tests at which point this map can be removed.
 var types2Failures = setOf(
-       "import1.go",      // types2 reports extra errors
-       "import6.go",      // issue #43109
-       "initializerr.go", // types2 reports extra errors
-       "notinheap.go",    // types2 doesn't report errors about conversions that are invalid due to //go:notinheap
-       "shift1.go",       // mostly just different wording, but reports two new errors.
-       "typecheck.go",    // invalid function is not causing errors when called
-
-       "fixedbugs/bug176.go", // types2 reports all errors (pref: types2)
-       "fixedbugs/bug195.go", // types2 reports slightly different (but correct) bugs
-       "fixedbugs/bug228.go", // types2 doesn't run when there are syntax errors
-       "fixedbugs/bug231.go", // types2 bug? (same error reported twice)
-       "fixedbugs/bug255.go", // types2 reports extra errors
-       "fixedbugs/bug388.go", // types2 not run due to syntax errors
-       "fixedbugs/bug412.go", // types2 produces a follow-on error
-
-       "fixedbugs/issue10700.go",  // types2 reports ok hint, but does not match regexp
-       "fixedbugs/issue11590.go",  // types2 doesn't report a follow-on error (pref: types2)
-       "fixedbugs/issue11610.go",  // types2 not run after syntax errors
-       "fixedbugs/issue11614.go",  // types2 reports an extra error
-       "fixedbugs/issue14520.go",  // missing import path error by types2
-       "fixedbugs/issue17038.go",  // types2 doesn't report a follow-on error (pref: types2)
-       "fixedbugs/issue18331.go",  // missing error about misuse of //go:noescape (irgen needs code from noder)
-       "fixedbugs/issue18419.go",  // types2 reports no field or method member, but should say unexported
-       "fixedbugs/issue19012.go",  // multiple errors on same line
-       "fixedbugs/issue20233.go",  // types2 reports two instead of one error (pref: compiler)
-       "fixedbugs/issue20245.go",  // types2 reports two instead of one error (pref: compiler)
-       "fixedbugs/issue21979.go",  // types2 doesn't report a follow-on error (pref: types2)
-       "fixedbugs/issue23732.go",  // types2 reports different (but ok) line numbers
-       "fixedbugs/issue25958.go",  // types2 doesn't report a follow-on error (pref: types2)
-       "fixedbugs/issue28079b.go", // types2 reports follow-on errors
-       "fixedbugs/issue28268.go",  // types2 reports follow-on errors
-       "fixedbugs/issue31053.go",  // types2 reports "unknown field" instead of "cannot refer to unexported field"
-       "fixedbugs/issue33460.go",  // types2 reports alternative positions in separate error
-       "fixedbugs/issue4232.go",   // types2 reports (correct) extra errors
-       "fixedbugs/issue4452.go",   // types2 reports (correct) extra errors
-       "fixedbugs/issue4510.go",   // types2 reports different (but ok) line numbers
-       "fixedbugs/issue7525b.go",  // types2 reports init cycle error on different line - ok otherwise
-       "fixedbugs/issue7525c.go",  // types2 reports init cycle error on different line - ok otherwise
-       "fixedbugs/issue7525d.go",  // types2 reports init cycle error on different line - ok otherwise
-       "fixedbugs/issue7525e.go",  // types2 reports init cycle error on different line - ok otherwise
-       "fixedbugs/issue7525.go",   // types2 reports init cycle error on different line - ok otherwise
+       "notinheap.go",            // types2 doesn't report errors about conversions that are invalid due to //go:notinheap
+       "shift1.go",               // types2 reports two new errors which are probably not right
+       "fixedbugs/issue10700.go", // types2 should give hint about ptr to interface
+       "fixedbugs/issue18331.go", // missing error about misuse of //go:noescape (irgen needs code from noder)
+       "fixedbugs/issue18419.go", // types2 reports no field or method member, but should say unexported
+       "fixedbugs/issue20233.go", // types2 reports two instead of one error (pref: -G=0)
+       "fixedbugs/issue20245.go", // types2 reports two instead of one error (pref: -G=0)
+       "fixedbugs/issue28268.go", // types2 reports follow-on errors (pref: -G=0)
+       "fixedbugs/issue31053.go", // types2 reports "unknown field" instead of "cannot refer to unexported field"
 )
 
 var types2Failures32Bit = setOf(
@@ -2168,6 +2136,29 @@ var g3Failures = setOf(
        "typeparam/nested.go", // -G=3 doesn't support function-local types with generics
 )
 
+// In all of these cases, -G=0 reports reasonable errors, but either -G=0 or types2
+// report extra errors, so we can't match correctly on both. We now set the patterns
+// to match correctly on all the types2 errors.
+var g0Failures = setOf(
+       "import1.go",      // types2 reports extra errors
+       "initializerr.go", // types2 reports extra error
+       "typecheck.go",    // types2 reports extra error at function call
+
+       "fixedbugs/bug176.go", // types2 reports all errors (pref: types2)
+       "fixedbugs/bug195.go", // types2 reports slight different errors, and an extra error
+       "fixedbugs/bug412.go", // types2 produces a follow-on error
+
+       "fixedbugs/issue11614.go", // types2 reports an extra error
+       "fixedbugs/issue17038.go", // types2 doesn't report a follow-on error (pref: types2)
+       "fixedbugs/issue23732.go", // types2 reports different (but ok) line numbers
+       "fixedbugs/issue4510.go",  // types2 reports different (but ok) line numbers
+       "fixedbugs/issue7525b.go", // types2 reports init cycle error on different line - ok otherwise
+       "fixedbugs/issue7525c.go", // types2 reports init cycle error on different line - ok otherwise
+       "fixedbugs/issue7525d.go", // types2 reports init cycle error on different line - ok otherwise
+       "fixedbugs/issue7525e.go", // types2 reports init cycle error on different line - ok otherwise
+       "fixedbugs/issue7525.go",  // types2 reports init cycle error on different line - ok otherwise
+)
+
 var unifiedFailures = setOf(
        "closure3.go",  // unified IR numbers closures differently than -d=inlfuncswithclosures
        "escape4.go",   // unified IR can inline f5 and f6; test doesn't expect this
index 4c55d2edcb5015bd2e1689099aa57167e26eb813..f822ae98ef3237db32e232af8e4c2b20ea6690bd 100644 (file)
@@ -17,6 +17,6 @@ func mine(int b) int { // ERROR "undefined.*b"
 }
 
 func main() {
-       mine()     // GCCGO_ERROR "not enough arguments"
+       mine()     // ERROR "not enough arguments"
        c = mine() // ERROR "undefined.*c|not enough arguments"
 }