---
doc/go1.16.html | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 46 insertions(+), 3 deletions(-)
diff --git a/doc/go1.16.html b/doc/go1.16.html
index 44d9707c16..e0187effd7 100644
--- a/doc/go1.16.html
+++ b/doc/go1.16.html
@@ -283,12 +283,55 @@ Do not send CLs removing the interior tags from such phrases.
Vet
-
- TODO
+
New warning for invalid testing.T use in
+goroutines
-
+
+ The vet tool now warns about invalid calls to the testing.T
+ method Fatal from within a goroutine created during the test.
+ This also warns on calls to Fatalf, FailNow, and
+ Skip{,f,Now} methods on testing.T tests or
+ testing.B benchmarks.
+
+ Calls to these methods stop the execution of the created goroutine and not
+ the Test* or Benchmark* function. So these are
+ required to be called by the goroutine
+ running the test or benchmark function. For example:
+
+
+
+func TestFoo(t *testing.T) {
+ go func() {
+ if condition() {
+ t.Fatal("oops") // This exits the inner func instead of TestFoo.
+ }
+ ...
+ }()
+}
+
+
+
+ Code calling t.Fatal (or a similar method) from a created
+ goroutine should be rewritten to signal the test failure using
+ t.Error and exit the goroutine early using an alternative
+ method, such as using a return statement. The previous example
+ could be rewritten as:
+
+
+
+func TestFoo(t *testing.T) {
+ go func() {
+ if condition() {
+ t.Error("oops")
+ return
+ }
+ ...
+ }()
+}
+
+
The vet tool now warns about amd64 assembly that clobbers the BP
register (the frame pointer) without saving and restoring it,
From e012d0dc34e0c182aed605347fb19c6980b3f8bd Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor
Date: Thu, 10 Dec 2020 15:01:20 -0800
Subject: [PATCH 13/66] syscall: drop references to Unix epoch in
Timeval/Timespec docs
The various conversion functions just change the format of time values.
They don't use the Unix epoch. Although in practice the values are often
times since the Unix epoch, they aren't always, so referring to the
epoch can be confusing.
Fixes #43010
Change-Id: I640d665f0d2017f0974db05d70858037c7c91eda
Reviewed-on: https://go-review.googlesource.com/c/go/+/277073
Trust: Ian Lance Taylor
Run-TryBot: Ian Lance Taylor
Reviewed-by: Brad Fitzpatrick
TryBot-Result: Go Bot
---
src/syscall/syscall.go | 10 ++++------
src/syscall/timestruct.go | 12 ++++--------
2 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/src/syscall/syscall.go b/src/syscall/syscall.go
index 2e7a3ae5f2..91173033ee 100644
--- a/src/syscall/syscall.go
+++ b/src/syscall/syscall.go
@@ -77,24 +77,22 @@ func BytePtrFromString(s string) (*byte, error) {
// See mksyscall.pl.
var _zero uintptr
-// Unix returns ts as the number of seconds and nanoseconds elapsed since the
-// Unix epoch.
+// Unix returns the time stored in ts as seconds plus nanoseconds.
func (ts *Timespec) Unix() (sec int64, nsec int64) {
return int64(ts.Sec), int64(ts.Nsec)
}
-// Unix returns tv as the number of seconds and nanoseconds elapsed since the
-// Unix epoch.
+// Unix returns the time stored in tv as seconds plus nanoseconds.
func (tv *Timeval) Unix() (sec int64, nsec int64) {
return int64(tv.Sec), int64(tv.Usec) * 1000
}
-// Nano returns ts as the number of nanoseconds elapsed since the Unix epoch.
+// Nano returns the time stored in ts as nanoseconds.
func (ts *Timespec) Nano() int64 {
return int64(ts.Sec)*1e9 + int64(ts.Nsec)
}
-// Nano returns tv as the number of nanoseconds elapsed since the Unix epoch.
+// Nano returns the time stored in tv as nanoseconds.
func (tv *Timeval) Nano() int64 {
return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000
}
diff --git a/src/syscall/timestruct.go b/src/syscall/timestruct.go
index 682c68cf9b..bca51df08d 100644
--- a/src/syscall/timestruct.go
+++ b/src/syscall/timestruct.go
@@ -6,12 +6,10 @@
package syscall
-// TimespecToNsec converts a Timespec value into a number of
-// nanoseconds since the Unix epoch.
+// TimespecToNSec returns the time stored in ts as nanoseconds.
func TimespecToNsec(ts Timespec) int64 { return ts.Nano() }
-// NsecToTimespec takes a number of nanoseconds since the Unix epoch
-// and returns the corresponding Timespec value.
+// NsecToTimespec converts a number of nanoseconds into a Timespec.
func NsecToTimespec(nsec int64) Timespec {
sec := nsec / 1e9
nsec = nsec % 1e9
@@ -22,12 +20,10 @@ func NsecToTimespec(nsec int64) Timespec {
return setTimespec(sec, nsec)
}
-// TimevalToNsec converts a Timeval value into a number of nanoseconds
-// since the Unix epoch.
+// TimevalToNsec returns the time stored in tv as nanoseconds.
func TimevalToNsec(tv Timeval) int64 { return tv.Nano() }
-// NsecToTimeval takes a number of nanoseconds since the Unix epoch
-// and returns the corresponding Timeval value.
+// NsecToTimeval converts a number of nanoseconds into a Timeval.
func NsecToTimeval(nsec int64) Timeval {
nsec += 999 // round up to microsecond
usec := nsec % 1e9 / 1e3
From 58e381b0b22352dda355f6d95fa101b773766c72 Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor
Date: Thu, 10 Dec 2020 22:24:21 -0800
Subject: [PATCH 14/66] cmd/vet: vendor in x/tools, update structtag vet check
For #40281
Fixes #43083
Change-Id: I50cb4db916587a6660c7f6e71f41f02334081510
Reviewed-on: https://go-review.googlesource.com/c/go/+/277076
Trust: Ian Lance Taylor
Run-TryBot: Ian Lance Taylor
Reviewed-by: Dmitri Shuralyov
TryBot-Result: Go Bot
---
src/cmd/go.mod | 2 +-
src/cmd/go.sum | 4 +-
.../go/analysis/passes/structtag/structtag.go | 98 +++++++++++--------
src/cmd/vendor/modules.txt | 2 +-
4 files changed, 62 insertions(+), 44 deletions(-)
diff --git a/src/cmd/go.mod b/src/cmd/go.mod
index c7d43873ef..031b8d4ab7 100644
--- a/src/cmd/go.mod
+++ b/src/cmd/go.mod
@@ -8,5 +8,5 @@ require (
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897
golang.org/x/mod v0.4.0
golang.org/x/sys v0.0.0-20201204225414-ed752295db88 // indirect
- golang.org/x/tools v0.0.0-20201208211828-de58e7c01d49
+ golang.org/x/tools v0.0.0-20201211025543-abf6a1d87e11
)
diff --git a/src/cmd/go.sum b/src/cmd/go.sum
index 30edf77282..2fde9445f6 100644
--- a/src/cmd/go.sum
+++ b/src/cmd/go.sum
@@ -31,8 +31,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20201208211828-de58e7c01d49 h1:K1QAOVIWIvmQ66F1Z3AEa9Wzp0bj+xU3YzLkvROk2Ds=
-golang.org/x/tools v0.0.0-20201208211828-de58e7c01d49/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.0.0-20201211025543-abf6a1d87e11 h1:9j/upNXDRpADUw2RpUfJ7E7GHtfhDih62kX6JM8vs2c=
+golang.org/x/tools v0.0.0-20201211025543-abf6a1d87e11/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go
index f0b15051c5..02555648a0 100644
--- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go
+++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go
@@ -207,12 +207,12 @@ var (
)
// validateStructTag parses the struct tag and returns an error if it is not
-// in the canonical format, which is a space-separated list of key:"value"
-// settings. The value may contain spaces.
+// in the canonical format, as defined by reflect.StructTag.
func validateStructTag(tag string) error {
// This code is based on the StructTag.Get code in package reflect.
n := 0
+ var keys []string
for ; tag != ""; n++ {
if n > 0 && tag != "" && tag[0] != ' ' {
// More restrictive than reflect, but catches likely mistakes
@@ -240,14 +240,27 @@ func validateStructTag(tag string) error {
if i == 0 {
return errTagKeySyntax
}
- if i+1 >= len(tag) || tag[i] != ':' {
+ if i+1 >= len(tag) || tag[i] < ' ' || tag[i] == 0x7f {
return errTagSyntax
}
- if tag[i+1] != '"' {
+ key := tag[:i]
+ keys = append(keys, key)
+ tag = tag[i:]
+
+ // If we found a space char here - assume that we have a tag with
+ // multiple keys.
+ if tag[0] == ' ' {
+ continue
+ }
+
+ // Spaces were filtered above so we assume that here we have
+ // only valid tag value started with `:"`.
+ if tag[0] != ':' || tag[1] != '"' {
return errTagValueSyntax
}
- key := tag[:i]
- tag = tag[i+1:]
+
+ // Remove the colon leaving tag at the start of the quoted string.
+ tag = tag[1:]
// Scan quoted string to find value.
i = 1
@@ -263,51 +276,56 @@ func validateStructTag(tag string) error {
qvalue := tag[:i+1]
tag = tag[i+1:]
- value, err := strconv.Unquote(qvalue)
+ wholeValue, err := strconv.Unquote(qvalue)
if err != nil {
return errTagValueSyntax
}
- if !checkTagSpaces[key] {
- continue
- }
-
- switch key {
- case "xml":
- // If the first or last character in the XML tag is a space, it is
- // suspicious.
- if strings.Trim(value, " ") != value {
- return errTagValueSpace
- }
-
- // If there are multiple spaces, they are suspicious.
- if strings.Count(value, " ") > 1 {
- return errTagValueSpace
- }
-
- // If there is no comma, skip the rest of the checks.
- comma := strings.IndexRune(value, ',')
- if comma < 0 {
+ for _, key := range keys {
+ if !checkTagSpaces[key] {
continue
}
- // If the character before a comma is a space, this is suspicious.
- if comma > 0 && value[comma-1] == ' ' {
+ value := wholeValue
+ switch key {
+ case "xml":
+ // If the first or last character in the XML tag is a space, it is
+ // suspicious.
+ if strings.Trim(value, " ") != value {
+ return errTagValueSpace
+ }
+
+ // If there are multiple spaces, they are suspicious.
+ if strings.Count(value, " ") > 1 {
+ return errTagValueSpace
+ }
+
+ // If there is no comma, skip the rest of the checks.
+ comma := strings.IndexRune(value, ',')
+ if comma < 0 {
+ continue
+ }
+
+ // If the character before a comma is a space, this is suspicious.
+ if comma > 0 && value[comma-1] == ' ' {
+ return errTagValueSpace
+ }
+ value = value[comma+1:]
+ case "json":
+ // JSON allows using spaces in the name, so skip it.
+ comma := strings.IndexRune(value, ',')
+ if comma < 0 {
+ continue
+ }
+ value = value[comma+1:]
+ }
+
+ if strings.IndexByte(value, ' ') >= 0 {
return errTagValueSpace
}
- value = value[comma+1:]
- case "json":
- // JSON allows using spaces in the name, so skip it.
- comma := strings.IndexRune(value, ',')
- if comma < 0 {
- continue
- }
- value = value[comma+1:]
}
- if strings.IndexByte(value, ' ') >= 0 {
- return errTagValueSpace
- }
+ keys = keys[:0]
}
return nil
}
diff --git a/src/cmd/vendor/modules.txt b/src/cmd/vendor/modules.txt
index b549258cfa..4e47f41855 100644
--- a/src/cmd/vendor/modules.txt
+++ b/src/cmd/vendor/modules.txt
@@ -44,7 +44,7 @@ golang.org/x/mod/zip
golang.org/x/sys/internal/unsafeheader
golang.org/x/sys/unix
golang.org/x/sys/windows
-# golang.org/x/tools v0.0.0-20201208211828-de58e7c01d49
+# golang.org/x/tools v0.0.0-20201211025543-abf6a1d87e11
## explicit
golang.org/x/tools/go/analysis
golang.org/x/tools/go/analysis/internal/analysisflags
From e508c1c67b02dceea146ce3472c0f8ce9e60632c Mon Sep 17 00:00:00 2001
From: Joel Sing
Date: Tue, 8 Dec 2020 04:23:36 +1100
Subject: [PATCH 15/66] cmd/link/internal/loadelf: support additional ELF
relocations on mips64
LLVM on openbsd/mips64 generates R_MIPS_GOT_HI16 and R_MIPS_GOT_LO16 relocations,
so teach cmd/link/internal/loadelf about both of these.
Updates #43005
Change-Id: Ic45ea8b901d44dcbdbf355411ee434dcd7670a92
Reviewed-on: https://go-review.googlesource.com/c/go/+/275894
Trust: Joel Sing
Reviewed-by: Cherry Zhang
---
src/cmd/link/internal/loadelf/ldelf.go | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/cmd/link/internal/loadelf/ldelf.go b/src/cmd/link/internal/loadelf/ldelf.go
index db543a5e50..c698874b32 100644
--- a/src/cmd/link/internal/loadelf/ldelf.go
+++ b/src/cmd/link/internal/loadelf/ldelf.go
@@ -969,6 +969,8 @@ func relSize(arch *sys.Arch, pn string, elftype uint32) (uint8, error) {
case MIPS | uint32(elf.R_MIPS_HI16)<<16,
MIPS | uint32(elf.R_MIPS_LO16)<<16,
MIPS | uint32(elf.R_MIPS_GOT16)<<16,
+ MIPS | uint32(elf.R_MIPS_GOT_HI16)<<16,
+ MIPS | uint32(elf.R_MIPS_GOT_LO16)<<16,
MIPS | uint32(elf.R_MIPS_GPREL16)<<16,
MIPS | uint32(elf.R_MIPS_GOT_PAGE)<<16,
MIPS | uint32(elf.R_MIPS_JALR)<<16,
@@ -976,6 +978,8 @@ func relSize(arch *sys.Arch, pn string, elftype uint32) (uint8, error) {
MIPS64 | uint32(elf.R_MIPS_HI16)<<16,
MIPS64 | uint32(elf.R_MIPS_LO16)<<16,
MIPS64 | uint32(elf.R_MIPS_GOT16)<<16,
+ MIPS64 | uint32(elf.R_MIPS_GOT_HI16)<<16,
+ MIPS64 | uint32(elf.R_MIPS_GOT_LO16)<<16,
MIPS64 | uint32(elf.R_MIPS_GPREL16)<<16,
MIPS64 | uint32(elf.R_MIPS_GOT_PAGE)<<16,
MIPS64 | uint32(elf.R_MIPS_JALR)<<16,
From 1341a3decd00d1106efaa73c5ff4ffcabc4e6afd Mon Sep 17 00:00:00 2001
From: Michael Matloob
Date: Tue, 1 Dec 2020 21:45:49 -0500
Subject: [PATCH 16/66] cmd/go: add documentation for the -overlay flag
Also add -overlay to the Go 1.16 release notes.
For #40700
Fixes #39958
Fixes #42893
Change-Id: Ifd397549e368b255e7b8800986cfa0563a942af5
Reviewed-on: https://go-review.googlesource.com/c/go/+/274714
Trust: Michael Matloob
Run-TryBot: Michael Matloob
TryBot-Result: Go Bot
Reviewed-by: Bryan C. Mills
Reviewed-by: Jay Conrod
---
doc/go1.16.html | 14 ++++++++++++++
src/cmd/go/alldocs.go | 11 +++++++++++
src/cmd/go/internal/work/build.go | 11 +++++++++++
3 files changed, 36 insertions(+)
diff --git a/doc/go1.16.html b/doc/go1.16.html
index e0187effd7..2ff763f9b6 100644
--- a/doc/go1.16.html
+++ b/doc/go1.16.html
@@ -271,6 +271,20 @@ Do not send CLs removing the interior tags from such phrases.
but without the extra step.
+The -overlay flag
+
+
+ The -overlay flag specifies a JSON configuration file containing
+ a set of file path replacements. The -overlay flag may be used
+ with all build commands and go mod subcommands.
+ It is primarily intended to be used by editor tooling such as gopls to
+ understand the effects of unsaved changes to source files. The config file
+ maps actual file paths to replacement file paths and the go
+ command and its builds will run as if the actual file paths exist with the
+ contents given by the replacement file paths, or don't exist if the replacement
+ file paths are empty.
+
+
Cgo
diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go
index daa407197c..c4913ce695 100644
--- a/src/cmd/go/alldocs.go
+++ b/src/cmd/go/alldocs.go
@@ -164,6 +164,17 @@
// directory, but it is not accessed. When -modfile is specified, an
// alternate go.sum file is also used: its path is derived from the
// -modfile flag by trimming the ".mod" extension and appending ".sum".
+// -overlay file
+// read a JSON config file that provides an overlay for build operations.
+// The file is a JSON struct with a single field, named 'Replace', that
+// maps each disk file path (a string) to its backing file path, so that
+// a build will run as if the disk file path exists with the contents
+// given by the backing file paths, or as if the disk file path does not
+// exist if its backing file path is empty. Support for the -overlay flag
+// has some limitations:importantly, cgo files included from outside the
+// include path must be in the same directory as the Go package they are
+// included from, and overlays will not appear when binaries and tests are
+// run through go run and go test respectively.
// -pkgdir dir
// install and load all packages from dir instead of the usual locations.
// For example, when building with a non-standard configuration,
diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go
index 21b2289dff..be5532d7aa 100644
--- a/src/cmd/go/internal/work/build.go
+++ b/src/cmd/go/internal/work/build.go
@@ -124,6 +124,17 @@ and test commands:
directory, but it is not accessed. When -modfile is specified, an
alternate go.sum file is also used: its path is derived from the
-modfile flag by trimming the ".mod" extension and appending ".sum".
+ -overlay file
+ read a JSON config file that provides an overlay for build operations.
+ The file is a JSON struct with a single field, named 'Replace', that
+ maps each disk file path (a string) to its backing file path, so that
+ a build will run as if the disk file path exists with the contents
+ given by the backing file paths, or as if the disk file path does not
+ exist if its backing file path is empty. Support for the -overlay flag
+ has some limitations:importantly, cgo files included from outside the
+ include path must be in the same directory as the Go package they are
+ included from, and overlays will not appear when binaries and tests are
+ run through go run and go test respectively.
-pkgdir dir
install and load all packages from dir instead of the usual locations.
For example, when building with a non-standard configuration,
From 14305527f686ced0de8d08b3a62bd96fe6359481 Mon Sep 17 00:00:00 2001
From: Matthew Dempsky
Date: Thu, 10 Dec 2020 12:21:45 -0800
Subject: [PATCH 17/66] cmd/compile: fix select statement evaluation order
corner case
The Go spec requires that select case clauses be evaluated in order,
which is stricter than normal ordering semantics. cmd/compile handled
this correctly for send clauses, but was not correctly handling
receive clauses that involved bare variable references.
Discovered with @cuonglm.
Fixes #43111.
Change-Id: Iec93b6514dd771875b084ba49c15d7f4531b4a6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/277132
Trust: Matthew Dempsky
Run-TryBot: Matthew Dempsky
TryBot-Result: Go Bot
Reviewed-by: Cuong Manh Le
Reviewed-by: Keith Randall
---
src/cmd/compile/internal/gc/order.go | 2 +-
test/fixedbugs/issue43111.go | 70 ++++++++++++++++++++++++++++
2 files changed, 71 insertions(+), 1 deletion(-)
create mode 100644 test/fixedbugs/issue43111.go
diff --git a/src/cmd/compile/internal/gc/order.go b/src/cmd/compile/internal/gc/order.go
index 863de5b6c7..30e1535c09 100644
--- a/src/cmd/compile/internal/gc/order.go
+++ b/src/cmd/compile/internal/gc/order.go
@@ -891,7 +891,7 @@ func (o *Order) stmt(n *Node) {
// c is always evaluated; x and ok are only evaluated when assigned.
r.Right.Left = o.expr(r.Right.Left, nil)
- if r.Right.Left.Op != ONAME {
+ if !r.Right.Left.IsAutoTmp() {
r.Right.Left = o.copyExpr(r.Right.Left, r.Right.Left.Type, false)
}
diff --git a/test/fixedbugs/issue43111.go b/test/fixedbugs/issue43111.go
new file mode 100644
index 0000000000..76d7beb084
--- /dev/null
+++ b/test/fixedbugs/issue43111.go
@@ -0,0 +1,70 @@
+// run
+
+// Copyright 2020 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 ch chan int
+var x int
+
+func f() int {
+ close(ch)
+ ch = nil
+ return 0
+}
+
+func g() int {
+ ch = nil
+ x = 0
+ return 0
+}
+
+func main() {
+ var nilch chan int
+ var v int
+ var ok bool
+ _, _ = v, ok
+
+ ch = make(chan int)
+ select {
+ case <-ch:
+ case nilch <- f():
+ }
+
+ ch = make(chan int)
+ select {
+ case v = <-ch:
+ case nilch <- f():
+ }
+
+ ch = make(chan int)
+ select {
+ case v := <-ch: _ = v
+ case nilch <- f():
+ }
+
+ ch = make(chan int)
+ select {
+ case v, ok = <-ch:
+ case nilch <- f():
+ }
+
+ ch = make(chan int)
+ select {
+ case v, ok := <-ch: _, _ = v, ok
+ case nilch <- f():
+ }
+
+ ch1 := make(chan int, 1)
+ ch = ch1
+ x = 42
+ select {
+ case ch <- x:
+ case nilch <- g():
+ }
+ if got := <-ch1; got != 42 {
+ panic(got)
+ }
+}
From 41d8e61a6b9d8f9db912626eb2bbc535e929fefc Mon Sep 17 00:00:00 2001
From: Russ Cox
Date: Fri, 11 Dec 2020 13:32:14 -0500
Subject: [PATCH 18/66] doc: make clear that Go 1.4 is not required for
bootstrap
Go 1.4 does not work on some systems, including the most
recent versions of macOS. Make it clearer that that's not the only
way to bootstrap Go.
Change-Id: I7c03d6808e43bf26283a53eab2bb0b2dc4af73af
Reviewed-on: https://go-review.googlesource.com/c/go/+/277216
Trust: Russ Cox
Run-TryBot: Russ Cox
TryBot-Result: Go Bot
Reviewed-by: Ian Lance Taylor
---
doc/install-source.html | 71 ++++++++++++++++++++++++++---------------
1 file changed, 46 insertions(+), 25 deletions(-)
diff --git a/doc/install-source.html b/doc/install-source.html
index c6dc3aed43..f0a909263c 100644
--- a/doc/install-source.html
+++ b/doc/install-source.html
@@ -119,11 +119,26 @@ The Go toolchain is written in Go. To build it, you need a Go compiler installed
The scripts that do the initial build of the tools look for a "go" command
in $PATH, so as long as you have Go installed in your
system and configured in your $PATH, you are ready to build Go
-from source.
+from source.
Or if you prefer you can set $GOROOT_BOOTSTRAP to the
root of a Go installation to use to build the new Go toolchain;
$GOROOT_BOOTSTRAP/bin/go should be the go command to use.
+
+There are four possible ways to obtain a bootstrap toolchain:
+
+
+
+- Download a recent binary release of Go.
+
- Cross-compile a toolchain using a system with a working Go installation.
+
- Use gccgo.
+
- Compile a toolchain from Go 1.4, the last Go release with a compiler written in C.
+
+
+
+These approaches are detailed below.
+
+
Bootstrap toolchain from binary release
@@ -132,30 +147,6 @@ To use a binary release as a bootstrap toolchain, see
packaged Go distribution.
-Bootstrap toolchain from source
-
-
-To build a bootstrap toolchain from source, use
-either the git branch release-branch.go1.4 or
-go1.4-bootstrap-20171003.tar.gz,
-which contains the Go 1.4 source code plus accumulated fixes
-to keep the tools running on newer operating systems.
-(Go 1.4 was the last distribution in which the toolchain was written in C.)
-After unpacking the Go 1.4 source, cd to
-the src subdirectory, set CGO_ENABLED=0 in
-the environment, and run make.bash (or,
-on Windows, make.bat).
-
-
-
-Once the Go 1.4 source has been unpacked into your GOROOT_BOOTSTRAP directory,
-you must keep this git clone instance checked out to branch
-release-branch.go1.4. Specifically, do not attempt to reuse
-this git clone in the later step named "Fetch the repository." The go1.4
-bootstrap toolchain must be able to properly traverse the go1.4 sources
-that it assumes are present under this repository root.
-
-
Bootstrap toolchain from cross-compiled source
@@ -194,6 +185,36 @@ $ sudo update-alternatives --set go /usr/bin/go-5
$ GOROOT_BOOTSTRAP=/usr ./make.bash
+
Bootstrap toolchain from C source code
+
+
+To build a bootstrap toolchain from C source code, use
+either the git branch release-branch.go1.4 or
+go1.4-bootstrap-20171003.tar.gz,
+which contains the Go 1.4 source code plus accumulated fixes
+to keep the tools running on newer operating systems.
+(Go 1.4 was the last distribution in which the toolchain was written in C.)
+After unpacking the Go 1.4 source, cd to
+the src subdirectory, set CGO_ENABLED=0 in
+the environment, and run make.bash (or,
+on Windows, make.bat).
+
+
+
+Once the Go 1.4 source has been unpacked into your GOROOT_BOOTSTRAP directory,
+you must keep this git clone instance checked out to branch
+release-branch.go1.4. Specifically, do not attempt to reuse
+this git clone in the later step named "Fetch the repository." The go1.4
+bootstrap toolchain must be able to properly traverse the go1.4 sources
+that it assumes are present under this repository root.
+
+
+
+Note that Go 1.4 does not run on all systems that later versions of Go do.
+In particular, Go 1.4 does not support current versions of macOS.
+On such systems, the bootstrap toolchain must be obtained using one of the other methods.
+
+
Install Git, if needed
From 0a02371b0576964e81c3b40d328db9a3ef3b031b Mon Sep 17 00:00:00 2001
From: Cuong Manh Le
Date: Mon, 14 Dec 2020 09:45:44 +0700
Subject: [PATCH 19/66] cmd/compile: set correct type for OpIData
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Since CL 270057, there're many attempts to fix the expand_calls pass
with interface{}-typed. But all of them did not fix the root cause. The
main issue is during SSA conversion in gc/ssa.go, for empty interface
case, we make its type as n.Type, instead of BytePtr.
To fix these, we can just use BytePtr for now, since when itab fields
are treated as scalar.
No significal changes on compiler speed, size.
cmd/compile/internal/ssa
expandCalls.func6 9488 -> 9232 (-2.70%)
file before after Δ %
cmd/compile/internal/ssa.s 3992893 3992637 -256 -0.006%
total 20500447 20500191 -256 -0.001%
Fixes #43112
Updates #42784
Updates #42727
Updates #42568
Change-Id: I0b15d9434e0be5448453e61f98ef9c2d6cd93792
Reviewed-on: https://go-review.googlesource.com/c/go/+/276952
Trust: Cuong Manh Le
Run-TryBot: Cuong Manh Le
TryBot-Result: Go Bot
Reviewed-by: Keith Randall
---
src/cmd/compile/internal/gc/ssa.go | 4 +-
src/cmd/compile/internal/ssa/expand_calls.go | 8 +---
test/fixedbugs/issue43112.go | 41 ++++++++++++++++++++
3 files changed, 44 insertions(+), 9 deletions(-)
create mode 100644 test/fixedbugs/issue43112.go
diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go
index 65b9291b76..5b74754b53 100644
--- a/src/cmd/compile/internal/gc/ssa.go
+++ b/src/cmd/compile/internal/gc/ssa.go
@@ -5925,7 +5925,7 @@ func (s *state) dottype(n *Node, commaok bool) (res, resok *ssa.Value) {
// Load type out of itab, build interface with existing idata.
off := s.newValue1I(ssa.OpOffPtr, byteptr, int64(Widthptr), itab)
typ := s.load(byteptr, off)
- idata := s.newValue1(ssa.OpIData, n.Type, iface)
+ idata := s.newValue1(ssa.OpIData, byteptr, iface)
res = s.newValue2(ssa.OpIMake, n.Type, typ, idata)
return
}
@@ -5947,7 +5947,7 @@ func (s *state) dottype(n *Node, commaok bool) (res, resok *ssa.Value) {
bOk.AddEdgeTo(bEnd)
bFail.AddEdgeTo(bEnd)
s.startBlock(bEnd)
- idata := s.newValue1(ssa.OpIData, n.Type, iface)
+ idata := s.newValue1(ssa.OpIData, byteptr, iface)
res = s.newValue2(ssa.OpIMake, n.Type, s.variable(&typVar, byteptr), idata)
resok = cond
delete(s.vars, &typVar)
diff --git a/src/cmd/compile/internal/ssa/expand_calls.go b/src/cmd/compile/internal/ssa/expand_calls.go
index f266e49327..fbde19d94c 100644
--- a/src/cmd/compile/internal/ssa/expand_calls.go
+++ b/src/cmd/compile/internal/ssa/expand_calls.go
@@ -196,9 +196,6 @@ func expandCalls(f *Func) {
}
if leaf.Op == OpIData {
leafType = removeTrivialWrapperTypes(leaf.Type)
- if leafType.IsEmptyInterface() {
- leafType = typ.BytePtr
- }
}
aux := selector.Aux
auxInt := selector.AuxInt + offset
@@ -247,12 +244,9 @@ func expandCalls(f *Func) {
// i.e., the struct select is generated and remains in because it is not applied to an actual structure.
// The OpLoad was created to load the single field of the IData
// This case removes that StructSelect.
- if leafType != selector.Type && !selector.Type.IsEmptyInterface() { // empty interface for #42727
+ if leafType != selector.Type {
f.Fatalf("Unexpected Load as selector, leaf=%s, selector=%s\n", leaf.LongString(), selector.LongString())
}
- if selector.Type.IsEmptyInterface() {
- selector.Type = typ.BytePtr
- }
leaf.copyOf(selector)
for _, s := range namedSelects[selector] {
locs = append(locs, f.Names[s.locIndex])
diff --git a/test/fixedbugs/issue43112.go b/test/fixedbugs/issue43112.go
new file mode 100644
index 0000000000..e36627a015
--- /dev/null
+++ b/test/fixedbugs/issue43112.go
@@ -0,0 +1,41 @@
+// compile
+
+// Copyright 2020 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 Symbol interface{}
+
+type Value interface {
+ String() string
+}
+
+type Object interface {
+ String() string
+}
+
+type Scope struct {
+ outer *Scope
+ elems map[string]Object
+}
+
+func (s *Scope) findouter(name string) (*Scope, Object) {
+ return s.outer.findouter(name)
+}
+
+func (s *Scope) Resolve(name string) (sym Symbol) {
+ if _, obj := s.findouter(name); obj != nil {
+ sym = obj.(Symbol)
+ }
+ return
+}
+
+type ScopeName struct {
+ scope *Scope
+}
+
+func (n *ScopeName) Get(name string) (Value, error) {
+ return n.scope.Resolve(name).(Value), nil
+}
From 451b6b38fd3f87957c39fdb6572740f74ea27931 Mon Sep 17 00:00:00 2001
From: Jay Conrod
Date: Fri, 11 Dec 2020 16:45:28 -0500
Subject: [PATCH 20/66] cmd/go: refactor error reporting in internal/load
Replaced load.PackagesForBuild with a new function,
load.CheckPackageErrors. Callers should now call PackagesAndErrors,
then CheckPackageErrors for the same functionality.
Removed load.Packages. Callers should call base.Errorf and filter the
package list as needed.
This gives callers more flexibility in handling package load errors.
For #42638
Change-Id: Id75463ba695adc1ca3f8693ceb2c8978b74a3500
Reviewed-on: https://go-review.googlesource.com/c/go/+/277354
Run-TryBot: Jay Conrod
TryBot-Result: Go Bot
Trust: Jay Conrod
Reviewed-by: Bryan C. Mills
---
src/cmd/go/internal/fix/fix.go | 14 +++++++-
src/cmd/go/internal/get/get.go | 7 ++--
src/cmd/go/internal/list/list.go | 17 ++++++---
src/cmd/go/internal/load/pkg.go | 58 ++++++++++---------------------
src/cmd/go/internal/modget/get.go | 4 ++-
src/cmd/go/internal/test/test.go | 7 ++--
src/cmd/go/internal/vet/vet.go | 3 +-
src/cmd/go/internal/work/build.go | 11 +++---
8 files changed, 65 insertions(+), 56 deletions(-)
diff --git a/src/cmd/go/internal/fix/fix.go b/src/cmd/go/internal/fix/fix.go
index 825624fcbb..c7588c66d3 100644
--- a/src/cmd/go/internal/fix/fix.go
+++ b/src/cmd/go/internal/fix/fix.go
@@ -33,8 +33,20 @@ See also: go fmt, go vet.
}
func runFix(ctx context.Context, cmd *base.Command, args []string) {
+ pkgs := load.PackagesAndErrors(ctx, args)
+ w := 0
+ for _, pkg := range pkgs {
+ if pkg.Error != nil {
+ base.Errorf("%v", pkg.Error)
+ continue
+ }
+ pkgs[w] = pkg
+ w++
+ }
+ pkgs = pkgs[:w]
+
printed := false
- for _, pkg := range load.Packages(ctx, args) {
+ for _, pkg := range pkgs {
if modload.Enabled() && pkg.Module != nil && !pkg.Module.Main {
if !printed {
fmt.Fprintf(os.Stderr, "go: not fixing packages in dependency modules\n")
diff --git a/src/cmd/go/internal/get/get.go b/src/cmd/go/internal/get/get.go
index 268962eca8..94a42c4f73 100644
--- a/src/cmd/go/internal/get/get.go
+++ b/src/cmd/go/internal/get/get.go
@@ -180,13 +180,14 @@ func runGet(ctx context.Context, cmd *base.Command, args []string) {
// everything.
load.ClearPackageCache()
- pkgs := load.PackagesForBuild(ctx, args)
+ pkgs := load.PackagesAndErrors(ctx, args)
+ load.CheckPackageErrors(pkgs)
// Phase 3. Install.
if *getD {
// Download only.
- // Check delayed until now so that importPaths
- // and packagesForBuild have a chance to print errors.
+ // Check delayed until now so that downloadPaths
+ // and CheckPackageErrors have a chance to print errors.
return
}
diff --git a/src/cmd/go/internal/list/list.go b/src/cmd/go/internal/list/list.go
index 9af9dbb856..ce6f579c05 100644
--- a/src/cmd/go/internal/list/list.go
+++ b/src/cmd/go/internal/list/list.go
@@ -471,11 +471,18 @@ func runList(ctx context.Context, cmd *base.Command, args []string) {
}
load.IgnoreImports = *listFind
- var pkgs []*load.Package
- if *listE {
- pkgs = load.PackagesAndErrors(ctx, args)
- } else {
- pkgs = load.Packages(ctx, args)
+ pkgs := load.PackagesAndErrors(ctx, args)
+ if !*listE {
+ w := 0
+ for _, pkg := range pkgs {
+ if pkg.Error != nil {
+ base.Errorf("%v", pkg.Error)
+ continue
+ }
+ pkgs[w] = pkg
+ w++
+ }
+ pkgs = pkgs[:w]
base.ExitIfErrors()
}
diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go
index 6f95af4f7e..855f9698a2 100644
--- a/src/cmd/go/internal/load/pkg.go
+++ b/src/cmd/go/internal/load/pkg.go
@@ -2314,30 +2314,14 @@ func LoadImportWithFlags(path, srcDir string, parent *Package, stk *ImportStack,
// argument where needed.
var ModResolveTests bool
-// Packages returns the packages named by the
-// command line arguments 'args'. If a named package
-// cannot be loaded at all (for example, if the directory does not exist),
-// then packages prints an error and does not include that
-// package in the results. However, if errors occur trying
-// to load dependencies of a named package, the named
-// package is still returned, with p.Incomplete = true
-// and details in p.DepsErrors.
-func Packages(ctx context.Context, args []string) []*Package {
- var pkgs []*Package
- for _, pkg := range PackagesAndErrors(ctx, args) {
- if pkg.Error != nil {
- base.Errorf("%v", pkg.Error)
- continue
- }
- pkgs = append(pkgs, pkg)
- }
- return pkgs
-}
-
-// PackagesAndErrors is like 'packages' but returns a
-// *Package for every argument, even the ones that
-// cannot be loaded at all.
-// The packages that fail to load will have p.Error != nil.
+// PackagesAndErrors returns the packages named by the command line arguments
+// 'patterns'. If a named package cannot be loaded, PackagesAndErrors returns
+// a *Package with the Error field describing the failure. If errors are found
+// loading imported packages, the DepsErrors field is set. The Incomplete field
+// may be set as well.
+//
+// To obtain a flat list of packages, use PackageList.
+// To report errors loading packages, use ReportPackageErrors.
func PackagesAndErrors(ctx context.Context, patterns []string) []*Package {
ctx, span := trace.StartSpan(ctx, "load.PackagesAndErrors")
defer span.Done()
@@ -2427,20 +2411,9 @@ func PackagesAndErrors(ctx context.Context, patterns []string) []*Package {
return pkgs
}
-func setToolFlags(pkgs ...*Package) {
- for _, p := range PackageList(pkgs) {
- p.Internal.Asmflags = BuildAsmflags.For(p)
- p.Internal.Gcflags = BuildGcflags.For(p)
- p.Internal.Ldflags = BuildLdflags.For(p)
- p.Internal.Gccgoflags = BuildGccgoflags.For(p)
- }
-}
-
-// PackagesForBuild is like Packages but exits
-// if any of the packages or their dependencies have errors
-// (cannot be built).
-func PackagesForBuild(ctx context.Context, args []string) []*Package {
- pkgs := PackagesAndErrors(ctx, args)
+// CheckPackageErrors prints errors encountered loading pkgs and their
+// dependencies, then exits with a non-zero status if any errors were found.
+func CheckPackageErrors(pkgs []*Package) {
printed := map[*PackageError]bool{}
for _, pkg := range pkgs {
if pkg.Error != nil {
@@ -2475,8 +2448,15 @@ func PackagesForBuild(ctx context.Context, args []string) []*Package {
seen[pkg.ImportPath] = true
}
base.ExitIfErrors()
+}
- return pkgs
+func setToolFlags(pkgs ...*Package) {
+ for _, p := range PackageList(pkgs) {
+ p.Internal.Asmflags = BuildAsmflags.For(p)
+ p.Internal.Gcflags = BuildGcflags.For(p)
+ p.Internal.Ldflags = BuildLdflags.For(p)
+ p.Internal.Gccgoflags = BuildGccgoflags.For(p)
+ }
}
// GoFilesPackage creates a package for building a collection of Go files
diff --git a/src/cmd/go/internal/modget/get.go b/src/cmd/go/internal/modget/get.go
index e5f55879ee..8463ec4e9c 100644
--- a/src/cmd/go/internal/modget/get.go
+++ b/src/cmd/go/internal/modget/get.go
@@ -434,11 +434,13 @@ func runGet(ctx context.Context, cmd *base.Command, args []string) {
// directory.
if !*getD && len(pkgPatterns) > 0 {
work.BuildInit()
- pkgs := load.PackagesForBuild(ctx, pkgPatterns)
+ pkgs := load.PackagesAndErrors(ctx, pkgPatterns)
+ load.CheckPackageErrors(pkgs)
work.InstallPackages(ctx, pkgPatterns, pkgs)
// TODO(#40276): After Go 1.16, print a deprecation notice when building
// and installing main packages. 'go install pkg' or
// 'go install pkg@version' should be used instead.
+ // Give the specific argument to use if possible.
}
if !modload.HasModRoot() {
diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go
index e8a7aacb85..50fe2dbf39 100644
--- a/src/cmd/go/internal/test/test.go
+++ b/src/cmd/go/internal/test/test.go
@@ -595,7 +595,8 @@ func runTest(ctx context.Context, cmd *base.Command, args []string) {
work.VetFlags = testVet.flags
work.VetExplicit = testVet.explicit
- pkgs = load.PackagesForBuild(ctx, pkgArgs)
+ pkgs = load.PackagesAndErrors(ctx, pkgArgs)
+ load.CheckPackageErrors(pkgs)
if len(pkgs) == 0 {
base.Fatalf("no packages to test")
}
@@ -678,7 +679,9 @@ func runTest(ctx context.Context, cmd *base.Command, args []string) {
sort.Strings(all)
a := &work.Action{Mode: "go test -i"}
- for _, p := range load.PackagesForBuild(ctx, all) {
+ pkgs := load.PackagesAndErrors(ctx, all)
+ load.CheckPackageErrors(pkgs)
+ for _, p := range pkgs {
if cfg.BuildToolchainName == "gccgo" && p.Standard {
// gccgo's standard library packages
// can not be reinstalled.
diff --git a/src/cmd/go/internal/vet/vet.go b/src/cmd/go/internal/vet/vet.go
index b1bf806e46..4257c90c97 100644
--- a/src/cmd/go/internal/vet/vet.go
+++ b/src/cmd/go/internal/vet/vet.go
@@ -87,7 +87,8 @@ func runVet(ctx context.Context, cmd *base.Command, args []string) {
}
}
- pkgs := load.PackagesForBuild(ctx, pkgArgs)
+ pkgs := load.PackagesAndErrors(ctx, pkgArgs)
+ load.CheckPackageErrors(pkgs)
if len(pkgs) == 0 {
base.Fatalf("no packages to vet")
}
diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go
index be5532d7aa..1f99ed6e07 100644
--- a/src/cmd/go/internal/work/build.go
+++ b/src/cmd/go/internal/work/build.go
@@ -369,7 +369,8 @@ func runBuild(ctx context.Context, cmd *base.Command, args []string) {
var b Builder
b.Init()
- pkgs := load.PackagesForBuild(ctx, args)
+ pkgs := load.PackagesAndErrors(ctx, args)
+ load.CheckPackageErrors(pkgs)
explicitO := len(cfg.BuildO) > 0
@@ -399,7 +400,7 @@ func runBuild(ctx context.Context, cmd *base.Command, args []string) {
fmt.Fprint(os.Stderr, "go build: -i flag is deprecated\n")
}
- pkgs = omitTestOnly(pkgsFilter(load.Packages(ctx, args)))
+ pkgs = omitTestOnly(pkgsFilter(pkgs))
// Special case -o /dev/null by not writing at all.
if cfg.BuildO == os.DevNull {
@@ -583,7 +584,8 @@ func runInstall(ctx context.Context, cmd *base.Command, args []string) {
}
}
BuildInit()
- pkgs := load.PackagesForBuild(ctx, args)
+ pkgs := load.PackagesAndErrors(ctx, args)
+ load.CheckPackageErrors(pkgs)
if cfg.BuildI {
allGoroot := true
for _, pkg := range pkgs {
@@ -824,7 +826,8 @@ func installOutsideModule(ctx context.Context, args []string) {
// TODO(golang.org/issue/40276): don't report errors loading non-main packages
// matched by a pattern.
- pkgs := load.PackagesForBuild(ctx, patterns)
+ pkgs := load.PackagesAndErrors(ctx, patterns)
+ load.CheckPackageErrors(pkgs)
mainPkgs := make([]*load.Package, 0, len(pkgs))
mainCount := make([]int, len(patterns))
nonMainCount := make([]int, len(patterns))
From 64d8846aaef4b64d2649917581069c0ec30ca561 Mon Sep 17 00:00:00 2001
From: Jay Conrod
Date: Fri, 11 Dec 2020 16:45:39 -0500
Subject: [PATCH 21/66] cmd/go: print hint when 'go install' run without
version outside module
If 'go install' is invoked in module mode outside a module with a
package that could only be loaded from a module, it will now suggest
running 'go install pkg@latest'.
'go install' will still work outside a module on packages in std and
cmd, as well as .go files specified on the command line.
Fixes #42638
Change-Id: Ib0963935f028b7656178bc04a279b1114de35fbb
Reviewed-on: https://go-review.googlesource.com/c/go/+/277355
Run-TryBot: Jay Conrod
Trust: Jay Conrod
Reviewed-by: Bryan C. Mills
---
src/cmd/go/internal/work/build.go | 26 +++++++++++++++++++++-
src/cmd/go/testdata/script/mod_outside.txt | 5 ++++-
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go
index 1f99ed6e07..7f2617cf1c 100644
--- a/src/cmd/go/internal/work/build.go
+++ b/src/cmd/go/internal/work/build.go
@@ -583,8 +583,31 @@ func runInstall(ctx context.Context, cmd *base.Command, args []string) {
return
}
}
+
BuildInit()
pkgs := load.PackagesAndErrors(ctx, args)
+ if cfg.ModulesEnabled && !modload.HasModRoot() {
+ haveErrors := false
+ allMissingErrors := true
+ for _, pkg := range pkgs {
+ if pkg.Error == nil {
+ continue
+ }
+ haveErrors = true
+ if missingErr := (*modload.ImportMissingError)(nil); !errors.As(pkg.Error, &missingErr) {
+ allMissingErrors = false
+ break
+ }
+ }
+ if haveErrors && allMissingErrors {
+ latestArgs := make([]string, len(args))
+ for i := range args {
+ latestArgs[i] = args[i] + "@latest"
+ }
+ hint := strings.Join(latestArgs, " ")
+ base.Fatalf("go install: version is required when current directory is not in a module\n\tTry 'go install %s' to install the latest version", hint)
+ }
+ }
load.CheckPackageErrors(pkgs)
if cfg.BuildI {
allGoroot := true
@@ -598,6 +621,7 @@ func runInstall(ctx context.Context, cmd *base.Command, args []string) {
fmt.Fprint(os.Stderr, "go install: -i flag is deprecated\n")
}
}
+
InstallPackages(ctx, args, pkgs)
}
@@ -815,7 +839,7 @@ func installOutsideModule(ctx context.Context, args []string) {
// Load packages for all arguments. Ignore non-main packages.
// Print a warning if an argument contains "..." and matches no main packages.
- // PackagesForBuild already prints warnings for patterns that don't match any
+ // PackagesAndErrors already prints warnings for patterns that don't match any
// packages, so be careful not to double print.
matchers := make([]func(string) bool, len(patterns))
for i, p := range patterns {
diff --git a/src/cmd/go/testdata/script/mod_outside.txt b/src/cmd/go/testdata/script/mod_outside.txt
index 28379ab40d..8f01b5d242 100644
--- a/src/cmd/go/testdata/script/mod_outside.txt
+++ b/src/cmd/go/testdata/script/mod_outside.txt
@@ -189,13 +189,16 @@ exists $GOPATH/bin/printversion$GOEXE
# 'go install' should fail if a package argument must be resolved to a module.
! go install example.com/printversion
-stderr 'no required module provides package example.com/printversion: working directory is not part of a module'
+stderr '^go install: version is required when current directory is not in a module\n\tTry ''go install example.com/printversion@latest'' to install the latest version$'
# 'go install' should fail if a source file imports a package that must be
# resolved to a module.
! go install ./needmod/needmod.go
stderr 'needmod[/\\]needmod.go:10:2: no required module provides package example.com/version: working directory is not part of a module'
+# 'go install' should succeed with a package in GOROOT.
+go install cmd/addr2line
+! stderr .
# 'go run' with a verison should fail due to syntax.
! go run example.com/printversion@v1.0.0
From a58be734eacd832be27a021b8ffac323061212f2 Mon Sep 17 00:00:00 2001
From: Ruixin Bao
Date: Wed, 9 Dec 2020 13:55:37 -0800
Subject: [PATCH 22/66] cmd/compile: fix incorrect shift count type with s390x
rules
The type of the shift count must be an unsigned integer. Some s390x
rules for shift have their auxint type being int8. This results in a
compilation failure on s390x with an invalid operation when running
make.bash using older versions of go (e.g: go1.10.4).
This CL adds an auxint type of uint8 and changes the ops for shift and
rotate to use auxint with type uint8. The related rules are also
modified to address this change.
Fixes #43090
Change-Id: I594274b6e3d9b23092fc9e9f4b354870164f2f19
Reviewed-on: https://go-review.googlesource.com/c/go/+/277078
Reviewed-by: Keith Randall
Trust: Dmitri Shuralyov
---
src/cmd/compile/internal/ssa/check.go | 5 +
src/cmd/compile/internal/ssa/gen/S390X.rules | 24 +-
src/cmd/compile/internal/ssa/gen/S390XOps.go | 30 +-
src/cmd/compile/internal/ssa/gen/rulegen.go | 4 +-
src/cmd/compile/internal/ssa/op.go | 1 +
src/cmd/compile/internal/ssa/opGen.go | 14 +-
src/cmd/compile/internal/ssa/rewriteS390X.go | 290 +++++++++----------
src/cmd/internal/obj/s390x/rotate.go | 14 +-
src/cmd/internal/obj/s390x/rotate_test.go | 2 +-
9 files changed, 196 insertions(+), 188 deletions(-)
diff --git a/src/cmd/compile/internal/ssa/check.go b/src/cmd/compile/internal/ssa/check.go
index 5f5dfc328a..2dade7a88d 100644
--- a/src/cmd/compile/internal/ssa/check.go
+++ b/src/cmd/compile/internal/ssa/check.go
@@ -147,6 +147,11 @@ func checkFunc(f *Func) {
canHaveAuxInt = true
case auxInt128:
// AuxInt must be zero, so leave canHaveAuxInt set to false.
+ case auxUInt8:
+ if v.AuxInt != int64(uint8(v.AuxInt)) {
+ f.Fatalf("bad uint8 AuxInt value for %v", v)
+ }
+ canHaveAuxInt = true
case auxFloat32:
canHaveAuxInt = true
if math.IsNaN(v.AuxFloat()) {
diff --git a/src/cmd/compile/internal/ssa/gen/S390X.rules b/src/cmd/compile/internal/ssa/gen/S390X.rules
index 39949edbc2..384f2e807e 100644
--- a/src/cmd/compile/internal/ssa/gen/S390X.rules
+++ b/src/cmd/compile/internal/ssa/gen/S390X.rules
@@ -663,8 +663,8 @@
((OR|XOR)W x (MOVDconst [c])) => ((OR|XOR)Wconst [int32(c)] x)
// Constant shifts.
-(S(LD|RD|RAD) x (MOVDconst [c])) => (S(LD|RD|RAD)const x [int8(c&63)])
-(S(LW|RW|RAW) x (MOVDconst [c])) && c&32 == 0 => (S(LW|RW|RAW)const x [int8(c&31)])
+(S(LD|RD|RAD) x (MOVDconst [c])) => (S(LD|RD|RAD)const x [uint8(c&63)])
+(S(LW|RW|RAW) x (MOVDconst [c])) && c&32 == 0 => (S(LW|RW|RAW)const x [uint8(c&31)])
(S(LW|RW) _ (MOVDconst [c])) && c&32 != 0 => (MOVDconst [0])
(SRAW x (MOVDconst [c])) && c&32 != 0 => (SRAWconst x [31])
@@ -685,8 +685,8 @@
(SRAW x (MOV(W|H|B|WZ|HZ|BZ)reg y)) => (SRAW x y)
// Match rotate by constant.
-(RLLG x (MOVDconst [c])) => (RISBGZ x {s390x.NewRotateParams(0, 63, int8(c&63))})
-(RLL x (MOVDconst [c])) => (RLLconst x [int8(c&31)])
+(RLLG x (MOVDconst [c])) => (RISBGZ x {s390x.NewRotateParams(0, 63, uint8(c&63))})
+(RLL x (MOVDconst [c])) => (RLLconst x [uint8(c&31)])
// Match rotate by constant pattern.
((ADD|OR|XOR) (SLDconst x [c]) (SRDconst x [64-c])) => (RISBGZ x {s390x.NewRotateParams(0, 63, c)})
@@ -705,10 +705,10 @@
(CMP(W|WU) (MOVDconst [c]) x) => (InvertFlags (CMP(W|WU)const x [int32(c)]))
// Match (x >> c) << d to 'rotate then insert selected bits [into zero]'.
-(SLDconst (SRDconst x [c]) [d]) => (RISBGZ x {s390x.NewRotateParams(max8(0, c-d), 63-d, (d-c)&63)})
+(SLDconst (SRDconst x [c]) [d]) => (RISBGZ x {s390x.NewRotateParams(uint8(max8(0, int8(c-d))), 63-d, uint8(int8(d-c)&63))})
// Match (x << c) >> d to 'rotate then insert selected bits [into zero]'.
-(SRDconst (SLDconst x [c]) [d]) => (RISBGZ x {s390x.NewRotateParams(d, min8(63, 63-c+d), (c-d)&63)})
+(SRDconst (SLDconst x [c]) [d]) => (RISBGZ x {s390x.NewRotateParams(d, uint8(min8(63, int8(63-c+d))), uint8(int8(c-d)&63))})
// Absorb input zero extension into 'rotate then insert selected bits [into zero]'.
(RISBGZ (MOVWZreg x) {r}) && r.InMerge(0xffffffff) != nil => (RISBGZ x {*r.InMerge(0xffffffff)})
@@ -818,18 +818,18 @@
// c = 2ˣ + 2ʸ => c - 2ˣ = 2ʸ
(MULL(D|W)const x [c]) && isPowerOfTwo32(c&(c-1))
- => ((ADD|ADDW) (SL(D|W)const x [int8(log32(c&(c-1)))])
- (SL(D|W)const x [int8(log32(c&^(c-1)))]))
+ => ((ADD|ADDW) (SL(D|W)const x [uint8(log32(c&(c-1)))])
+ (SL(D|W)const x [uint8(log32(c&^(c-1)))]))
// c = 2ʸ - 2ˣ => c + 2ˣ = 2ʸ
(MULL(D|W)const x [c]) && isPowerOfTwo32(c+(c&^(c-1)))
- => ((SUB|SUBW) (SL(D|W)const x [int8(log32(c+(c&^(c-1))))])
- (SL(D|W)const x [int8(log32(c&^(c-1)))]))
+ => ((SUB|SUBW) (SL(D|W)const x [uint8(log32(c+(c&^(c-1))))])
+ (SL(D|W)const x [uint8(log32(c&^(c-1)))]))
// c = 2ˣ - 2ʸ => -c + 2ˣ = 2ʸ
(MULL(D|W)const x [c]) && isPowerOfTwo32(-c+(-c&^(-c-1)))
- => ((SUB|SUBW) (SL(D|W)const x [int8(log32(-c&^(-c-1)))])
- (SL(D|W)const x [int8(log32(-c+(-c&^(-c-1))))]))
+ => ((SUB|SUBW) (SL(D|W)const x [uint8(log32(-c&^(-c-1)))])
+ (SL(D|W)const x [uint8(log32(-c+(-c&^(-c-1))))]))
// Fold ADD into MOVDaddr. Odd offsets from SB shouldn't be folded (LARL can't handle them).
(ADDconst [c] (MOVDaddr [d] {s} x:(SB))) && ((c+d)&1 == 0) && is32Bit(int64(c)+int64(d)) => (MOVDaddr [c+d] {s} x)
diff --git a/src/cmd/compile/internal/ssa/gen/S390XOps.go b/src/cmd/compile/internal/ssa/gen/S390XOps.go
index f0cf2f2f6e..b24fd61942 100644
--- a/src/cmd/compile/internal/ssa/gen/S390XOps.go
+++ b/src/cmd/compile/internal/ssa/gen/S390XOps.go
@@ -330,27 +330,27 @@ func init() {
{name: "LTDBR", argLength: 1, reg: fp1flags, asm: "LTDBR", typ: "Flags"}, // arg0 compare to 0, f64
{name: "LTEBR", argLength: 1, reg: fp1flags, asm: "LTEBR", typ: "Flags"}, // arg0 compare to 0, f32
- {name: "SLD", argLength: 2, reg: sh21, asm: "SLD"}, // arg0 << arg1, shift amount is mod 64
- {name: "SLW", argLength: 2, reg: sh21, asm: "SLW"}, // arg0 << arg1, shift amount is mod 64
- {name: "SLDconst", argLength: 1, reg: gp11, asm: "SLD", aux: "Int8"}, // arg0 << auxint, shift amount 0-63
- {name: "SLWconst", argLength: 1, reg: gp11, asm: "SLW", aux: "Int8"}, // arg0 << auxint, shift amount 0-31
+ {name: "SLD", argLength: 2, reg: sh21, asm: "SLD"}, // arg0 << arg1, shift amount is mod 64
+ {name: "SLW", argLength: 2, reg: sh21, asm: "SLW"}, // arg0 << arg1, shift amount is mod 64
+ {name: "SLDconst", argLength: 1, reg: gp11, asm: "SLD", aux: "UInt8"}, // arg0 << auxint, shift amount 0-63
+ {name: "SLWconst", argLength: 1, reg: gp11, asm: "SLW", aux: "UInt8"}, // arg0 << auxint, shift amount 0-31
- {name: "SRD", argLength: 2, reg: sh21, asm: "SRD"}, // unsigned arg0 >> arg1, shift amount is mod 64
- {name: "SRW", argLength: 2, reg: sh21, asm: "SRW"}, // unsigned uint32(arg0) >> arg1, shift amount is mod 64
- {name: "SRDconst", argLength: 1, reg: gp11, asm: "SRD", aux: "Int8"}, // unsigned arg0 >> auxint, shift amount 0-63
- {name: "SRWconst", argLength: 1, reg: gp11, asm: "SRW", aux: "Int8"}, // unsigned uint32(arg0) >> auxint, shift amount 0-31
+ {name: "SRD", argLength: 2, reg: sh21, asm: "SRD"}, // unsigned arg0 >> arg1, shift amount is mod 64
+ {name: "SRW", argLength: 2, reg: sh21, asm: "SRW"}, // unsigned uint32(arg0) >> arg1, shift amount is mod 64
+ {name: "SRDconst", argLength: 1, reg: gp11, asm: "SRD", aux: "UInt8"}, // unsigned arg0 >> auxint, shift amount 0-63
+ {name: "SRWconst", argLength: 1, reg: gp11, asm: "SRW", aux: "UInt8"}, // unsigned uint32(arg0) >> auxint, shift amount 0-31
// Arithmetic shifts clobber flags.
- {name: "SRAD", argLength: 2, reg: sh21, asm: "SRAD", clobberFlags: true}, // signed arg0 >> arg1, shift amount is mod 64
- {name: "SRAW", argLength: 2, reg: sh21, asm: "SRAW", clobberFlags: true}, // signed int32(arg0) >> arg1, shift amount is mod 64
- {name: "SRADconst", argLength: 1, reg: gp11, asm: "SRAD", aux: "Int8", clobberFlags: true}, // signed arg0 >> auxint, shift amount 0-63
- {name: "SRAWconst", argLength: 1, reg: gp11, asm: "SRAW", aux: "Int8", clobberFlags: true}, // signed int32(arg0) >> auxint, shift amount 0-31
+ {name: "SRAD", argLength: 2, reg: sh21, asm: "SRAD", clobberFlags: true}, // signed arg0 >> arg1, shift amount is mod 64
+ {name: "SRAW", argLength: 2, reg: sh21, asm: "SRAW", clobberFlags: true}, // signed int32(arg0) >> arg1, shift amount is mod 64
+ {name: "SRADconst", argLength: 1, reg: gp11, asm: "SRAD", aux: "UInt8", clobberFlags: true}, // signed arg0 >> auxint, shift amount 0-63
+ {name: "SRAWconst", argLength: 1, reg: gp11, asm: "SRAW", aux: "UInt8", clobberFlags: true}, // signed int32(arg0) >> auxint, shift amount 0-31
// Rotate instructions.
// Note: no RLLGconst - use RISBGZ instead.
- {name: "RLLG", argLength: 2, reg: sh21, asm: "RLLG"}, // arg0 rotate left arg1, rotate amount 0-63
- {name: "RLL", argLength: 2, reg: sh21, asm: "RLL"}, // arg0 rotate left arg1, rotate amount 0-31
- {name: "RLLconst", argLength: 1, reg: gp11, asm: "RLL", aux: "Int8"}, // arg0 rotate left auxint, rotate amount 0-31
+ {name: "RLLG", argLength: 2, reg: sh21, asm: "RLLG"}, // arg0 rotate left arg1, rotate amount 0-63
+ {name: "RLL", argLength: 2, reg: sh21, asm: "RLL"}, // arg0 rotate left arg1, rotate amount 0-31
+ {name: "RLLconst", argLength: 1, reg: gp11, asm: "RLL", aux: "UInt8"}, // arg0 rotate left auxint, rotate amount 0-31
// Rotate then (and|or|xor|insert) selected bits instructions.
//
diff --git a/src/cmd/compile/internal/ssa/gen/rulegen.go b/src/cmd/compile/internal/ssa/gen/rulegen.go
index 120ccbbdb3..aaf9101368 100644
--- a/src/cmd/compile/internal/ssa/gen/rulegen.go
+++ b/src/cmd/compile/internal/ssa/gen/rulegen.go
@@ -1395,7 +1395,7 @@ func parseValue(val string, arch arch, loc string) (op opData, oparch, typ, auxi
func opHasAuxInt(op opData) bool {
switch op.aux {
- case "Bool", "Int8", "Int16", "Int32", "Int64", "Int128", "Float32", "Float64",
+ case "Bool", "Int8", "Int16", "Int32", "Int64", "Int128", "UInt8", "Float32", "Float64",
"SymOff", "CallOff", "SymValAndOff", "TypSize", "ARM64BitField", "FlagConstant", "CCop":
return true
}
@@ -1780,6 +1780,8 @@ func (op opData) auxIntType() string {
return "int64"
case "Int128":
return "int128"
+ case "UInt8":
+ return "uint8"
case "Float32":
return "float32"
case "Float64":
diff --git a/src/cmd/compile/internal/ssa/op.go b/src/cmd/compile/internal/ssa/op.go
index 6f029a421e..d1673352bd 100644
--- a/src/cmd/compile/internal/ssa/op.go
+++ b/src/cmd/compile/internal/ssa/op.go
@@ -205,6 +205,7 @@ const (
auxInt32 // auxInt is a 32-bit integer
auxInt64 // auxInt is a 64-bit integer
auxInt128 // auxInt represents a 128-bit integer. Always 0.
+ auxUInt8 // auxInt is an 8-bit unsigned integer
auxFloat32 // auxInt is a float32 (encoded with math.Float64bits)
auxFloat64 // auxInt is a float64 (encoded with math.Float64bits)
auxFlagConstant // auxInt is a flagConstant
diff --git a/src/cmd/compile/internal/ssa/opGen.go b/src/cmd/compile/internal/ssa/opGen.go
index eceef1d91a..83d35cf7e1 100644
--- a/src/cmd/compile/internal/ssa/opGen.go
+++ b/src/cmd/compile/internal/ssa/opGen.go
@@ -30569,7 +30569,7 @@ var opcodeTable = [...]opInfo{
},
{
name: "SLDconst",
- auxType: auxInt8,
+ auxType: auxUInt8,
argLen: 1,
asm: s390x.ASLD,
reg: regInfo{
@@ -30583,7 +30583,7 @@ var opcodeTable = [...]opInfo{
},
{
name: "SLWconst",
- auxType: auxInt8,
+ auxType: auxUInt8,
argLen: 1,
asm: s390x.ASLW,
reg: regInfo{
@@ -30625,7 +30625,7 @@ var opcodeTable = [...]opInfo{
},
{
name: "SRDconst",
- auxType: auxInt8,
+ auxType: auxUInt8,
argLen: 1,
asm: s390x.ASRD,
reg: regInfo{
@@ -30639,7 +30639,7 @@ var opcodeTable = [...]opInfo{
},
{
name: "SRWconst",
- auxType: auxInt8,
+ auxType: auxUInt8,
argLen: 1,
asm: s390x.ASRW,
reg: regInfo{
@@ -30683,7 +30683,7 @@ var opcodeTable = [...]opInfo{
},
{
name: "SRADconst",
- auxType: auxInt8,
+ auxType: auxUInt8,
argLen: 1,
clobberFlags: true,
asm: s390x.ASRAD,
@@ -30698,7 +30698,7 @@ var opcodeTable = [...]opInfo{
},
{
name: "SRAWconst",
- auxType: auxInt8,
+ auxType: auxUInt8,
argLen: 1,
clobberFlags: true,
asm: s390x.ASRAW,
@@ -30741,7 +30741,7 @@ var opcodeTable = [...]opInfo{
},
{
name: "RLLconst",
- auxType: auxInt8,
+ auxType: auxUInt8,
argLen: 1,
asm: s390x.ARLL,
reg: regInfo{
diff --git a/src/cmd/compile/internal/ssa/rewriteS390X.go b/src/cmd/compile/internal/ssa/rewriteS390X.go
index d66113d111..a9722b820c 100644
--- a/src/cmd/compile/internal/ssa/rewriteS390X.go
+++ b/src/cmd/compile/internal/ssa/rewriteS390X.go
@@ -1240,7 +1240,7 @@ func rewriteValueS390X_OpAvg64u(v *Value) bool {
y := v_1
v.reset(OpS390XADD)
v0 := b.NewValue0(v.Pos, OpS390XSRDconst, t)
- v0.AuxInt = int8ToAuxInt(1)
+ v0.AuxInt = uint8ToAuxInt(1)
v1 := b.NewValue0(v.Pos, OpS390XSUB, t)
v1.AddArg2(x, y)
v0.AddArg(v1)
@@ -1737,7 +1737,7 @@ func rewriteValueS390X_OpHmul32(v *Value) bool {
x := v_0
y := v_1
v.reset(OpS390XSRDconst)
- v.AuxInt = int8ToAuxInt(32)
+ v.AuxInt = uint8ToAuxInt(32)
v0 := b.NewValue0(v.Pos, OpS390XMULLD, typ.Int64)
v1 := b.NewValue0(v.Pos, OpS390XMOVWreg, typ.Int64)
v1.AddArg(x)
@@ -1759,7 +1759,7 @@ func rewriteValueS390X_OpHmul32u(v *Value) bool {
x := v_0
y := v_1
v.reset(OpS390XSRDconst)
- v.AuxInt = int8ToAuxInt(32)
+ v.AuxInt = uint8ToAuxInt(32)
v0 := b.NewValue0(v.Pos, OpS390XMULLD, typ.Int64)
v1 := b.NewValue0(v.Pos, OpS390XMOVWZreg, typ.UInt64)
v1.AddArg(x)
@@ -5281,9 +5281,9 @@ func rewriteValueS390X_OpS390XADD(v *Value) bool {
if v_0.Op != OpS390XSLDconst {
continue
}
- c := auxIntToInt8(v_0.AuxInt)
+ c := auxIntToUint8(v_0.AuxInt)
x := v_0.Args[0]
- if v_1.Op != OpS390XSRDconst || auxIntToInt8(v_1.AuxInt) != 64-c || x != v_1.Args[0] {
+ if v_1.Op != OpS390XSRDconst || auxIntToUint8(v_1.AuxInt) != 64-c || x != v_1.Args[0] {
continue
}
v.reset(OpS390XRISBGZ)
@@ -5474,13 +5474,13 @@ func rewriteValueS390X_OpS390XADDW(v *Value) bool {
if v_0.Op != OpS390XSLWconst {
continue
}
- c := auxIntToInt8(v_0.AuxInt)
+ c := auxIntToUint8(v_0.AuxInt)
x := v_0.Args[0]
- if v_1.Op != OpS390XSRWconst || auxIntToInt8(v_1.AuxInt) != 32-c || x != v_1.Args[0] {
+ if v_1.Op != OpS390XSRWconst || auxIntToUint8(v_1.AuxInt) != 32-c || x != v_1.Args[0] {
continue
}
v.reset(OpS390XRLLconst)
- v.AuxInt = int8ToAuxInt(c)
+ v.AuxInt = uint8ToAuxInt(c)
v.AddArg(x)
return true
}
@@ -6460,7 +6460,7 @@ func rewriteValueS390X_OpS390XCMPUconst(v *Value) bool {
if v_0.Op != OpS390XSRDconst {
break
}
- c := auxIntToInt8(v_0.AuxInt)
+ c := auxIntToUint8(v_0.AuxInt)
if !(c > 0 && c < 64 && (1< 0 && c < 32 && (1< 0 && n < 0) {
break
}
@@ -7020,7 +7020,7 @@ func rewriteValueS390X_OpS390XCMPWconst(v *Value) bool {
if x.Op != OpS390XSRWconst {
break
}
- c := auxIntToInt8(x.AuxInt)
+ c := auxIntToUint8(x.AuxInt)
if !(c > 0 && n >= 0) {
break
}
@@ -7112,7 +7112,7 @@ func rewriteValueS390X_OpS390XCMPconst(v *Value) bool {
if v_0.Op != OpS390XSRDconst {
break
}
- c := auxIntToInt8(v_0.AuxInt)
+ c := auxIntToUint8(v_0.AuxInt)
if !(c > 0 && n < 0) {
break
}
@@ -7250,7 +7250,7 @@ func rewriteValueS390X_OpS390XCMPconst(v *Value) bool {
if x.Op != OpS390XSRDconst {
break
}
- c := auxIntToInt8(x.AuxInt)
+ c := auxIntToUint8(x.AuxInt)
if !(c > 0 && n >= 0) {
break
}
@@ -8673,7 +8673,7 @@ func rewriteValueS390X_OpS390XMOVBstore(v *Value) bool {
break
}
x_1 := x.Args[1]
- if x_1.Op != OpS390XSRDconst || auxIntToInt8(x_1.AuxInt) != 8 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
+ if x_1.Op != OpS390XSRDconst || auxIntToUint8(x_1.AuxInt) != 8 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
break
}
v.reset(OpS390XMOVHstore)
@@ -8693,7 +8693,7 @@ func rewriteValueS390X_OpS390XMOVBstore(v *Value) bool {
if w0.Op != OpS390XSRDconst {
break
}
- j := auxIntToInt8(w0.AuxInt)
+ j := auxIntToUint8(w0.AuxInt)
w := w0.Args[0]
x := v_2
if x.Op != OpS390XMOVBstore || auxIntToInt32(x.AuxInt) != i-1 || auxToSym(x.Aux) != s {
@@ -8704,7 +8704,7 @@ func rewriteValueS390X_OpS390XMOVBstore(v *Value) bool {
break
}
x_1 := x.Args[1]
- if x_1.Op != OpS390XSRDconst || auxIntToInt8(x_1.AuxInt) != j+8 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
+ if x_1.Op != OpS390XSRDconst || auxIntToUint8(x_1.AuxInt) != j+8 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
break
}
v.reset(OpS390XMOVHstore)
@@ -8730,7 +8730,7 @@ func rewriteValueS390X_OpS390XMOVBstore(v *Value) bool {
break
}
x_1 := x.Args[1]
- if x_1.Op != OpS390XSRWconst || auxIntToInt8(x_1.AuxInt) != 8 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
+ if x_1.Op != OpS390XSRWconst || auxIntToUint8(x_1.AuxInt) != 8 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
break
}
v.reset(OpS390XMOVHstore)
@@ -8750,7 +8750,7 @@ func rewriteValueS390X_OpS390XMOVBstore(v *Value) bool {
if w0.Op != OpS390XSRWconst {
break
}
- j := auxIntToInt8(w0.AuxInt)
+ j := auxIntToUint8(w0.AuxInt)
w := w0.Args[0]
x := v_2
if x.Op != OpS390XMOVBstore || auxIntToInt32(x.AuxInt) != i-1 || auxToSym(x.Aux) != s {
@@ -8761,7 +8761,7 @@ func rewriteValueS390X_OpS390XMOVBstore(v *Value) bool {
break
}
x_1 := x.Args[1]
- if x_1.Op != OpS390XSRWconst || auxIntToInt8(x_1.AuxInt) != j+8 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
+ if x_1.Op != OpS390XSRWconst || auxIntToUint8(x_1.AuxInt) != j+8 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
break
}
v.reset(OpS390XMOVHstore)
@@ -8777,7 +8777,7 @@ func rewriteValueS390X_OpS390XMOVBstore(v *Value) bool {
i := auxIntToInt32(v.AuxInt)
s := auxToSym(v.Aux)
p := v_0
- if v_1.Op != OpS390XSRDconst || auxIntToInt8(v_1.AuxInt) != 8 {
+ if v_1.Op != OpS390XSRDconst || auxIntToUint8(v_1.AuxInt) != 8 {
break
}
w := v_1.Args[0]
@@ -8805,7 +8805,7 @@ func rewriteValueS390X_OpS390XMOVBstore(v *Value) bool {
if v_1.Op != OpS390XSRDconst {
break
}
- j := auxIntToInt8(v_1.AuxInt)
+ j := auxIntToUint8(v_1.AuxInt)
w := v_1.Args[0]
x := v_2
if x.Op != OpS390XMOVBstore || auxIntToInt32(x.AuxInt) != i-1 || auxToSym(x.Aux) != s {
@@ -8816,7 +8816,7 @@ func rewriteValueS390X_OpS390XMOVBstore(v *Value) bool {
break
}
w0 := x.Args[1]
- if w0.Op != OpS390XSRDconst || auxIntToInt8(w0.AuxInt) != j-8 || w != w0.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
+ if w0.Op != OpS390XSRDconst || auxIntToUint8(w0.AuxInt) != j-8 || w != w0.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
break
}
v.reset(OpS390XMOVHBRstore)
@@ -8832,7 +8832,7 @@ func rewriteValueS390X_OpS390XMOVBstore(v *Value) bool {
i := auxIntToInt32(v.AuxInt)
s := auxToSym(v.Aux)
p := v_0
- if v_1.Op != OpS390XSRWconst || auxIntToInt8(v_1.AuxInt) != 8 {
+ if v_1.Op != OpS390XSRWconst || auxIntToUint8(v_1.AuxInt) != 8 {
break
}
w := v_1.Args[0]
@@ -8860,7 +8860,7 @@ func rewriteValueS390X_OpS390XMOVBstore(v *Value) bool {
if v_1.Op != OpS390XSRWconst {
break
}
- j := auxIntToInt8(v_1.AuxInt)
+ j := auxIntToUint8(v_1.AuxInt)
w := v_1.Args[0]
x := v_2
if x.Op != OpS390XMOVBstore || auxIntToInt32(x.AuxInt) != i-1 || auxToSym(x.Aux) != s {
@@ -8871,7 +8871,7 @@ func rewriteValueS390X_OpS390XMOVBstore(v *Value) bool {
break
}
w0 := x.Args[1]
- if w0.Op != OpS390XSRWconst || auxIntToInt8(w0.AuxInt) != j-8 || w != w0.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
+ if w0.Op != OpS390XSRWconst || auxIntToUint8(w0.AuxInt) != j-8 || w != w0.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
break
}
v.reset(OpS390XMOVHBRstore)
@@ -9345,7 +9345,7 @@ func rewriteValueS390X_OpS390XMOVHBRstore(v *Value) bool {
i := auxIntToInt32(v.AuxInt)
s := auxToSym(v.Aux)
p := v_0
- if v_1.Op != OpS390XSRDconst || auxIntToInt8(v_1.AuxInt) != 16 {
+ if v_1.Op != OpS390XSRDconst || auxIntToUint8(v_1.AuxInt) != 16 {
break
}
w := v_1.Args[0]
@@ -9373,7 +9373,7 @@ func rewriteValueS390X_OpS390XMOVHBRstore(v *Value) bool {
if v_1.Op != OpS390XSRDconst {
break
}
- j := auxIntToInt8(v_1.AuxInt)
+ j := auxIntToUint8(v_1.AuxInt)
w := v_1.Args[0]
x := v_2
if x.Op != OpS390XMOVHBRstore || auxIntToInt32(x.AuxInt) != i-2 || auxToSym(x.Aux) != s {
@@ -9384,7 +9384,7 @@ func rewriteValueS390X_OpS390XMOVHBRstore(v *Value) bool {
break
}
w0 := x.Args[1]
- if w0.Op != OpS390XSRDconst || auxIntToInt8(w0.AuxInt) != j-16 || w != w0.Args[0] || !(x.Uses == 1 && clobber(x)) {
+ if w0.Op != OpS390XSRDconst || auxIntToUint8(w0.AuxInt) != j-16 || w != w0.Args[0] || !(x.Uses == 1 && clobber(x)) {
break
}
v.reset(OpS390XMOVWBRstore)
@@ -9400,7 +9400,7 @@ func rewriteValueS390X_OpS390XMOVHBRstore(v *Value) bool {
i := auxIntToInt32(v.AuxInt)
s := auxToSym(v.Aux)
p := v_0
- if v_1.Op != OpS390XSRWconst || auxIntToInt8(v_1.AuxInt) != 16 {
+ if v_1.Op != OpS390XSRWconst || auxIntToUint8(v_1.AuxInt) != 16 {
break
}
w := v_1.Args[0]
@@ -9428,7 +9428,7 @@ func rewriteValueS390X_OpS390XMOVHBRstore(v *Value) bool {
if v_1.Op != OpS390XSRWconst {
break
}
- j := auxIntToInt8(v_1.AuxInt)
+ j := auxIntToUint8(v_1.AuxInt)
w := v_1.Args[0]
x := v_2
if x.Op != OpS390XMOVHBRstore || auxIntToInt32(x.AuxInt) != i-2 || auxToSym(x.Aux) != s {
@@ -9439,7 +9439,7 @@ func rewriteValueS390X_OpS390XMOVHBRstore(v *Value) bool {
break
}
w0 := x.Args[1]
- if w0.Op != OpS390XSRWconst || auxIntToInt8(w0.AuxInt) != j-16 || w != w0.Args[0] || !(x.Uses == 1 && clobber(x)) {
+ if w0.Op != OpS390XSRWconst || auxIntToUint8(w0.AuxInt) != j-16 || w != w0.Args[0] || !(x.Uses == 1 && clobber(x)) {
break
}
v.reset(OpS390XMOVWBRstore)
@@ -10086,7 +10086,7 @@ func rewriteValueS390X_OpS390XMOVHstore(v *Value) bool {
break
}
x_1 := x.Args[1]
- if x_1.Op != OpS390XSRDconst || auxIntToInt8(x_1.AuxInt) != 16 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
+ if x_1.Op != OpS390XSRDconst || auxIntToUint8(x_1.AuxInt) != 16 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
break
}
v.reset(OpS390XMOVWstore)
@@ -10106,7 +10106,7 @@ func rewriteValueS390X_OpS390XMOVHstore(v *Value) bool {
if w0.Op != OpS390XSRDconst {
break
}
- j := auxIntToInt8(w0.AuxInt)
+ j := auxIntToUint8(w0.AuxInt)
w := w0.Args[0]
x := v_2
if x.Op != OpS390XMOVHstore || auxIntToInt32(x.AuxInt) != i-2 || auxToSym(x.Aux) != s {
@@ -10117,7 +10117,7 @@ func rewriteValueS390X_OpS390XMOVHstore(v *Value) bool {
break
}
x_1 := x.Args[1]
- if x_1.Op != OpS390XSRDconst || auxIntToInt8(x_1.AuxInt) != j+16 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
+ if x_1.Op != OpS390XSRDconst || auxIntToUint8(x_1.AuxInt) != j+16 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
break
}
v.reset(OpS390XMOVWstore)
@@ -10143,7 +10143,7 @@ func rewriteValueS390X_OpS390XMOVHstore(v *Value) bool {
break
}
x_1 := x.Args[1]
- if x_1.Op != OpS390XSRWconst || auxIntToInt8(x_1.AuxInt) != 16 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
+ if x_1.Op != OpS390XSRWconst || auxIntToUint8(x_1.AuxInt) != 16 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
break
}
v.reset(OpS390XMOVWstore)
@@ -10163,7 +10163,7 @@ func rewriteValueS390X_OpS390XMOVHstore(v *Value) bool {
if w0.Op != OpS390XSRWconst {
break
}
- j := auxIntToInt8(w0.AuxInt)
+ j := auxIntToUint8(w0.AuxInt)
w := w0.Args[0]
x := v_2
if x.Op != OpS390XMOVHstore || auxIntToInt32(x.AuxInt) != i-2 || auxToSym(x.Aux) != s {
@@ -10174,7 +10174,7 @@ func rewriteValueS390X_OpS390XMOVHstore(v *Value) bool {
break
}
x_1 := x.Args[1]
- if x_1.Op != OpS390XSRWconst || auxIntToInt8(x_1.AuxInt) != j+16 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
+ if x_1.Op != OpS390XSRWconst || auxIntToUint8(x_1.AuxInt) != j+16 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
break
}
v.reset(OpS390XMOVWstore)
@@ -10273,7 +10273,7 @@ func rewriteValueS390X_OpS390XMOVWBRstore(v *Value) bool {
i := auxIntToInt32(v.AuxInt)
s := auxToSym(v.Aux)
p := v_0
- if v_1.Op != OpS390XSRDconst || auxIntToInt8(v_1.AuxInt) != 32 {
+ if v_1.Op != OpS390XSRDconst || auxIntToUint8(v_1.AuxInt) != 32 {
break
}
w := v_1.Args[0]
@@ -10301,7 +10301,7 @@ func rewriteValueS390X_OpS390XMOVWBRstore(v *Value) bool {
if v_1.Op != OpS390XSRDconst {
break
}
- j := auxIntToInt8(v_1.AuxInt)
+ j := auxIntToUint8(v_1.AuxInt)
w := v_1.Args[0]
x := v_2
if x.Op != OpS390XMOVWBRstore || auxIntToInt32(x.AuxInt) != i-4 || auxToSym(x.Aux) != s {
@@ -10312,7 +10312,7 @@ func rewriteValueS390X_OpS390XMOVWBRstore(v *Value) bool {
break
}
w0 := x.Args[1]
- if w0.Op != OpS390XSRDconst || auxIntToInt8(w0.AuxInt) != j-32 || w != w0.Args[0] || !(x.Uses == 1 && clobber(x)) {
+ if w0.Op != OpS390XSRDconst || auxIntToUint8(w0.AuxInt) != j-32 || w != w0.Args[0] || !(x.Uses == 1 && clobber(x)) {
break
}
v.reset(OpS390XMOVDBRstore)
@@ -10914,7 +10914,7 @@ func rewriteValueS390X_OpS390XMOVWstore(v *Value) bool {
i := auxIntToInt32(v.AuxInt)
s := auxToSym(v.Aux)
p := v_0
- if v_1.Op != OpS390XSRDconst || auxIntToInt8(v_1.AuxInt) != 32 {
+ if v_1.Op != OpS390XSRDconst || auxIntToUint8(v_1.AuxInt) != 32 {
break
}
w := v_1.Args[0]
@@ -10943,7 +10943,7 @@ func rewriteValueS390X_OpS390XMOVWstore(v *Value) bool {
if w0.Op != OpS390XSRDconst {
break
}
- j := auxIntToInt8(w0.AuxInt)
+ j := auxIntToUint8(w0.AuxInt)
w := w0.Args[0]
x := v_2
if x.Op != OpS390XMOVWstore || auxIntToInt32(x.AuxInt) != i-4 || auxToSym(x.Aux) != s {
@@ -10954,7 +10954,7 @@ func rewriteValueS390X_OpS390XMOVWstore(v *Value) bool {
break
}
x_1 := x.Args[1]
- if x_1.Op != OpS390XSRDconst || auxIntToInt8(x_1.AuxInt) != j+32 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
+ if x_1.Op != OpS390XSRDconst || auxIntToUint8(x_1.AuxInt) != j+32 || w != x_1.Args[0] || !(p.Op != OpSB && x.Uses == 1 && clobber(x)) {
break
}
v.reset(OpS390XMOVDstore)
@@ -11180,7 +11180,7 @@ func rewriteValueS390X_OpS390XMULLDconst(v *Value) bool {
b := v.Block
// match: (MULLDconst x [c])
// cond: isPowerOfTwo32(c&(c-1))
- // result: (ADD (SLDconst x [int8(log32(c&(c-1)))]) (SLDconst x [int8(log32(c&^(c-1)))]))
+ // result: (ADD (SLDconst x [uint8(log32(c&(c-1)))]) (SLDconst x [uint8(log32(c&^(c-1)))]))
for {
t := v.Type
c := auxIntToInt32(v.AuxInt)
@@ -11190,17 +11190,17 @@ func rewriteValueS390X_OpS390XMULLDconst(v *Value) bool {
}
v.reset(OpS390XADD)
v0 := b.NewValue0(v.Pos, OpS390XSLDconst, t)
- v0.AuxInt = int8ToAuxInt(int8(log32(c & (c - 1))))
+ v0.AuxInt = uint8ToAuxInt(uint8(log32(c & (c - 1))))
v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpS390XSLDconst, t)
- v1.AuxInt = int8ToAuxInt(int8(log32(c &^ (c - 1))))
+ v1.AuxInt = uint8ToAuxInt(uint8(log32(c &^ (c - 1))))
v1.AddArg(x)
v.AddArg2(v0, v1)
return true
}
// match: (MULLDconst x [c])
// cond: isPowerOfTwo32(c+(c&^(c-1)))
- // result: (SUB (SLDconst x [int8(log32(c+(c&^(c-1))))]) (SLDconst x [int8(log32(c&^(c-1)))]))
+ // result: (SUB (SLDconst x [uint8(log32(c+(c&^(c-1))))]) (SLDconst x [uint8(log32(c&^(c-1)))]))
for {
t := v.Type
c := auxIntToInt32(v.AuxInt)
@@ -11210,17 +11210,17 @@ func rewriteValueS390X_OpS390XMULLDconst(v *Value) bool {
}
v.reset(OpS390XSUB)
v0 := b.NewValue0(v.Pos, OpS390XSLDconst, t)
- v0.AuxInt = int8ToAuxInt(int8(log32(c + (c &^ (c - 1)))))
+ v0.AuxInt = uint8ToAuxInt(uint8(log32(c + (c &^ (c - 1)))))
v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpS390XSLDconst, t)
- v1.AuxInt = int8ToAuxInt(int8(log32(c &^ (c - 1))))
+ v1.AuxInt = uint8ToAuxInt(uint8(log32(c &^ (c - 1))))
v1.AddArg(x)
v.AddArg2(v0, v1)
return true
}
// match: (MULLDconst x [c])
// cond: isPowerOfTwo32(-c+(-c&^(-c-1)))
- // result: (SUB (SLDconst x [int8(log32(-c&^(-c-1)))]) (SLDconst x [int8(log32(-c+(-c&^(-c-1))))]))
+ // result: (SUB (SLDconst x [uint8(log32(-c&^(-c-1)))]) (SLDconst x [uint8(log32(-c+(-c&^(-c-1))))]))
for {
t := v.Type
c := auxIntToInt32(v.AuxInt)
@@ -11230,10 +11230,10 @@ func rewriteValueS390X_OpS390XMULLDconst(v *Value) bool {
}
v.reset(OpS390XSUB)
v0 := b.NewValue0(v.Pos, OpS390XSLDconst, t)
- v0.AuxInt = int8ToAuxInt(int8(log32(-c &^ (-c - 1))))
+ v0.AuxInt = uint8ToAuxInt(uint8(log32(-c &^ (-c - 1))))
v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpS390XSLDconst, t)
- v1.AuxInt = int8ToAuxInt(int8(log32(-c + (-c &^ (-c - 1)))))
+ v1.AuxInt = uint8ToAuxInt(uint8(log32(-c + (-c &^ (-c - 1)))))
v1.AddArg(x)
v.AddArg2(v0, v1)
return true
@@ -11407,7 +11407,7 @@ func rewriteValueS390X_OpS390XMULLWconst(v *Value) bool {
b := v.Block
// match: (MULLWconst x [c])
// cond: isPowerOfTwo32(c&(c-1))
- // result: (ADDW (SLWconst x [int8(log32(c&(c-1)))]) (SLWconst x [int8(log32(c&^(c-1)))]))
+ // result: (ADDW (SLWconst x [uint8(log32(c&(c-1)))]) (SLWconst x [uint8(log32(c&^(c-1)))]))
for {
t := v.Type
c := auxIntToInt32(v.AuxInt)
@@ -11417,17 +11417,17 @@ func rewriteValueS390X_OpS390XMULLWconst(v *Value) bool {
}
v.reset(OpS390XADDW)
v0 := b.NewValue0(v.Pos, OpS390XSLWconst, t)
- v0.AuxInt = int8ToAuxInt(int8(log32(c & (c - 1))))
+ v0.AuxInt = uint8ToAuxInt(uint8(log32(c & (c - 1))))
v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpS390XSLWconst, t)
- v1.AuxInt = int8ToAuxInt(int8(log32(c &^ (c - 1))))
+ v1.AuxInt = uint8ToAuxInt(uint8(log32(c &^ (c - 1))))
v1.AddArg(x)
v.AddArg2(v0, v1)
return true
}
// match: (MULLWconst x [c])
// cond: isPowerOfTwo32(c+(c&^(c-1)))
- // result: (SUBW (SLWconst x [int8(log32(c+(c&^(c-1))))]) (SLWconst x [int8(log32(c&^(c-1)))]))
+ // result: (SUBW (SLWconst x [uint8(log32(c+(c&^(c-1))))]) (SLWconst x [uint8(log32(c&^(c-1)))]))
for {
t := v.Type
c := auxIntToInt32(v.AuxInt)
@@ -11437,17 +11437,17 @@ func rewriteValueS390X_OpS390XMULLWconst(v *Value) bool {
}
v.reset(OpS390XSUBW)
v0 := b.NewValue0(v.Pos, OpS390XSLWconst, t)
- v0.AuxInt = int8ToAuxInt(int8(log32(c + (c &^ (c - 1)))))
+ v0.AuxInt = uint8ToAuxInt(uint8(log32(c + (c &^ (c - 1)))))
v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpS390XSLWconst, t)
- v1.AuxInt = int8ToAuxInt(int8(log32(c &^ (c - 1))))
+ v1.AuxInt = uint8ToAuxInt(uint8(log32(c &^ (c - 1))))
v1.AddArg(x)
v.AddArg2(v0, v1)
return true
}
// match: (MULLWconst x [c])
// cond: isPowerOfTwo32(-c+(-c&^(-c-1)))
- // result: (SUBW (SLWconst x [int8(log32(-c&^(-c-1)))]) (SLWconst x [int8(log32(-c+(-c&^(-c-1))))]))
+ // result: (SUBW (SLWconst x [uint8(log32(-c&^(-c-1)))]) (SLWconst x [uint8(log32(-c+(-c&^(-c-1))))]))
for {
t := v.Type
c := auxIntToInt32(v.AuxInt)
@@ -11457,10 +11457,10 @@ func rewriteValueS390X_OpS390XMULLWconst(v *Value) bool {
}
v.reset(OpS390XSUBW)
v0 := b.NewValue0(v.Pos, OpS390XSLWconst, t)
- v0.AuxInt = int8ToAuxInt(int8(log32(-c &^ (-c - 1))))
+ v0.AuxInt = uint8ToAuxInt(uint8(log32(-c &^ (-c - 1))))
v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpS390XSLWconst, t)
- v1.AuxInt = int8ToAuxInt(int8(log32(-c + (-c &^ (-c - 1)))))
+ v1.AuxInt = uint8ToAuxInt(uint8(log32(-c + (-c &^ (-c - 1)))))
v1.AddArg(x)
v.AddArg2(v0, v1)
return true
@@ -11640,9 +11640,9 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
if v_0.Op != OpS390XSLDconst {
continue
}
- c := auxIntToInt8(v_0.AuxInt)
+ c := auxIntToUint8(v_0.AuxInt)
x := v_0.Args[0]
- if v_1.Op != OpS390XSRDconst || auxIntToInt8(v_1.AuxInt) != 64-c || x != v_1.Args[0] {
+ if v_1.Op != OpS390XSRDconst || auxIntToUint8(v_1.AuxInt) != 64-c || x != v_1.Args[0] {
continue
}
v.reset(OpS390XRISBGZ)
@@ -11804,7 +11804,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
mem := x1.Args[1]
p := x1.Args[0]
sh := v_1
- if sh.Op != OpS390XSLDconst || auxIntToInt8(sh.AuxInt) != 8 {
+ if sh.Op != OpS390XSLDconst || auxIntToUint8(sh.AuxInt) != 8 {
continue
}
x0 := sh.Args[0]
@@ -11843,7 +11843,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
mem := x1.Args[1]
p := x1.Args[0]
sh := v_1
- if sh.Op != OpS390XSLDconst || auxIntToInt8(sh.AuxInt) != 16 {
+ if sh.Op != OpS390XSLDconst || auxIntToUint8(sh.AuxInt) != 16 {
continue
}
x0 := sh.Args[0]
@@ -11882,7 +11882,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
mem := x1.Args[1]
p := x1.Args[0]
sh := v_1
- if sh.Op != OpS390XSLDconst || auxIntToInt8(sh.AuxInt) != 32 {
+ if sh.Op != OpS390XSLDconst || auxIntToUint8(sh.AuxInt) != 32 {
continue
}
x0 := sh.Args[0]
@@ -11916,7 +11916,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
if s0.Op != OpS390XSLDconst {
continue
}
- j0 := auxIntToInt8(s0.AuxInt)
+ j0 := auxIntToUint8(s0.AuxInt)
x0 := s0.Args[0]
if x0.Op != OpS390XMOVBZload {
continue
@@ -11937,7 +11937,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
if s1.Op != OpS390XSLDconst {
continue
}
- j1 := auxIntToInt8(s1.AuxInt)
+ j1 := auxIntToUint8(s1.AuxInt)
x1 := s1.Args[0]
if x1.Op != OpS390XMOVBZload {
continue
@@ -11958,7 +11958,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
v0 := b.NewValue0(x1.Pos, OpS390XOR, v.Type)
v.copyOf(v0)
v1 := b.NewValue0(x1.Pos, OpS390XSLDconst, v.Type)
- v1.AuxInt = int8ToAuxInt(j1)
+ v1.AuxInt = uint8ToAuxInt(j1)
v2 := b.NewValue0(x1.Pos, OpS390XMOVHZload, typ.UInt16)
v2.AuxInt = int32ToAuxInt(i0)
v2.Aux = symToAux(s)
@@ -11979,7 +11979,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
if s0.Op != OpS390XSLDconst {
continue
}
- j0 := auxIntToInt8(s0.AuxInt)
+ j0 := auxIntToUint8(s0.AuxInt)
x0 := s0.Args[0]
if x0.Op != OpS390XMOVHZload {
continue
@@ -12000,7 +12000,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
if s1.Op != OpS390XSLDconst {
continue
}
- j1 := auxIntToInt8(s1.AuxInt)
+ j1 := auxIntToUint8(s1.AuxInt)
x1 := s1.Args[0]
if x1.Op != OpS390XMOVHZload {
continue
@@ -12021,7 +12021,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
v0 := b.NewValue0(x1.Pos, OpS390XOR, v.Type)
v.copyOf(v0)
v1 := b.NewValue0(x1.Pos, OpS390XSLDconst, v.Type)
- v1.AuxInt = int8ToAuxInt(j1)
+ v1.AuxInt = uint8ToAuxInt(j1)
v2 := b.NewValue0(x1.Pos, OpS390XMOVWZload, typ.UInt32)
v2.AuxInt = int32ToAuxInt(i0)
v2.Aux = symToAux(s)
@@ -12047,7 +12047,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
mem := x0.Args[1]
p := x0.Args[0]
sh := v_1
- if sh.Op != OpS390XSLDconst || auxIntToInt8(sh.AuxInt) != 8 {
+ if sh.Op != OpS390XSLDconst || auxIntToUint8(sh.AuxInt) != 8 {
continue
}
x1 := sh.Args[0]
@@ -12092,7 +12092,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
mem := x0.Args[1]
p := x0.Args[0]
sh := v_1
- if sh.Op != OpS390XSLDconst || auxIntToInt8(sh.AuxInt) != 16 {
+ if sh.Op != OpS390XSLDconst || auxIntToUint8(sh.AuxInt) != 16 {
continue
}
r1 := sh.Args[0]
@@ -12141,7 +12141,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
mem := x0.Args[1]
p := x0.Args[0]
sh := v_1
- if sh.Op != OpS390XSLDconst || auxIntToInt8(sh.AuxInt) != 32 {
+ if sh.Op != OpS390XSLDconst || auxIntToUint8(sh.AuxInt) != 32 {
continue
}
r1 := sh.Args[0]
@@ -12179,7 +12179,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
if s1.Op != OpS390XSLDconst {
continue
}
- j1 := auxIntToInt8(s1.AuxInt)
+ j1 := auxIntToUint8(s1.AuxInt)
x1 := s1.Args[0]
if x1.Op != OpS390XMOVBZload {
continue
@@ -12200,7 +12200,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
if s0.Op != OpS390XSLDconst {
continue
}
- j0 := auxIntToInt8(s0.AuxInt)
+ j0 := auxIntToUint8(s0.AuxInt)
x0 := s0.Args[0]
if x0.Op != OpS390XMOVBZload {
continue
@@ -12221,7 +12221,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
v0 := b.NewValue0(x0.Pos, OpS390XOR, v.Type)
v.copyOf(v0)
v1 := b.NewValue0(x0.Pos, OpS390XSLDconst, v.Type)
- v1.AuxInt = int8ToAuxInt(j0)
+ v1.AuxInt = uint8ToAuxInt(j0)
v2 := b.NewValue0(x0.Pos, OpS390XMOVHZreg, typ.UInt64)
v3 := b.NewValue0(x0.Pos, OpS390XMOVHBRload, typ.UInt16)
v3.AuxInt = int32ToAuxInt(i0)
@@ -12244,7 +12244,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
if s1.Op != OpS390XSLDconst {
continue
}
- j1 := auxIntToInt8(s1.AuxInt)
+ j1 := auxIntToUint8(s1.AuxInt)
r1 := s1.Args[0]
if r1.Op != OpS390XMOVHZreg {
continue
@@ -12269,7 +12269,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
if s0.Op != OpS390XSLDconst {
continue
}
- j0 := auxIntToInt8(s0.AuxInt)
+ j0 := auxIntToUint8(s0.AuxInt)
r0 := s0.Args[0]
if r0.Op != OpS390XMOVHZreg {
continue
@@ -12294,7 +12294,7 @@ func rewriteValueS390X_OpS390XOR(v *Value) bool {
v0 := b.NewValue0(x0.Pos, OpS390XOR, v.Type)
v.copyOf(v0)
v1 := b.NewValue0(x0.Pos, OpS390XSLDconst, v.Type)
- v1.AuxInt = int8ToAuxInt(j0)
+ v1.AuxInt = uint8ToAuxInt(j0)
v2 := b.NewValue0(x0.Pos, OpS390XMOVWZreg, typ.UInt64)
v3 := b.NewValue0(x0.Pos, OpS390XMOVWBRload, typ.UInt32)
v3.AuxInt = int32ToAuxInt(i0)
@@ -12338,13 +12338,13 @@ func rewriteValueS390X_OpS390XORW(v *Value) bool {
if v_0.Op != OpS390XSLWconst {
continue
}
- c := auxIntToInt8(v_0.AuxInt)
+ c := auxIntToUint8(v_0.AuxInt)
x := v_0.Args[0]
- if v_1.Op != OpS390XSRWconst || auxIntToInt8(v_1.AuxInt) != 32-c || x != v_1.Args[0] {
+ if v_1.Op != OpS390XSRWconst || auxIntToUint8(v_1.AuxInt) != 32-c || x != v_1.Args[0] {
continue
}
v.reset(OpS390XRLLconst)
- v.AuxInt = int8ToAuxInt(c)
+ v.AuxInt = uint8ToAuxInt(c)
v.AddArg(x)
return true
}
@@ -12428,7 +12428,7 @@ func rewriteValueS390X_OpS390XORW(v *Value) bool {
mem := x1.Args[1]
p := x1.Args[0]
sh := v_1
- if sh.Op != OpS390XSLWconst || auxIntToInt8(sh.AuxInt) != 8 {
+ if sh.Op != OpS390XSLWconst || auxIntToUint8(sh.AuxInt) != 8 {
continue
}
x0 := sh.Args[0]
@@ -12467,7 +12467,7 @@ func rewriteValueS390X_OpS390XORW(v *Value) bool {
mem := x1.Args[1]
p := x1.Args[0]
sh := v_1
- if sh.Op != OpS390XSLWconst || auxIntToInt8(sh.AuxInt) != 16 {
+ if sh.Op != OpS390XSLWconst || auxIntToUint8(sh.AuxInt) != 16 {
continue
}
x0 := sh.Args[0]
@@ -12501,7 +12501,7 @@ func rewriteValueS390X_OpS390XORW(v *Value) bool {
if s0.Op != OpS390XSLWconst {
continue
}
- j0 := auxIntToInt8(s0.AuxInt)
+ j0 := auxIntToUint8(s0.AuxInt)
x0 := s0.Args[0]
if x0.Op != OpS390XMOVBZload {
continue
@@ -12522,7 +12522,7 @@ func rewriteValueS390X_OpS390XORW(v *Value) bool {
if s1.Op != OpS390XSLWconst {
continue
}
- j1 := auxIntToInt8(s1.AuxInt)
+ j1 := auxIntToUint8(s1.AuxInt)
x1 := s1.Args[0]
if x1.Op != OpS390XMOVBZload {
continue
@@ -12543,7 +12543,7 @@ func rewriteValueS390X_OpS390XORW(v *Value) bool {
v0 := b.NewValue0(x1.Pos, OpS390XORW, v.Type)
v.copyOf(v0)
v1 := b.NewValue0(x1.Pos, OpS390XSLWconst, v.Type)
- v1.AuxInt = int8ToAuxInt(j1)
+ v1.AuxInt = uint8ToAuxInt(j1)
v2 := b.NewValue0(x1.Pos, OpS390XMOVHZload, typ.UInt16)
v2.AuxInt = int32ToAuxInt(i0)
v2.Aux = symToAux(s)
@@ -12569,7 +12569,7 @@ func rewriteValueS390X_OpS390XORW(v *Value) bool {
mem := x0.Args[1]
p := x0.Args[0]
sh := v_1
- if sh.Op != OpS390XSLWconst || auxIntToInt8(sh.AuxInt) != 8 {
+ if sh.Op != OpS390XSLWconst || auxIntToUint8(sh.AuxInt) != 8 {
continue
}
x1 := sh.Args[0]
@@ -12614,7 +12614,7 @@ func rewriteValueS390X_OpS390XORW(v *Value) bool {
mem := x0.Args[1]
p := x0.Args[0]
sh := v_1
- if sh.Op != OpS390XSLWconst || auxIntToInt8(sh.AuxInt) != 16 {
+ if sh.Op != OpS390XSLWconst || auxIntToUint8(sh.AuxInt) != 16 {
continue
}
r1 := sh.Args[0]
@@ -12652,7 +12652,7 @@ func rewriteValueS390X_OpS390XORW(v *Value) bool {
if s1.Op != OpS390XSLWconst {
continue
}
- j1 := auxIntToInt8(s1.AuxInt)
+ j1 := auxIntToUint8(s1.AuxInt)
x1 := s1.Args[0]
if x1.Op != OpS390XMOVBZload {
continue
@@ -12673,7 +12673,7 @@ func rewriteValueS390X_OpS390XORW(v *Value) bool {
if s0.Op != OpS390XSLWconst {
continue
}
- j0 := auxIntToInt8(s0.AuxInt)
+ j0 := auxIntToUint8(s0.AuxInt)
x0 := s0.Args[0]
if x0.Op != OpS390XMOVBZload {
continue
@@ -12694,7 +12694,7 @@ func rewriteValueS390X_OpS390XORW(v *Value) bool {
v0 := b.NewValue0(x0.Pos, OpS390XORW, v.Type)
v.copyOf(v0)
v1 := b.NewValue0(x0.Pos, OpS390XSLWconst, v.Type)
- v1.AuxInt = int8ToAuxInt(j0)
+ v1.AuxInt = uint8ToAuxInt(j0)
v2 := b.NewValue0(x0.Pos, OpS390XMOVHZreg, typ.UInt64)
v3 := b.NewValue0(x0.Pos, OpS390XMOVHBRload, typ.UInt16)
v3.AuxInt = int32ToAuxInt(i0)
@@ -12974,7 +12974,7 @@ func rewriteValueS390X_OpS390XRISBGZ(v *Value) bool {
if v_0.Op != OpS390XSLDconst {
break
}
- c := auxIntToInt8(v_0.AuxInt)
+ c := auxIntToUint8(v_0.AuxInt)
x := v_0.Args[0]
if !(r.InMerge(^uint64(0)<>c) != nil) {
break
@@ -13030,7 +13030,7 @@ func rewriteValueS390X_OpS390XRISBGZ(v *Value) bool {
break
}
v.reset(OpS390XSRDconst)
- v.AuxInt = int8ToAuxInt(-r.Amount & 63)
+ v.AuxInt = uint8ToAuxInt(-r.Amount & 63)
v.AddArg(x)
return true
}
@@ -13044,7 +13044,7 @@ func rewriteValueS390X_OpS390XRISBGZ(v *Value) bool {
break
}
v.reset(OpS390XSLDconst)
- v.AuxInt = int8ToAuxInt(r.Amount)
+ v.AuxInt = uint8ToAuxInt(r.Amount)
v.AddArg(x)
return true
}
@@ -13056,7 +13056,7 @@ func rewriteValueS390X_OpS390XRISBGZ(v *Value) bool {
if v_0.Op != OpS390XSRADconst {
break
}
- c := auxIntToInt8(v_0.AuxInt)
+ c := auxIntToUint8(v_0.AuxInt)
x := v_0.Args[0]
if !(r.Start == r.End && (r.Start+r.Amount)&63 <= c) {
break
@@ -13131,7 +13131,7 @@ func rewriteValueS390X_OpS390XRLL(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
// match: (RLL x (MOVDconst [c]))
- // result: (RLLconst x [int8(c&31)])
+ // result: (RLLconst x [uint8(c&31)])
for {
x := v_0
if v_1.Op != OpS390XMOVDconst {
@@ -13139,7 +13139,7 @@ func rewriteValueS390X_OpS390XRLL(v *Value) bool {
}
c := auxIntToInt64(v_1.AuxInt)
v.reset(OpS390XRLLconst)
- v.AuxInt = int8ToAuxInt(int8(c & 31))
+ v.AuxInt = uint8ToAuxInt(uint8(c & 31))
v.AddArg(x)
return true
}
@@ -13149,7 +13149,7 @@ func rewriteValueS390X_OpS390XRLLG(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
// match: (RLLG x (MOVDconst [c]))
- // result: (RISBGZ x {s390x.NewRotateParams(0, 63, int8(c&63))})
+ // result: (RISBGZ x {s390x.NewRotateParams(0, 63, uint8(c&63))})
for {
x := v_0
if v_1.Op != OpS390XMOVDconst {
@@ -13157,7 +13157,7 @@ func rewriteValueS390X_OpS390XRLLG(v *Value) bool {
}
c := auxIntToInt64(v_1.AuxInt)
v.reset(OpS390XRISBGZ)
- v.Aux = s390xRotateParamsToAux(s390x.NewRotateParams(0, 63, int8(c&63)))
+ v.Aux = s390xRotateParamsToAux(s390x.NewRotateParams(0, 63, uint8(c&63)))
v.AddArg(x)
return true
}
@@ -13169,7 +13169,7 @@ func rewriteValueS390X_OpS390XSLD(v *Value) bool {
b := v.Block
typ := &b.Func.Config.Types
// match: (SLD x (MOVDconst [c]))
- // result: (SLDconst x [int8(c&63)])
+ // result: (SLDconst x [uint8(c&63)])
for {
x := v_0
if v_1.Op != OpS390XMOVDconst {
@@ -13177,7 +13177,7 @@ func rewriteValueS390X_OpS390XSLD(v *Value) bool {
}
c := auxIntToInt64(v_1.AuxInt)
v.reset(OpS390XSLDconst)
- v.AuxInt = int8ToAuxInt(int8(c & 63))
+ v.AuxInt = uint8ToAuxInt(uint8(c & 63))
v.AddArg(x)
return true
}
@@ -13317,16 +13317,16 @@ func rewriteValueS390X_OpS390XSLD(v *Value) bool {
func rewriteValueS390X_OpS390XSLDconst(v *Value) bool {
v_0 := v.Args[0]
// match: (SLDconst (SRDconst x [c]) [d])
- // result: (RISBGZ x {s390x.NewRotateParams(max8(0, c-d), 63-d, (d-c)&63)})
+ // result: (RISBGZ x {s390x.NewRotateParams(uint8(max8(0, int8(c-d))), 63-d, uint8(int8(d-c)&63))})
for {
- d := auxIntToInt8(v.AuxInt)
+ d := auxIntToUint8(v.AuxInt)
if v_0.Op != OpS390XSRDconst {
break
}
- c := auxIntToInt8(v_0.AuxInt)
+ c := auxIntToUint8(v_0.AuxInt)
x := v_0.Args[0]
v.reset(OpS390XRISBGZ)
- v.Aux = s390xRotateParamsToAux(s390x.NewRotateParams(max8(0, c-d), 63-d, (d-c)&63))
+ v.Aux = s390xRotateParamsToAux(s390x.NewRotateParams(uint8(max8(0, int8(c-d))), 63-d, uint8(int8(d-c)&63)))
v.AddArg(x)
return true
}
@@ -13334,7 +13334,7 @@ func rewriteValueS390X_OpS390XSLDconst(v *Value) bool {
// cond: s390x.NewRotateParams(0, 63-c, c).InMerge(r.OutMask()) != nil
// result: (RISBGZ x {(*s390x.NewRotateParams(0, 63-c, c).InMerge(r.OutMask())).RotateLeft(r.Amount)})
for {
- c := auxIntToInt8(v.AuxInt)
+ c := auxIntToUint8(v.AuxInt)
if v_0.Op != OpS390XRISBGZ {
break
}
@@ -13351,7 +13351,7 @@ func rewriteValueS390X_OpS390XSLDconst(v *Value) bool {
// match: (SLDconst x [0])
// result: x
for {
- if auxIntToInt8(v.AuxInt) != 0 {
+ if auxIntToUint8(v.AuxInt) != 0 {
break
}
x := v_0
@@ -13367,7 +13367,7 @@ func rewriteValueS390X_OpS390XSLW(v *Value) bool {
typ := &b.Func.Config.Types
// match: (SLW x (MOVDconst [c]))
// cond: c&32 == 0
- // result: (SLWconst x [int8(c&31)])
+ // result: (SLWconst x [uint8(c&31)])
for {
x := v_0
if v_1.Op != OpS390XMOVDconst {
@@ -13378,7 +13378,7 @@ func rewriteValueS390X_OpS390XSLW(v *Value) bool {
break
}
v.reset(OpS390XSLWconst)
- v.AuxInt = int8ToAuxInt(int8(c & 31))
+ v.AuxInt = uint8ToAuxInt(uint8(c & 31))
v.AddArg(x)
return true
}
@@ -13535,7 +13535,7 @@ func rewriteValueS390X_OpS390XSLWconst(v *Value) bool {
// match: (SLWconst x [0])
// result: x
for {
- if auxIntToInt8(v.AuxInt) != 0 {
+ if auxIntToUint8(v.AuxInt) != 0 {
break
}
x := v_0
@@ -13550,7 +13550,7 @@ func rewriteValueS390X_OpS390XSRAD(v *Value) bool {
b := v.Block
typ := &b.Func.Config.Types
// match: (SRAD x (MOVDconst [c]))
- // result: (SRADconst x [int8(c&63)])
+ // result: (SRADconst x [uint8(c&63)])
for {
x := v_0
if v_1.Op != OpS390XMOVDconst {
@@ -13558,7 +13558,7 @@ func rewriteValueS390X_OpS390XSRAD(v *Value) bool {
}
c := auxIntToInt64(v_1.AuxInt)
v.reset(OpS390XSRADconst)
- v.AuxInt = int8ToAuxInt(int8(c & 63))
+ v.AuxInt = uint8ToAuxInt(uint8(c & 63))
v.AddArg(x)
return true
}
@@ -13700,7 +13700,7 @@ func rewriteValueS390X_OpS390XSRADconst(v *Value) bool {
// match: (SRADconst x [0])
// result: x
for {
- if auxIntToInt8(v.AuxInt) != 0 {
+ if auxIntToUint8(v.AuxInt) != 0 {
break
}
x := v_0
@@ -13710,7 +13710,7 @@ func rewriteValueS390X_OpS390XSRADconst(v *Value) bool {
// match: (SRADconst [c] (MOVDconst [d]))
// result: (MOVDconst [d>>uint64(c)])
for {
- c := auxIntToInt8(v.AuxInt)
+ c := auxIntToUint8(v.AuxInt)
if v_0.Op != OpS390XMOVDconst {
break
}
@@ -13728,7 +13728,7 @@ func rewriteValueS390X_OpS390XSRAW(v *Value) bool {
typ := &b.Func.Config.Types
// match: (SRAW x (MOVDconst [c]))
// cond: c&32 == 0
- // result: (SRAWconst x [int8(c&31)])
+ // result: (SRAWconst x [uint8(c&31)])
for {
x := v_0
if v_1.Op != OpS390XMOVDconst {
@@ -13739,7 +13739,7 @@ func rewriteValueS390X_OpS390XSRAW(v *Value) bool {
break
}
v.reset(OpS390XSRAWconst)
- v.AuxInt = int8ToAuxInt(int8(c & 31))
+ v.AuxInt = uint8ToAuxInt(uint8(c & 31))
v.AddArg(x)
return true
}
@@ -13756,7 +13756,7 @@ func rewriteValueS390X_OpS390XSRAW(v *Value) bool {
break
}
v.reset(OpS390XSRAWconst)
- v.AuxInt = int8ToAuxInt(31)
+ v.AuxInt = uint8ToAuxInt(31)
v.AddArg(x)
return true
}
@@ -13898,7 +13898,7 @@ func rewriteValueS390X_OpS390XSRAWconst(v *Value) bool {
// match: (SRAWconst x [0])
// result: x
for {
- if auxIntToInt8(v.AuxInt) != 0 {
+ if auxIntToUint8(v.AuxInt) != 0 {
break
}
x := v_0
@@ -13908,7 +13908,7 @@ func rewriteValueS390X_OpS390XSRAWconst(v *Value) bool {
// match: (SRAWconst [c] (MOVDconst [d]))
// result: (MOVDconst [int64(int32(d))>>uint64(c)])
for {
- c := auxIntToInt8(v.AuxInt)
+ c := auxIntToUint8(v.AuxInt)
if v_0.Op != OpS390XMOVDconst {
break
}
@@ -13925,7 +13925,7 @@ func rewriteValueS390X_OpS390XSRD(v *Value) bool {
b := v.Block
typ := &b.Func.Config.Types
// match: (SRD x (MOVDconst [c]))
- // result: (SRDconst x [int8(c&63)])
+ // result: (SRDconst x [uint8(c&63)])
for {
x := v_0
if v_1.Op != OpS390XMOVDconst {
@@ -13933,7 +13933,7 @@ func rewriteValueS390X_OpS390XSRD(v *Value) bool {
}
c := auxIntToInt64(v_1.AuxInt)
v.reset(OpS390XSRDconst)
- v.AuxInt = int8ToAuxInt(int8(c & 63))
+ v.AuxInt = uint8ToAuxInt(uint8(c & 63))
v.AddArg(x)
return true
}
@@ -14073,16 +14073,16 @@ func rewriteValueS390X_OpS390XSRD(v *Value) bool {
func rewriteValueS390X_OpS390XSRDconst(v *Value) bool {
v_0 := v.Args[0]
// match: (SRDconst (SLDconst x [c]) [d])
- // result: (RISBGZ x {s390x.NewRotateParams(d, min8(63, 63-c+d), (c-d)&63)})
+ // result: (RISBGZ x {s390x.NewRotateParams(d, uint8(min8(63, int8(63-c+d))), uint8(int8(c-d)&63))})
for {
- d := auxIntToInt8(v.AuxInt)
+ d := auxIntToUint8(v.AuxInt)
if v_0.Op != OpS390XSLDconst {
break
}
- c := auxIntToInt8(v_0.AuxInt)
+ c := auxIntToUint8(v_0.AuxInt)
x := v_0.Args[0]
v.reset(OpS390XRISBGZ)
- v.Aux = s390xRotateParamsToAux(s390x.NewRotateParams(d, min8(63, 63-c+d), (c-d)&63))
+ v.Aux = s390xRotateParamsToAux(s390x.NewRotateParams(d, uint8(min8(63, int8(63-c+d))), uint8(int8(c-d)&63)))
v.AddArg(x)
return true
}
@@ -14090,7 +14090,7 @@ func rewriteValueS390X_OpS390XSRDconst(v *Value) bool {
// cond: s390x.NewRotateParams(c, 63, -c&63).InMerge(r.OutMask()) != nil
// result: (RISBGZ x {(*s390x.NewRotateParams(c, 63, -c&63).InMerge(r.OutMask())).RotateLeft(r.Amount)})
for {
- c := auxIntToInt8(v.AuxInt)
+ c := auxIntToUint8(v.AuxInt)
if v_0.Op != OpS390XRISBGZ {
break
}
@@ -14107,7 +14107,7 @@ func rewriteValueS390X_OpS390XSRDconst(v *Value) bool {
// match: (SRDconst x [0])
// result: x
for {
- if auxIntToInt8(v.AuxInt) != 0 {
+ if auxIntToUint8(v.AuxInt) != 0 {
break
}
x := v_0
@@ -14123,7 +14123,7 @@ func rewriteValueS390X_OpS390XSRW(v *Value) bool {
typ := &b.Func.Config.Types
// match: (SRW x (MOVDconst [c]))
// cond: c&32 == 0
- // result: (SRWconst x [int8(c&31)])
+ // result: (SRWconst x [uint8(c&31)])
for {
x := v_0
if v_1.Op != OpS390XMOVDconst {
@@ -14134,7 +14134,7 @@ func rewriteValueS390X_OpS390XSRW(v *Value) bool {
break
}
v.reset(OpS390XSRWconst)
- v.AuxInt = int8ToAuxInt(int8(c & 31))
+ v.AuxInt = uint8ToAuxInt(uint8(c & 31))
v.AddArg(x)
return true
}
@@ -14291,7 +14291,7 @@ func rewriteValueS390X_OpS390XSRWconst(v *Value) bool {
// match: (SRWconst x [0])
// result: x
for {
- if auxIntToInt8(v.AuxInt) != 0 {
+ if auxIntToUint8(v.AuxInt) != 0 {
break
}
x := v_0
@@ -14339,7 +14339,7 @@ func rewriteValueS390X_OpS390XSTM2(v *Value) bool {
i := auxIntToInt32(v.AuxInt)
s := auxToSym(v.Aux)
p := v_0
- if v_1.Op != OpS390XSRDconst || auxIntToInt8(v_1.AuxInt) != 32 {
+ if v_1.Op != OpS390XSRDconst || auxIntToUint8(v_1.AuxInt) != 32 {
break
}
x := v_1.Args[0]
@@ -14851,7 +14851,7 @@ func rewriteValueS390X_OpS390XSumBytes2(v *Value) bool {
x := v_0
v.reset(OpS390XADDW)
v0 := b.NewValue0(v.Pos, OpS390XSRWconst, typ.UInt8)
- v0.AuxInt = int8ToAuxInt(8)
+ v0.AuxInt = uint8ToAuxInt(8)
v0.AddArg(x)
v.AddArg2(v0, x)
return true
@@ -14868,7 +14868,7 @@ func rewriteValueS390X_OpS390XSumBytes4(v *Value) bool {
v.reset(OpS390XSumBytes2)
v0 := b.NewValue0(v.Pos, OpS390XADDW, typ.UInt16)
v1 := b.NewValue0(v.Pos, OpS390XSRWconst, typ.UInt16)
- v1.AuxInt = int8ToAuxInt(16)
+ v1.AuxInt = uint8ToAuxInt(16)
v1.AddArg(x)
v0.AddArg2(v1, x)
v.AddArg(v0)
@@ -14886,7 +14886,7 @@ func rewriteValueS390X_OpS390XSumBytes8(v *Value) bool {
v.reset(OpS390XSumBytes4)
v0 := b.NewValue0(v.Pos, OpS390XADDW, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpS390XSRDconst, typ.UInt32)
- v1.AuxInt = int8ToAuxInt(32)
+ v1.AuxInt = uint8ToAuxInt(32)
v1.AddArg(x)
v0.AddArg2(v1, x)
v.AddArg(v0)
@@ -14923,9 +14923,9 @@ func rewriteValueS390X_OpS390XXOR(v *Value) bool {
if v_0.Op != OpS390XSLDconst {
continue
}
- c := auxIntToInt8(v_0.AuxInt)
+ c := auxIntToUint8(v_0.AuxInt)
x := v_0.Args[0]
- if v_1.Op != OpS390XSRDconst || auxIntToInt8(v_1.AuxInt) != 64-c || x != v_1.Args[0] {
+ if v_1.Op != OpS390XSRDconst || auxIntToUint8(v_1.AuxInt) != 64-c || x != v_1.Args[0] {
continue
}
v.reset(OpS390XRISBGZ)
@@ -15019,13 +15019,13 @@ func rewriteValueS390X_OpS390XXORW(v *Value) bool {
if v_0.Op != OpS390XSLWconst {
continue
}
- c := auxIntToInt8(v_0.AuxInt)
+ c := auxIntToUint8(v_0.AuxInt)
x := v_0.Args[0]
- if v_1.Op != OpS390XSRWconst || auxIntToInt8(v_1.AuxInt) != 32-c || x != v_1.Args[0] {
+ if v_1.Op != OpS390XSRWconst || auxIntToUint8(v_1.AuxInt) != 32-c || x != v_1.Args[0] {
continue
}
v.reset(OpS390XRLLconst)
- v.AuxInt = int8ToAuxInt(c)
+ v.AuxInt = uint8ToAuxInt(c)
v.AddArg(x)
return true
}
@@ -15649,7 +15649,7 @@ func rewriteValueS390X_OpSlicemask(v *Value) bool {
t := v.Type
x := v_0
v.reset(OpS390XSRADconst)
- v.AuxInt = int8ToAuxInt(63)
+ v.AuxInt = uint8ToAuxInt(63)
v0 := b.NewValue0(v.Pos, OpS390XNEG, t)
v0.AddArg(x)
v.AddArg(v0)
diff --git a/src/cmd/internal/obj/s390x/rotate.go b/src/cmd/internal/obj/s390x/rotate.go
index 7dbc45e648..388bd40f41 100644
--- a/src/cmd/internal/obj/s390x/rotate.go
+++ b/src/cmd/internal/obj/s390x/rotate.go
@@ -28,9 +28,9 @@ import (
// input left by. Note that this rotation is performed
// before the masked region is used.
type RotateParams struct {
- Start int8 // big-endian start bit index [0..63]
- End int8 // big-endian end bit index [0..63]
- Amount int8 // amount to rotate left
+ Start uint8 // big-endian start bit index [0..63]
+ End uint8 // big-endian end bit index [0..63]
+ Amount uint8 // amount to rotate left
}
// NewRotateParams creates a set of parameters representing a
@@ -39,7 +39,7 @@ type RotateParams struct {
//
// The start and end indexes and the rotation amount must all
// be in the range 0-63 inclusive or this function will panic.
-func NewRotateParams(start, end, amount int8) RotateParams {
+func NewRotateParams(start, end, amount uint8) RotateParams {
if start&^63 != 0 {
panic("start out of bounds")
}
@@ -58,7 +58,7 @@ func NewRotateParams(start, end, amount int8) RotateParams {
// RotateLeft generates a new set of parameters with the rotation amount
// increased by the given value. The selected bits are left unchanged.
-func (r RotateParams) RotateLeft(amount int8) RotateParams {
+func (r RotateParams) RotateLeft(amount uint8) RotateParams {
r.Amount += amount
r.Amount &= 63
return r
@@ -100,8 +100,8 @@ func (r RotateParams) OutMerge(mask uint64) *RotateParams {
}
// update start and end positions (rotation amount remains the same)
- r.Start = int8(o+z) & 63
- r.End = (r.Start + int8(l) - 1) & 63
+ r.Start = uint8(o+z) & 63
+ r.End = (r.Start + uint8(l) - 1) & 63
return &r
}
diff --git a/src/cmd/internal/obj/s390x/rotate_test.go b/src/cmd/internal/obj/s390x/rotate_test.go
index fa5b5bdecd..88421b1b83 100644
--- a/src/cmd/internal/obj/s390x/rotate_test.go
+++ b/src/cmd/internal/obj/s390x/rotate_test.go
@@ -10,7 +10,7 @@ import (
func TestRotateParamsMask(t *testing.T) {
tests := []struct {
- start, end, amount int8
+ start, end, amount uint8
inMask, outMask uint64
}{
// start before end, no rotation
From ce61ccca8f9e101b13b61907024ee48afadca403 Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor
Date: Fri, 11 Dec 2020 19:53:32 -0800
Subject: [PATCH 23/66] test: match gofrontend error messages
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
fixedbugs/issue14136.go:17:16: error: unknown field ‘X’ in ‘T’
fixedbugs/issue14136.go:18:13: error: incompatible type in initialization (cannot use type int as type string)
fixedbugs/issue14520.go:9:37: error: import path contains control character
fixedbugs/issue14520.go:14:2: error: expected ‘)’
fixedbugs/issue14520.go:14:3: error: expected declaration
fixedbugs/issue14652.go:9:7: error: use of undefined type ‘any’
fixedbugs/issue14729.go:13:17: error: embedded type may not be a pointer
fixedbugs/issue15514.dir/c.go:10: error: incompatible type in initialization
fixedbugs/issue15898.go:11:9: error: duplicate type in switch
fixedbugs/issue15898.go:16:9: error: duplicate type in switch
fixedbugs/issue16439.go:10:21: error: index expression is negative
fixedbugs/issue16439.go:13:21: error: index expression is negative
fixedbugs/issue16439.go:16:21: error: index expression is not integer constant
fixedbugs/issue16439.go:18:22: error: index expression is not integer constant
fixedbugs/issue17328.go:11:20: error: expected ‘{’
fixedbugs/issue17328.go:11:20: error: expected ‘;’ or ‘}’ or newline
fixedbugs/issue17328.go:13:1: error: expected declaration
fixedbugs/issue17588.go:14:15: error: expected type
fixedbugs/issue17631.go:20:17: error: unknown field ‘updates’ in ‘unnamed struct’
fixedbugs/issue17645.go:15:13: error: incompatible type in initialization
fixedbugs/issue17758.go:13:1: error: redefinition of ‘foo’
fixedbugs/issue17758.go:9:1: note: previous definition of ‘foo’ was here
fixedbugs/issue18092.go:13:19: error: expected colon
fixedbugs/issue18231.go:17:12: error: may only omit types within composite literals of slice, array, or map type
fixedbugs/issue18393.go:24:38: error: expected type
fixedbugs/issue18419.dir/test.go:12: error: reference to unexported field or method 'member'
fixedbugs/issue18655.go:14:1: error: redefinition of ‘m’
fixedbugs/issue18655.go:13:1: note: previous definition of ‘m’ was here
fixedbugs/issue18655.go:15:1: error: redefinition of ‘m’
fixedbugs/issue18655.go:13:1: note: previous definition of ‘m’ was here
fixedbugs/issue18655.go:16:1: error: redefinition of ‘m’
fixedbugs/issue18655.go:13:1: note: previous definition of ‘m’ was here
fixedbugs/issue18655.go:17:1: error: redefinition of ‘m’
fixedbugs/issue18655.go:13:1: note: previous definition of ‘m’ was here
fixedbugs/issue18655.go:18:1: error: redefinition of ‘m’
fixedbugs/issue18655.go:13:1: note: previous definition of ‘m’ was here
fixedbugs/issue18655.go:20:1: error: redefinition of ‘m’
fixedbugs/issue18655.go:13:1: note: previous definition of ‘m’ was here
fixedbugs/issue18655.go:21:1: error: redefinition of ‘m’
fixedbugs/issue18655.go:13:1: note: previous definition of ‘m’ was here
fixedbugs/issue18655.go:22:1: error: redefinition of ‘m’
fixedbugs/issue18655.go:13:1: note: previous definition of ‘m’ was here
fixedbugs/issue18915.go:13:20: error: expected ‘;’ after statement in if expression
fixedbugs/issue18915.go:16:21: error: parse error in for statement
fixedbugs/issue18915.go:19:24: error: expected ‘;’ after statement in switch expression
fixedbugs/issue18915.go:13:12: error: ‘a’ declared but not used
fixedbugs/issue18915.go:16:13: error: ‘b’ declared but not used
fixedbugs/issue18915.go:19:16: error: ‘c’ declared but not used
fixedbugs/issue19012.go:16:17: error: return with value in function with no return type
fixedbugs/issue19012.go:18:9: error: return with value in function with no return type
fixedbugs/issue19012.go:22:16: error: argument 2 has incompatible type (cannot use type bool as type uint)
fixedbugs/issue19012.go:22:9: error: too many arguments
fixedbugs/issue19012.go:22:16: error: incompatible types in binary expression
fixedbugs/issue19012.go:24:9: error: too many arguments
fixedbugs/issue19056.go:9:9: error: expected operand
fixedbugs/issue19056.go:9:9: error: expected ‘;’ or newline after top level declaration
fixedbugs/issue19482.go:25:15: error: expected struct field name
fixedbugs/issue19482.go:27:15: error: expected struct field name
fixedbugs/issue19482.go:31:19: error: expected struct field name
fixedbugs/issue19482.go:33:15: error: expected struct field name
fixedbugs/issue19667.go:13:1: error: expected operand
fixedbugs/issue19667.go:13:1: error: missing ‘)’
fixedbugs/issue19667.go:13:105: error: expected ‘;’ after statement in if expression
fixedbugs/issue19667.go:13:105: error: expected ‘{’
fixedbugs/issue19667.go:12:19: error: reference to undefined name ‘http’
Change-Id: Ia9c75b9c78671f354f0a0623dbc075157ef8f181
Reviewed-on: https://go-review.googlesource.com/c/go/+/277433
Trust: Ian Lance Taylor
Run-TryBot: Ian Lance Taylor
TryBot-Result: Go Bot
Reviewed-by: Than McIntosh
Reviewed-by: Cherry Zhang
---
test/fixedbugs/issue14136.go | 4 ++--
test/fixedbugs/issue14520.go | 4 ++--
test/fixedbugs/issue14652.go | 2 +-
test/fixedbugs/issue14729.go | 2 +-
test/fixedbugs/issue15514.dir/c.go | 2 +-
test/fixedbugs/issue15898.go | 4 ++--
test/fixedbugs/issue16439.go | 8 ++++----
test/fixedbugs/issue17328.go | 4 ++--
test/fixedbugs/issue17588.go | 2 +-
test/fixedbugs/issue17631.go | 2 +-
test/fixedbugs/issue17645.go | 2 +-
test/fixedbugs/issue17758.go | 2 +-
test/fixedbugs/issue18092.go | 4 ++--
test/fixedbugs/issue18231.go | 2 +-
test/fixedbugs/issue18393.go | 2 +-
test/fixedbugs/issue18419.dir/test.go | 2 +-
test/fixedbugs/issue18655.go | 16 ++++++++--------
test/fixedbugs/issue18915.go | 6 +++---
test/fixedbugs/issue19012.go | 8 ++++----
test/fixedbugs/issue19056.go | 2 +-
test/fixedbugs/issue19482.go | 8 ++++----
test/fixedbugs/issue19667.go | 4 ++--
22 files changed, 46 insertions(+), 46 deletions(-)
diff --git a/test/fixedbugs/issue14136.go b/test/fixedbugs/issue14136.go
index f9efd05f96..38308cd75c 100644
--- a/test/fixedbugs/issue14136.go
+++ b/test/fixedbugs/issue14136.go
@@ -14,6 +14,6 @@ package main
type T struct{}
func main() {
- t := T{X: 1, X: 1, X: 1, X: 1, X: 1, X: 1, X: 1, X: 1, X: 1, X: 1} // ERROR "unknown field 'X' in struct literal of type T"
- var s string = 1 // ERROR "cannot use 1"
+ t := T{X: 1, X: 1, X: 1, X: 1, X: 1, X: 1, X: 1, X: 1, X: 1, X: 1} // ERROR "unknown field 'X' in struct literal of type T|unknown field .*X.* in .*T.*"
+ var s string = 1 // ERROR "cannot use 1|incompatible type"
}
diff --git a/test/fixedbugs/issue14520.go b/test/fixedbugs/issue14520.go
index 84d240faf0..0b840ff4be 100644
--- a/test/fixedbugs/issue14520.go
+++ b/test/fixedbugs/issue14520.go
@@ -9,6 +9,6 @@ package f
import /* // ERROR "import path" */ `
bogus`
-func f(x int /* // ERROR "unexpected newline"
+func f(x int /* // GC_ERROR "unexpected newline"
-*/)
+*/) // GCCGO_ERROR "expected .*\).*|expected declaration"
diff --git a/test/fixedbugs/issue14652.go b/test/fixedbugs/issue14652.go
index b030aee16f..d53b412668 100644
--- a/test/fixedbugs/issue14652.go
+++ b/test/fixedbugs/issue14652.go
@@ -6,4 +6,4 @@
package p
-var x any // ERROR "undefined: any"
+var x any // ERROR "undefined: any|undefined type .*any.*"
diff --git a/test/fixedbugs/issue14729.go b/test/fixedbugs/issue14729.go
index 88e01f9e16..9b30fd2715 100644
--- a/test/fixedbugs/issue14729.go
+++ b/test/fixedbugs/issue14729.go
@@ -10,5 +10,5 @@ package main
import "unsafe"
-type s struct { unsafe.Pointer } // ERROR "embedded type cannot be a pointer"
+type s struct { unsafe.Pointer } // ERROR "embedded type cannot be a pointer|embedded type may not be a pointer"
type s1 struct { p unsafe.Pointer }
diff --git a/test/fixedbugs/issue15514.dir/c.go b/test/fixedbugs/issue15514.dir/c.go
index 11624f9256..dc2ef5bed5 100644
--- a/test/fixedbugs/issue15514.dir/c.go
+++ b/test/fixedbugs/issue15514.dir/c.go
@@ -7,4 +7,4 @@ package c
import "./a"
import "./b"
-var _ a.A = b.B() // ERROR "cannot use b\.B"
+var _ a.A = b.B() // ERROR "cannot use b\.B|incompatible type"
diff --git a/test/fixedbugs/issue15898.go b/test/fixedbugs/issue15898.go
index 7b66ea23dc..94369f9345 100644
--- a/test/fixedbugs/issue15898.go
+++ b/test/fixedbugs/issue15898.go
@@ -8,11 +8,11 @@ package p
func f(e interface{}) {
switch e.(type) {
- case nil, nil: // ERROR "multiple nil cases in type switch"
+ case nil, nil: // ERROR "multiple nil cases in type switch|duplicate type in switch"
}
switch e.(type) {
case nil:
- case nil: // ERROR "multiple nil cases in type switch"
+ case nil: // ERROR "multiple nil cases in type switch|duplicate type in switch"
}
}
diff --git a/test/fixedbugs/issue16439.go b/test/fixedbugs/issue16439.go
index f9382bafcd..704b6b15a6 100644
--- a/test/fixedbugs/issue16439.go
+++ b/test/fixedbugs/issue16439.go
@@ -7,12 +7,12 @@
package p
var a []int = []int{1: 1}
-var b []int = []int{-1: 1} // ERROR "must be non-negative integer constant"
+var b []int = []int{-1: 1} // ERROR "must be non-negative integer constant|index expression is negative"
var c []int = []int{2.0: 2}
-var d []int = []int{-2.0: 2} // ERROR "must be non-negative integer constant"
+var d []int = []int{-2.0: 2} // ERROR "must be non-negative integer constant|index expression is negative"
var e []int = []int{3 + 0i: 3}
-var f []int = []int{3i: 3} // ERROR "truncated to integer"
+var f []int = []int{3i: 3} // ERROR "truncated to integer|index expression is not integer constant"
-var g []int = []int{"a": 4} // ERROR "must be non-negative integer constant"
+var g []int = []int{"a": 4} // ERROR "must be non-negative integer constant|index expression is not integer constant"
diff --git a/test/fixedbugs/issue17328.go b/test/fixedbugs/issue17328.go
index abe4daa353..ef60edbd42 100644
--- a/test/fixedbugs/issue17328.go
+++ b/test/fixedbugs/issue17328.go
@@ -8,6 +8,6 @@ package main
func main() {
i := 0
- for ; ; i++) { // ERROR "unexpected \), expecting { after for clause"
+ for ; ; i++) { // ERROR "unexpected \), expecting { after for clause|expected .*{.*|expected .*;.*"
}
-}
+} // GCCGO_ERROR "expected declaration"
diff --git a/test/fixedbugs/issue17588.go b/test/fixedbugs/issue17588.go
index 1be57c6292..0e3a14ef7c 100644
--- a/test/fixedbugs/issue17588.go
+++ b/test/fixedbugs/issue17588.go
@@ -11,7 +11,7 @@
package p
-type F func(b T) // ERROR "T is not a type"
+type F func(b T) // ERROR "T is not a type|expected type"
func T(fn F) {
func() {
diff --git a/test/fixedbugs/issue17631.go b/test/fixedbugs/issue17631.go
index 79b7e8a751..b820b2d5a7 100644
--- a/test/fixedbugs/issue17631.go
+++ b/test/fixedbugs/issue17631.go
@@ -17,6 +17,6 @@ func main() {
expect map[string]int
}{
about: "this one",
- updates: map[string]int{"gopher": 10}, // ERROR "unknown field 'updates' in struct literal of type"
+ updates: map[string]int{"gopher": 10}, // ERROR "unknown field 'updates' in struct literal of type|unknown field .*updates.* in .*unnamed struct.*"
}
}
diff --git a/test/fixedbugs/issue17645.go b/test/fixedbugs/issue17645.go
index 95fcecd1e0..bb34e4ee97 100644
--- a/test/fixedbugs/issue17645.go
+++ b/test/fixedbugs/issue17645.go
@@ -12,5 +12,5 @@ type Foo struct {
func main() {
var s []int
- var _ string = append(s, Foo{""}) // ERROR "cannot use .. \(type untyped string\) as type int in field value" "cannot use Foo{...} \(type Foo\) as type int in append" "cannot use append\(s\, Foo{...}\) \(type \[\]int\) as type string in assignment"
+ var _ string = append(s, Foo{""}) // ERROR "cannot use .. \(type untyped string\) as type int in field value|incompatible type" "cannot use Foo{...} \(type Foo\) as type int in append" "cannot use append\(s\, Foo{...}\) \(type \[\]int\) as type string in assignment"
}
diff --git a/test/fixedbugs/issue17758.go b/test/fixedbugs/issue17758.go
index e7f2f3af91..8e40f9db73 100644
--- a/test/fixedbugs/issue17758.go
+++ b/test/fixedbugs/issue17758.go
@@ -10,7 +10,7 @@ func foo() {
_ = func() {}
}
-func foo() { // ERROR "foo redeclared in this block"
+func foo() { // ERROR "foo redeclared in this block|redefinition of .*foo.*"
_ = func() {}
}
diff --git a/test/fixedbugs/issue18092.go b/test/fixedbugs/issue18092.go
index 94fd2dd383..a0f7eddda5 100644
--- a/test/fixedbugs/issue18092.go
+++ b/test/fixedbugs/issue18092.go
@@ -10,6 +10,6 @@ func _() {
var ch chan bool
select {
default:
- case <-ch { // don't crash here
- } // ERROR "expecting :"
+ case <-ch { // GCCGO_ERROR "expected colon"
+ } // GC_ERROR "expecting :"
}
diff --git a/test/fixedbugs/issue18231.go b/test/fixedbugs/issue18231.go
index adfd2277ff..7747304052 100644
--- a/test/fixedbugs/issue18231.go
+++ b/test/fixedbugs/issue18231.go
@@ -14,7 +14,7 @@ type T struct {
}
var _ = T{
- f: { // ERROR "missing type in composite literal"
+ f: { // ERROR "missing type in composite literal|may only omit types within"
"a": "b",
},
}
diff --git a/test/fixedbugs/issue18393.go b/test/fixedbugs/issue18393.go
index c16ff4df97..454392721f 100644
--- a/test/fixedbugs/issue18393.go
+++ b/test/fixedbugs/issue18393.go
@@ -21,4 +21,4 @@ var x // error on line 24, not 30
-// ERROR "syntax error: unexpected newline, expecting type"
+// ERROR "syntax error: unexpected newline, expecting type|expected type"
diff --git a/test/fixedbugs/issue18419.dir/test.go b/test/fixedbugs/issue18419.dir/test.go
index 31c6025e3f..da9639dd72 100644
--- a/test/fixedbugs/issue18419.dir/test.go
+++ b/test/fixedbugs/issue18419.dir/test.go
@@ -9,7 +9,7 @@ package main
import "./other"
func InMyCode(e *other.Exported) {
- e.member() // ERROR "e\.member undefined .cannot refer to unexported field or method other\.\(\*Exported\)\.member."
+ e.member() // ERROR "e\.member undefined .cannot refer to unexported field or method other\.\(\*Exported\)\.member.|unexported field or method"
}
func main() {}
diff --git a/test/fixedbugs/issue18655.go b/test/fixedbugs/issue18655.go
index abc2600280..13762f1a94 100644
--- a/test/fixedbugs/issue18655.go
+++ b/test/fixedbugs/issue18655.go
@@ -11,12 +11,12 @@ type A = T
type B = T
func (T) m() {}
-func (T) m() {} // ERROR "redeclared"
-func (A) m() {} // ERROR "redeclared"
-func (A) m() {} // ERROR "redeclared"
-func (B) m() {} // ERROR "redeclared"
-func (B) m() {} // ERROR "redeclared"
+func (T) m() {} // ERROR "redeclared|redefinition"
+func (A) m() {} // ERROR "redeclared|redefinition"
+func (A) m() {} // ERROR "redeclared|redefinition"
+func (B) m() {} // ERROR "redeclared|redefinition"
+func (B) m() {} // ERROR "redeclared|redefinition"
-func (*T) m() {} // ERROR "redeclared"
-func (*A) m() {} // ERROR "redeclared"
-func (*B) m() {} // ERROR "redeclared"
+func (*T) m() {} // ERROR "redeclared|redefinition"
+func (*A) m() {} // ERROR "redeclared|redefinition"
+func (*B) m() {} // ERROR "redeclared|redefinition"
diff --git a/test/fixedbugs/issue18915.go b/test/fixedbugs/issue18915.go
index 66e31e2556..22f97c6b62 100644
--- a/test/fixedbugs/issue18915.go
+++ b/test/fixedbugs/issue18915.go
@@ -10,12 +10,12 @@
package p
func _() {
- if a := 10 { // ERROR "cannot use a := 10 as value"
+ if a := 10 { // ERROR "cannot use a := 10 as value|expected .*;|declared but not used"
}
- for b := 10 { // ERROR "cannot use b := 10 as value"
+ for b := 10 { // ERROR "cannot use b := 10 as value|parse error|declared but not used"
}
- switch c := 10 { // ERROR "cannot use c := 10 as value"
+ switch c := 10 { // ERROR "cannot use c := 10 as value|expected .*;|declared but not used"
}
}
diff --git a/test/fixedbugs/issue19012.go b/test/fixedbugs/issue19012.go
index 636bf06e75..158618aa27 100644
--- a/test/fixedbugs/issue19012.go
+++ b/test/fixedbugs/issue19012.go
@@ -13,13 +13,13 @@ package main
func f(x int, y uint) {
if true {
- return "a" > 10 // ERROR "^too many arguments to return$" "."
+ return "a" > 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 "gopher" == true, 10 // ERROR "^too many arguments to return$|return with value in function with no return|mismatched types"
}
func main() {
- f(2, 3 < "x", 10) // ERROR "^too many arguments in call to f$" "."
+ f(2, 3 < "x", 10) // ERROR "too many arguments|invalid operation|incompatible type"
- f(10, 10, "a") // ERROR "too many arguments in call to f\n\thave \(number, number, string\)\n\twant \(int, uint\)"
+ f(10, 10, "a") // ERROR "too many arguments"
}
diff --git a/test/fixedbugs/issue19056.go b/test/fixedbugs/issue19056.go
index e4e8d07905..d279eaa3cf 100644
--- a/test/fixedbugs/issue19056.go
+++ b/test/fixedbugs/issue19056.go
@@ -6,4 +6,4 @@
package p
-var _ = ... . // ERROR "unexpected ..."
+var _ = ... . // ERROR "unexpected ...|expected operand|expected .*;"
diff --git a/test/fixedbugs/issue19482.go b/test/fixedbugs/issue19482.go
index 97497a434c..4c2c19ec9d 100644
--- a/test/fixedbugs/issue19482.go
+++ b/test/fixedbugs/issue19482.go
@@ -22,13 +22,13 @@ func ok() {
var (
y = T{"stare"}
- w = T{_: "look"} // ERROR "invalid field name _ in struct initializer"
+ w = T{_: "look"} // ERROR "invalid field name _ in struct initializer|expected struct field name"
_ = T{"page"}
- _ = T{_: "out"} // ERROR "invalid field name _ in struct initializer"
+ _ = T{_: "out"} // ERROR "invalid field name _ in struct initializer|expected struct field name"
)
func bad() {
- var z = T{_: "verse"} // ERROR "invalid field name _ in struct initializer"
+ var z = T{_: "verse"} // ERROR "invalid field name _ in struct initializer|expected struct field name"
_ = z
- _ = T{_: "itinerary"} // ERROR "invalid field name _ in struct initializer"
+ _ = T{_: "itinerary"} // ERROR "invalid field name _ in struct initializer|expected struct field name"
}
diff --git a/test/fixedbugs/issue19667.go b/test/fixedbugs/issue19667.go
index c94a11d871..e33e350487 100644
--- a/test/fixedbugs/issue19667.go
+++ b/test/fixedbugs/issue19667.go
@@ -9,5 +9,5 @@
package p
func f() {
- if err := http.ListenAndServe(
-} // ERROR "unexpected }, expecting expression"
+ if err := http.ListenAndServe( // GCCGO_ERROR "undefined name"
+} // ERROR "unexpected }, expecting expression|expected operand|missing .*\)|expected .*;|expected .*{"
From be10af7c4e818566f0b19fb9ffefce2853722842 Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor
Date: Sun, 13 Dec 2020 22:48:02 -0800
Subject: [PATCH 24/66] test: match gofrontend error messages
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
fixedbugs/issue20602.go:13:9: error: argument must have complex type
fixedbugs/issue20602.go:14:9: error: argument must have complex type
fixedbugs/issue19323.go:12:12: error: attempt to slice object that is not array, slice, or string
fixedbugs/issue19323.go:18:13: error: attempt to slice object that is not array, slice, or string
fixedbugs/issue20749.go:12:11: error: array index out of bounds
fixedbugs/issue20749.go:15:11: error: array index out of bounds
fixedbugs/issue20415.go:14:5: error: redefinition of ‘f’
fixedbugs/issue20415.go:12:5: note: previous definition of ‘f’ was here
fixedbugs/issue20415.go:25:5: error: redefinition of ‘g’
fixedbugs/issue20415.go:20:5: note: previous definition of ‘g’ was here
fixedbugs/issue20415.go:33:5: error: redefinition of ‘h’
fixedbugs/issue20415.go:31:5: note: previous definition of ‘h’ was here
fixedbugs/issue19977.go:12:21: error: reference to undefined name ‘a’
fixedbugs/issue20812.go:10:13: error: invalid type conversion (cannot use type string as type int)
fixedbugs/issue20812.go:11:13: error: invalid type conversion (cannot use type int as type bool)
fixedbugs/issue20812.go:12:13: error: invalid type conversion (cannot use type string as type bool)
fixedbugs/issue20812.go:13:13: error: invalid type conversion (cannot use type bool as type int)
fixedbugs/issue20812.go:14:13: error: invalid type conversion (cannot use type bool as type string)
fixedbugs/issue21256.go:9:5: error: redefinition of ‘main’
fixedbugs/issue20813.go:10:11: error: invalid left hand side of assignment
fixedbugs/issue20185.go:22:16: error: ‘t’ declared but not used
fixedbugs/issue20185.go:13:9: error: cannot type switch on non-interface value
fixedbugs/issue20185.go:22:9: error: cannot type switch on non-interface value
fixedbugs/issue20227.go:11:11: error: division by zero
fixedbugs/issue20227.go:12:12: error: division by zero
fixedbugs/issue20227.go:13:12: error: division by zero
fixedbugs/issue20227.go:15:11: error: division by zero
fixedbugs/issue20227.go:16:12: error: division by zero
fixedbugs/issue19880.go:14:13: error: invalid use of type
fixedbugs/issue23093.go:9:5: error: initialization expression for ‘f’ depends upon itself
fixedbugs/issue21979.go:29:13: error: integer constant overflow
fixedbugs/issue21979.go:39:13: error: complex constant truncated to floating-point
fixedbugs/issue21979.go:10:13: error: invalid type conversion (cannot use type string as type bool)
fixedbugs/issue21979.go:11:13: error: invalid type conversion (cannot use type int as type bool)
fixedbugs/issue21979.go:12:13: error: invalid type conversion (cannot use type float64 as type bool)
fixedbugs/issue21979.go:13:13: error: invalid type conversion (cannot use type complex128 as type bool)
fixedbugs/issue21979.go:15:13: error: invalid type conversion (cannot use type bool as type string)
fixedbugs/issue21979.go:17:13: error: invalid type conversion (cannot use type float64 as type string)
fixedbugs/issue21979.go:18:13: error: invalid type conversion (cannot use type complex128 as type string)
fixedbugs/issue21979.go:20:13: error: invalid type conversion (cannot use type string as type int)
fixedbugs/issue21979.go:21:13: error: invalid type conversion (cannot use type bool as type int)
fixedbugs/issue21979.go:27:13: error: invalid type conversion (cannot use type string as type uint)
fixedbugs/issue21979.go:28:13: error: invalid type conversion (cannot use type bool as type uint)
fixedbugs/issue21979.go:34:13: error: invalid type conversion (cannot use type string as type float64)
fixedbugs/issue21979.go:35:13: error: invalid type conversion (cannot use type bool as type float64)
fixedbugs/issue21979.go:41:13: error: invalid type conversion (cannot use type string as type complex128)
fixedbugs/issue21979.go:42:13: error: invalid type conversion (cannot use type bool as type complex128)
fixedbugs/issue21988.go:11:11: error: reference to undefined name ‘Wrong’
fixedbugs/issue22063.go:11:11: error: reference to undefined name ‘Wrong’
fixedbugs/issue22904.go:12:6: error: invalid recursive type ‘a’
fixedbugs/issue22904.go:13:6: error: invalid recursive type ‘b’
fixedbugs/issue22921.go:11:16: error: reference to undefined identifier ‘bytes.nonexist’
fixedbugs/issue22921.go:13:19: error: reference to undefined identifier ‘bytes.nonexist’
fixedbugs/issue22921.go:13:19: error: expected signature or type name
fixedbugs/issue22921.go:17:15: error: reference to undefined identifier ‘bytes.buffer’
fixedbugs/issue23823.go:15:9: error: invalid recursive interface
fixedbugs/issue23823.go:10:9: error: invalid recursive interface
fixedbugs/issue23732.go:24:13: error: too few expressions for struct
fixedbugs/issue23732.go:34:17: error: too many expressions for struct
fixedbugs/issue23732.go:37:13: error: too few expressions for struct
fixedbugs/issue23732.go:40:17: error: too many expressions for struct
fixedbugs/issue22794.go:16:14: error: reference to undefined field or method ‘floats’
fixedbugs/issue22794.go:18:19: error: unknown field ‘floats’ in ‘it’
fixedbugs/issue22794.go:19:17: error: unknown field ‘InneR’ in ‘it’
fixedbugs/issue22794.go:18:9: error: ‘i2’ declared but not used
fixedbugs/issue22822.go:15:17: error: expected function
fixedbugs/issue25727.go:12:10: error: reference to unexported field or method ‘doneChan’
fixedbugs/issue25727.go:13:10: error: reference to undefined field or method ‘DoneChan’
fixedbugs/issue25727.go:14:21: error: unknown field ‘tlsConfig’ in ‘http.Server’
fixedbugs/issue25727.go:15:21: error: unknown field ‘DoneChan’ in ‘http.Server’
fixedbugs/issue25727.go:21:14: error: unknown field ‘bAr’ in ‘foo’
Change-Id: I32ce0b7d80017b2367b8fb479a881632240d4161
Reviewed-on: https://go-review.googlesource.com/c/go/+/277455
Trust: Ian Lance Taylor
Run-TryBot: Ian Lance Taylor
TryBot-Result: Go Bot
Reviewed-by: Than McIntosh
---
test/fixedbugs/issue19323.go | 4 ++--
test/fixedbugs/issue19880.go | 2 +-
test/fixedbugs/issue19977.go | 2 +-
test/fixedbugs/issue20185.go | 4 ++--
test/fixedbugs/issue20227.go | 10 +++++-----
test/fixedbugs/issue20415.go | 6 +++---
test/fixedbugs/issue20529.go | 2 +-
test/fixedbugs/issue20602.go | 4 ++--
test/fixedbugs/issue20749.go | 4 ++--
test/fixedbugs/issue20780.go | 2 +-
test/fixedbugs/issue20812.go | 10 +++++-----
test/fixedbugs/issue20813.go | 2 +-
test/fixedbugs/issue21256.go | 2 +-
test/fixedbugs/issue21273.go | 2 +-
test/fixedbugs/issue21979.go | 34 +++++++++++++++++-----------------
test/fixedbugs/issue21988.go | 2 +-
test/fixedbugs/issue22063.go | 2 +-
test/fixedbugs/issue22200.go | 2 +-
test/fixedbugs/issue22200b.go | 6 +++---
test/fixedbugs/issue22794.go | 6 +++---
test/fixedbugs/issue22822.go | 2 +-
test/fixedbugs/issue22904.go | 2 +-
test/fixedbugs/issue22921.go | 6 +++---
test/fixedbugs/issue23093.go | 2 +-
test/fixedbugs/issue23732.go | 10 +++++-----
test/fixedbugs/issue23823.go | 6 +++---
test/fixedbugs/issue24339.go | 2 +-
test/fixedbugs/issue25507.go | 6 +++---
test/fixedbugs/issue25727.go | 10 +++++-----
29 files changed, 77 insertions(+), 77 deletions(-)
diff --git a/test/fixedbugs/issue19323.go b/test/fixedbugs/issue19323.go
index f90af660d5..71365e10dd 100644
--- a/test/fixedbugs/issue19323.go
+++ b/test/fixedbugs/issue19323.go
@@ -9,11 +9,11 @@ package p
func g() {}
func f() {
- g()[:] // ERROR "g.. used as value"
+ g()[:] // ERROR "g.. used as value|attempt to slice object that is not"
}
func g2() ([]byte, []byte) { return nil, nil }
func f2() {
- g2()[:] // ERROR "multiple-value g2.. in single-value context"
+ g2()[:] // ERROR "multiple-value g2.. in single-value context|attempt to slice object that is not"
}
diff --git a/test/fixedbugs/issue19880.go b/test/fixedbugs/issue19880.go
index 629c95d960..3d83cf3a12 100644
--- a/test/fixedbugs/issue19880.go
+++ b/test/fixedbugs/issue19880.go
@@ -11,7 +11,7 @@ type T struct {
}
func a() {
- _ = T // ERROR "type T is not an expression"
+ _ = T // ERROR "type T is not an expression|invalid use of type"
}
func b() {
diff --git a/test/fixedbugs/issue19977.go b/test/fixedbugs/issue19977.go
index 3db1dfd636..6e4a9cc422 100644
--- a/test/fixedbugs/issue19977.go
+++ b/test/fixedbugs/issue19977.go
@@ -9,7 +9,7 @@
package foo
func Foo() {
- switch x := a.(type) { // ERROR "undefined: a"
+ switch x := a.(type) { // ERROR "undefined: a|reference to undefined name .*a"
default:
_ = x
}
diff --git a/test/fixedbugs/issue20185.go b/test/fixedbugs/issue20185.go
index 2cbb143ed0..9065868d7f 100644
--- a/test/fixedbugs/issue20185.go
+++ b/test/fixedbugs/issue20185.go
@@ -10,7 +10,7 @@
package p
func F() {
- switch t := nil.(type) { // ERROR "cannot type switch on non-interface value nil"
+ switch t := nil.(type) { // ERROR "cannot type switch on non-interface value"
default:
_ = t
}
@@ -19,7 +19,7 @@ func F() {
const x = 1
func G() {
- switch t := x.(type) { // ERROR "cannot type switch on non-interface value x \(type untyped int\)"
+ switch t := x.(type) { // ERROR "cannot type switch on non-interface value|declared but not used"
default:
}
}
diff --git a/test/fixedbugs/issue20227.go b/test/fixedbugs/issue20227.go
index 4448eb5438..f59923106d 100644
--- a/test/fixedbugs/issue20227.go
+++ b/test/fixedbugs/issue20227.go
@@ -8,9 +8,9 @@
package p
-var _ = 1 / 1e-600000000i // ERROR "complex division by zero"
-var _ = 1i / 1e-600000000 // ERROR "complex division by zero"
-var _ = 1i / 1e-600000000i // ERROR "complex division by zero"
+var _ = 1 / 1e-600000000i // ERROR "division by zero"
+var _ = 1i / 1e-600000000 // ERROR "division by zero"
+var _ = 1i / 1e-600000000i // ERROR "division by zero"
-var _ = 1 / (1e-600000000 + 1e-600000000i) // ERROR "complex division by zero"
-var _ = 1i / (1e-600000000 + 1e-600000000i) // ERROR "complex division by zero"
+var _ = 1 / (1e-600000000 + 1e-600000000i) // ERROR "division by zero"
+var _ = 1i / (1e-600000000 + 1e-600000000i) // ERROR "division by zero"
diff --git a/test/fixedbugs/issue20415.go b/test/fixedbugs/issue20415.go
index 6f2c342ce4..9e7649fc95 100644
--- a/test/fixedbugs/issue20415.go
+++ b/test/fixedbugs/issue20415.go
@@ -11,7 +11,7 @@ package p
// 1
var f byte
-var f interface{} // ERROR "previous declaration at issue20415.go:12"
+var f interface{} // ERROR "previous declaration at issue20415.go:12|redefinition"
func _(f int) {
}
@@ -22,7 +22,7 @@ var g byte
func _(g int) {
}
-var g interface{} // ERROR "previous declaration at issue20415.go:20"
+var g interface{} // ERROR "previous declaration at issue20415.go:20|redefinition"
// 3
func _(h int) {
@@ -30,4 +30,4 @@ func _(h int) {
var h byte
-var h interface{} // ERROR "previous declaration at issue20415.go:31"
+var h interface{} // ERROR "previous declaration at issue20415.go:31|redefinition"
diff --git a/test/fixedbugs/issue20529.go b/test/fixedbugs/issue20529.go
index 669064c2ea..eeaaf37358 100644
--- a/test/fixedbugs/issue20529.go
+++ b/test/fixedbugs/issue20529.go
@@ -15,7 +15,7 @@ package p
import "runtime"
-func f() { // ERROR "stack frame too large"
+func f() { // GC_ERROR "stack frame too large"
x := [][]int{1e9: []int{}}
runtime.KeepAlive(x)
}
diff --git a/test/fixedbugs/issue20602.go b/test/fixedbugs/issue20602.go
index ca4ce095aa..d4d513b050 100644
--- a/test/fixedbugs/issue20602.go
+++ b/test/fixedbugs/issue20602.go
@@ -10,5 +10,5 @@
package p
var p = &[1]complex128{0}
-var _ = real(p) // ERROR "type \*\[1\]complex128"
-var _ = imag(p) // ERROR "type \*\[1\]complex128"
+var _ = real(p) // ERROR "type \*\[1\]complex128|argument must have complex type"
+var _ = imag(p) // ERROR "type \*\[1\]complex128|argument must have complex type"
diff --git a/test/fixedbugs/issue20749.go b/test/fixedbugs/issue20749.go
index af9ff3fbed..de2d3ad16a 100644
--- a/test/fixedbugs/issue20749.go
+++ b/test/fixedbugs/issue20749.go
@@ -9,7 +9,7 @@ package p
// Verify that the compiler complains even if the array
// has length 0.
var a [0]int
-var _ = a[2:] // ERROR "invalid slice index 2"
+var _ = a[2:] // ERROR "invalid slice index 2|array index out of bounds"
var b [1]int
-var _ = b[2:] // ERROR "invalid slice index 2"
+var _ = b[2:] // ERROR "invalid slice index 2|array index out of bounds"
diff --git a/test/fixedbugs/issue20780.go b/test/fixedbugs/issue20780.go
index 58952e53ee..53c4f615e1 100644
--- a/test/fixedbugs/issue20780.go
+++ b/test/fixedbugs/issue20780.go
@@ -9,7 +9,7 @@
package main
-func f() { // ERROR "stack frame too large"
+func f() { // GC_ERROR "stack frame too large"
var x [800e6]byte
g(x)
return
diff --git a/test/fixedbugs/issue20812.go b/test/fixedbugs/issue20812.go
index 0175eede17..d0df831dfd 100644
--- a/test/fixedbugs/issue20812.go
+++ b/test/fixedbugs/issue20812.go
@@ -7,9 +7,9 @@
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"
+ _ = int("1") // ERROR "cannot convert|invalid type conversion"
+ _ = bool(0) // ERROR "cannot convert|invalid type conversion"
+ _ = bool("false") // ERROR "cannot convert|invalid type conversion"
+ _ = int(false) // ERROR "cannot convert|invalid type conversion"
+ _ = string(true) // ERROR "cannot convert|invalid type conversion"
}
diff --git a/test/fixedbugs/issue20813.go b/test/fixedbugs/issue20813.go
index b931aea592..b147a8903c 100644
--- a/test/fixedbugs/issue20813.go
+++ b/test/fixedbugs/issue20813.go
@@ -7,5 +7,5 @@
package p
func f() {
- 1 = 2 // ERROR "cannot assign to 1"
+ 1 = 2 // ERROR "cannot assign to 1|invalid left hand side"
}
diff --git a/test/fixedbugs/issue21256.go b/test/fixedbugs/issue21256.go
index 3d3612478d..c845ec52b3 100644
--- a/test/fixedbugs/issue21256.go
+++ b/test/fixedbugs/issue21256.go
@@ -6,4 +6,4 @@
package main
-var main = func() {} // ERROR "must be func"
+var main = func() {} // ERROR "must be func|redefinition"
diff --git a/test/fixedbugs/issue21273.go b/test/fixedbugs/issue21273.go
index 7a790d14b5..77a1abad9b 100644
--- a/test/fixedbugs/issue21273.go
+++ b/test/fixedbugs/issue21273.go
@@ -24,5 +24,5 @@ func g() {
func h() {
type T4 struct{ m map[T4]int } // ERROR "invalid map key"
- type _ map[T4]int // ERROR "invalid map key"
+ type _ map[T4]int // GC_ERROR "invalid map key"
}
diff --git a/test/fixedbugs/issue21979.go b/test/fixedbugs/issue21979.go
index 1c02f574c3..addf786c03 100644
--- a/test/fixedbugs/issue21979.go
+++ b/test/fixedbugs/issue21979.go
@@ -7,39 +7,39 @@
package p
func f() {
- _ = bool("") // ERROR "cannot convert .. \(type untyped string\) to type bool"
- _ = bool(1) // ERROR "cannot convert 1 \(type untyped int\) to type bool"
- _ = bool(1.0) // ERROR "cannot convert 1 \(type untyped float\) to type bool"
- _ = bool(-4 + 2i) // ERROR "cannot convert -4 \+ 2i \(type untyped complex\) to type bool"
+ _ = 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"
- _ = string(true) // ERROR "cannot convert true \(type untyped bool\) to type string"
+ _ = string(true) // ERROR "cannot convert true \(type untyped bool\) to type string|invalid type conversion"
_ = string(-1)
- _ = string(1.0) // ERROR "cannot convert 1 \(type untyped float\) to type string"
- _ = string(-4 + 2i) // ERROR "cannot convert -4 \+ 2i \(type untyped complex\) to type string"
+ _ = 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"
- _ = int("") // ERROR "cannot convert .. \(type untyped string\) to type int"
- _ = int(true) // ERROR "cannot convert true \(type untyped bool\) to type int"
+ _ = 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(-1)
_ = int(1)
_ = int(1.0)
_ = int(-4 + 2i) // ERROR "truncated to integer"
- _ = uint("") // ERROR "cannot convert .. \(type untyped string\) to type uint"
- _ = uint(true) // ERROR "cannot convert true \(type untyped bool\) to type uint"
- _ = uint(-1) // ERROR "constant -1 overflows uint"
+ _ = 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(1)
_ = uint(1.0)
_ = uint(-4 + 2i) // ERROR "constant -4 overflows uint" "truncated to integer"
- _ = float64("") // ERROR "cannot convert .. \(type untyped string\) to type float64"
- _ = float64(true) // ERROR "cannot convert true \(type untyped bool\) to type float64"
+ _ = 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(-1)
_ = float64(1)
_ = float64(1.0)
- _ = float64(-4 + 2i) // ERROR "truncated to real"
+ _ = float64(-4 + 2i) // ERROR "truncated to"
- _ = complex128("") // ERROR "cannot convert .. \(type untyped string\) to type complex128"
- _ = complex128(true) // ERROR "cannot convert true \(type untyped bool\) to type complex128"
+ _ = 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(-1)
_ = complex128(1)
_ = complex128(1.0)
diff --git a/test/fixedbugs/issue21988.go b/test/fixedbugs/issue21988.go
index 850e0398d6..4dbf06ee31 100644
--- a/test/fixedbugs/issue21988.go
+++ b/test/fixedbugs/issue21988.go
@@ -8,7 +8,7 @@
package p
-const X = Wrong(0) // ERROR "undefined: Wrong"
+const X = Wrong(0) // ERROR "undefined: Wrong|undefined name .*Wrong"
func _() {
switch 0 {
diff --git a/test/fixedbugs/issue22063.go b/test/fixedbugs/issue22063.go
index bfdb2e0027..8d84047e07 100644
--- a/test/fixedbugs/issue22063.go
+++ b/test/fixedbugs/issue22063.go
@@ -8,7 +8,7 @@
package p
-const X = Wrong(0) // ERROR "undefined: Wrong"
+const X = Wrong(0) // ERROR "undefined: Wrong|reference to undefined name .*Wrong"
func _() {
switch interface{}(nil) {
diff --git a/test/fixedbugs/issue22200.go b/test/fixedbugs/issue22200.go
index 66b9538e03..37440d9bf0 100644
--- a/test/fixedbugs/issue22200.go
+++ b/test/fixedbugs/issue22200.go
@@ -12,7 +12,7 @@ func f1(x *[1<<30 - 1e6]byte) byte {
}
return 0
}
-func f2(x *[1<<30 + 1e6]byte) byte { // ERROR "stack frame too large"
+func f2(x *[1<<30 + 1e6]byte) byte { // GC_ERROR "stack frame too large"
for _, b := range *x {
return b
}
diff --git a/test/fixedbugs/issue22200b.go b/test/fixedbugs/issue22200b.go
index 8d4515eb05..ce20923334 100644
--- a/test/fixedbugs/issue22200b.go
+++ b/test/fixedbugs/issue22200b.go
@@ -8,19 +8,19 @@
package p
-func f3(x *[1 << 31]byte) byte { // ERROR "stack frame too large"
+func f3(x *[1 << 31]byte) byte { // GC_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"
+func f4(x *[1 << 32]byte) byte { // GC_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"
+func f5(x *[1 << 33]byte) byte { // GC_ERROR "stack frame too large"
for _, b := range *x {
return b
}
diff --git a/test/fixedbugs/issue22794.go b/test/fixedbugs/issue22794.go
index c7e9eb1224..2ac31ef0c7 100644
--- a/test/fixedbugs/issue22794.go
+++ b/test/fixedbugs/issue22794.go
@@ -13,8 +13,8 @@ type it struct {
func main() {
i1 := it{Floats: true}
- if i1.floats { // ERROR "(type it .* field or method floats, but does have Floats)"
+ if i1.floats { // ERROR "(type it .* field or method floats, but does have Floats)|undefined field or method"
}
- i2 := &it{floats: false} // ERROR "(but does have Floats)"
- _ = &it{InneR: "foo"} // ERROR "(but does have inner)"
+ i2 := &it{floats: false} // ERROR "(but does have Floats)|unknown field|declared but not used"
+ _ = &it{InneR: "foo"} // ERROR "(but does have inner)|unknown field"
}
diff --git a/test/fixedbugs/issue22822.go b/test/fixedbugs/issue22822.go
index e449ddb186..ea53452f09 100644
--- a/test/fixedbugs/issue22822.go
+++ b/test/fixedbugs/issue22822.go
@@ -12,5 +12,5 @@ package main
func F() {
slice := []int{1, 2, 3}
len := int(2)
- println(len(slice)) // ERROR "cannot call non-function len .type int., declared at"
+ println(len(slice)) // ERROR "cannot call non-function len .type int., declared at|expected function"
}
diff --git a/test/fixedbugs/issue22904.go b/test/fixedbugs/issue22904.go
index 09f4a2118e..02459c6a4e 100644
--- a/test/fixedbugs/issue22904.go
+++ b/test/fixedbugs/issue22904.go
@@ -10,7 +10,7 @@
package p
type a struct{ b } // ERROR "invalid recursive type"
-type b struct{ a }
+type b struct{ a } // GCCGO_ERROR "invalid recursive type"
var x interface{}
diff --git a/test/fixedbugs/issue22921.go b/test/fixedbugs/issue22921.go
index 04f78b2c08..5336ba3410 100644
--- a/test/fixedbugs/issue22921.go
+++ b/test/fixedbugs/issue22921.go
@@ -8,11 +8,11 @@ package main
import "bytes"
-type _ struct{ bytes.nonexist } // ERROR "unexported"
+type _ struct{ bytes.nonexist } // ERROR "unexported|undefined"
-type _ interface{ bytes.nonexist } // ERROR "unexported"
+type _ interface{ bytes.nonexist } // ERROR "unexported|undefined|expected signature or type name"
func main() {
var _ bytes.Buffer
- var _ bytes.buffer // ERROR "unexported"
+ var _ bytes.buffer // ERROR "unexported|undefined"
}
diff --git a/test/fixedbugs/issue23093.go b/test/fixedbugs/issue23093.go
index 2fd7d5fff1..7b2865ca41 100644
--- a/test/fixedbugs/issue23093.go
+++ b/test/fixedbugs/issue23093.go
@@ -6,4 +6,4 @@
package p
-var f = func() { f() } // ERROR "initialization loop"
+var f = func() { f() } // ERROR "initialization loop|initialization expression for .*f.* depends upon itself"
diff --git a/test/fixedbugs/issue23732.go b/test/fixedbugs/issue23732.go
index 5e63eb2074..db2d182234 100644
--- a/test/fixedbugs/issue23732.go
+++ b/test/fixedbugs/issue23732.go
@@ -21,22 +21,22 @@ type Bar struct {
}
func main() {
- _ = Foo{
+ _ = Foo{ // GCCGO_ERROR "too few expressions"
1,
2,
- 3, // ERROR "too few values in Foo{...}"
+ 3, // GC_ERROR "too few values in Foo{...}"
}
_ = Foo{
1,
2,
3,
- Bar{"A", "B"}, // ERROR "too many values in Bar{...}"
+ Bar{"A", "B"}, // ERROR "too many values in Bar{...}|too many expressions"
}
- _ = Foo{
+ _ = Foo{ // GCCGO_ERROR "too few expressions"
1,
2,
- Bar{"A", "B"}, // ERROR "too many values in Bar{...}" "too few values in Foo{...}"
+ Bar{"A", "B"}, // ERROR "too many values in Bar{...}|too many expressions" "too few values in Foo{...}"
}
}
diff --git a/test/fixedbugs/issue23823.go b/test/fixedbugs/issue23823.go
index fe6cef1fb4..c440c96315 100644
--- a/test/fixedbugs/issue23823.go
+++ b/test/fixedbugs/issue23823.go
@@ -7,10 +7,10 @@
package p
type I1 = interface {
- I2
+ I2 // GCCGO_ERROR "invalid recursive interface"
}
// BAD: type loop should mention I1; see also #41669
-type I2 interface { // ERROR "invalid recursive type I2\n\tLINE: I2 refers to\n\tLINE: I2$"
- I1
+type I2 interface { // GC_ERROR "invalid recursive type I2\n\tLINE: I2 refers to\n\tLINE: I2$"
+ I1 // GCCGO_ERROR "invalid recursive interface"
}
diff --git a/test/fixedbugs/issue24339.go b/test/fixedbugs/issue24339.go
index 502c575ec8..2cca7f8bda 100644
--- a/test/fixedbugs/issue24339.go
+++ b/test/fixedbugs/issue24339.go
@@ -17,4 +17,4 @@ var _ = struct{}{ /*line :20:1*/foo /*line :21:1*/: /*line :22:1*/0 }
-// ERROR "unknown field 'foo'"
\ No newline at end of file
+// ERROR "unknown field 'foo'"
diff --git a/test/fixedbugs/issue25507.go b/test/fixedbugs/issue25507.go
index 8dcbae16ab..9143a73397 100644
--- a/test/fixedbugs/issue25507.go
+++ b/test/fixedbugs/issue25507.go
@@ -16,14 +16,14 @@ type large struct {
b [1500000000]byte
}
-func (x large) f1() int { // ERROR "stack frame too large"
+func (x large) f1() int { // GC_ERROR "stack frame too large"
return 5
}
-func f2(x large) int { // ERROR "stack frame too large"
+func f2(x large) int { // GC_ERROR "stack frame too large"
return 5
}
-func f3() (x large, i int) { // ERROR "stack frame too large"
+func f3() (x large, i int) { // GC_ERROR "stack frame too large"
return
}
diff --git a/test/fixedbugs/issue25727.go b/test/fixedbugs/issue25727.go
index da7c94cc12..936b9f8ff5 100644
--- a/test/fixedbugs/issue25727.go
+++ b/test/fixedbugs/issue25727.go
@@ -9,13 +9,13 @@ package main
import "net/http"
var s = http.Server{}
-var _ = s.doneChan // ERROR "s.doneChan undefined .cannot refer to unexported field or method doneChan.$"
-var _ = s.DoneChan // ERROR "s.DoneChan undefined .type http.Server has no field or method DoneChan.$"
-var _ = http.Server{tlsConfig: nil} // ERROR "unknown field 'tlsConfig' in struct literal.+ .but does have TLSConfig.$"
-var _ = http.Server{DoneChan: nil} // ERROR "unknown field 'DoneChan' in struct literal of type http.Server$"
+var _ = s.doneChan // ERROR "s.doneChan undefined .cannot refer to unexported field or method doneChan.$|unexported field or method"
+var _ = s.DoneChan // ERROR "s.DoneChan undefined .type http.Server has no field or method DoneChan.$|undefined field or method"
+var _ = http.Server{tlsConfig: nil} // ERROR "unknown field 'tlsConfig' in struct literal.+ .but does have TLSConfig.$|unknown field .?tlsConfig.? in .?http.Server"
+var _ = http.Server{DoneChan: nil} // ERROR "unknown field 'DoneChan' in struct literal of type http.Server$|unknown field .?DoneChan.? in .?http.Server"
type foo struct {
bar int
}
-var _ = &foo{bAr: 10} // ERROR "unknown field 'bAr' in struct literal.+ .but does have bar.$"
+var _ = &foo{bAr: 10} // ERROR "unknown field 'bAr' in struct literal.+ .but does have bar.$|unknown field .?bAr.? in .?foo"
From 828746ec57e76e49527791bca500b27b77576d79 Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor
Date: Fri, 11 Dec 2020 15:15:43 -0800
Subject: [PATCH 25/66] debug/dwarf: don't try to parse addr/rnglists header
In an executable, the debug_addr and debug_rnglists sections are
assembled by concatenating the input sections, and each input section
has a header, and each header may have different attributes. So just
parsing the single header isn't right. Parsing the header is not
necessary to handle offsets into these sections which is all we do.
Looking at the header is also problematic because GCC with
-gsplit-dwarf when using DWARF versions 2 through 4 emits a
.debug_addr section, but it has no header. The header was only added
for DWARF 5. So we can't parse the header at all for that case, and we
can't even detect that case in general.
This CL also fixes SeekPC with addrx and strx formats, by not using
the wrong compilation unit to find the address or string base.
To make that work when parsing the compilation unit itself, we add
support for delay the resolution of those values until we know the base.
New test binaries built with
gcc -gdwarf-5 -no-pie debug/dwarf/testdata/line[12].c
(gcc (Debian 10.2.0-15) 10.2.0)
clang -gdwarf-5 -no-pie debug/dwarf/testdata/line[12].c
(clang version 9.0.1-14)
Change-Id: I66783e0eded629bf80c467767f781164d344a54d
Reviewed-on: https://go-review.googlesource.com/c/go/+/277233
Trust: Ian Lance Taylor
Reviewed-by: Than McIntosh
---
src/debug/dwarf/dwarf5ranges_test.go | 7 +-
src/debug/dwarf/entry.go | 123 ++++++++++++------
src/debug/dwarf/entry_test.go | 102 ++++++++++-----
src/debug/dwarf/open.go | 85 +-----------
.../dwarf/testdata/line-clang-dwarf5.elf | Bin 0 -> 18384 bytes
src/debug/dwarf/testdata/line-gcc-dwarf5.elf | Bin 0 -> 18040 bytes
6 files changed, 165 insertions(+), 152 deletions(-)
create mode 100644 src/debug/dwarf/testdata/line-clang-dwarf5.elf
create mode 100644 src/debug/dwarf/testdata/line-gcc-dwarf5.elf
diff --git a/src/debug/dwarf/dwarf5ranges_test.go b/src/debug/dwarf/dwarf5ranges_test.go
index 0ff1a55bc9..8bc50bcab6 100644
--- a/src/debug/dwarf/dwarf5ranges_test.go
+++ b/src/debug/dwarf/dwarf5ranges_test.go
@@ -22,7 +22,12 @@ func TestDwarf5Ranges(t *testing.T) {
if err := d.AddSection(".debug_rnglists", rngLists); err != nil {
t.Fatal(err)
}
- ret, err := d.dwarf5Ranges(nil, 0x5fbd, 0xc, [][2]uint64{})
+ u := &unit{
+ asize: 8,
+ vers: 5,
+ is64: true,
+ }
+ ret, err := d.dwarf5Ranges(u, nil, 0x5fbd, 0xc, [][2]uint64{})
if err != nil {
t.Fatalf("could not read rnglist: %v", err)
}
diff --git a/src/debug/dwarf/entry.go b/src/debug/dwarf/entry.go
index bc05d7ef31..3fc73b8ead 100644
--- a/src/debug/dwarf/entry.go
+++ b/src/debug/dwarf/entry.go
@@ -423,6 +423,47 @@ func (b *buf) entry(cu *Entry, atab abbrevTable, ubase Offset, vers int) *Entry
Children: a.children,
Field: make([]Field, len(a.field)),
}
+
+ // If we are currently parsing the compilation unit,
+ // we can't evaluate Addrx or Strx until we've seen the
+ // relevant base entry.
+ type delayed struct {
+ idx int
+ off uint64
+ fmt format
+ }
+ var delay []delayed
+
+ resolveStrx := func(strBase, off uint64) string {
+ off += strBase
+ if uint64(int(off)) != off {
+ b.error("DW_FORM_strx offset out of range")
+ }
+
+ b1 := makeBuf(b.dwarf, b.format, "str_offsets", 0, b.dwarf.strOffsets)
+ b1.skip(int(off))
+ is64, _ := b.format.dwarf64()
+ if is64 {
+ off = b1.uint64()
+ } else {
+ off = uint64(b1.uint32())
+ }
+ if b1.err != nil {
+ b.err = b1.err
+ return ""
+ }
+ if uint64(int(off)) != off {
+ b.error("DW_FORM_strx indirect offset out of range")
+ }
+ b1 = makeBuf(b.dwarf, b.format, "str", 0, b.dwarf.str)
+ b1.skip(int(off))
+ val := b1.string()
+ if b1.err != nil {
+ b.err = b1.err
+ }
+ return val
+ }
+
for i := range e.Field {
e.Field[i].Attr = a.field[i].attr
e.Field[i].Class = a.field[i].class
@@ -467,10 +508,13 @@ func (b *buf) entry(cu *Entry, atab abbrevTable, ubase Offset, vers int) *Entry
var addrBase int64
if cu != nil {
addrBase, _ = cu.Val(AttrAddrBase).(int64)
+ } else if a.tag == TagCompileUnit {
+ delay = append(delay, delayed{i, off, formAddrx})
+ break
}
var err error
- val, err = b.dwarf.debugAddr(uint64(addrBase), off)
+ val, err = b.dwarf.debugAddr(b.format, uint64(addrBase), off)
if err != nil {
if b.err == nil {
b.err = err
@@ -611,38 +655,16 @@ func (b *buf) entry(cu *Entry, atab abbrevTable, ubase Offset, vers int) *Entry
// compilation unit. This won't work if the
// program uses Reader.Seek to skip over the
// unit. Not much we can do about that.
+ var strBase int64
if cu != nil {
- cuOff, ok := cu.Val(AttrStrOffsetsBase).(int64)
- if ok {
- off += uint64(cuOff)
- }
+ strBase, _ = cu.Val(AttrStrOffsetsBase).(int64)
+ } else if a.tag == TagCompileUnit {
+ delay = append(delay, delayed{i, off, formStrx})
+ break
}
- if uint64(int(off)) != off {
- b.error("DW_FORM_strx offset out of range")
- }
+ val = resolveStrx(uint64(strBase), off)
- b1 := makeBuf(b.dwarf, b.format, "str_offsets", 0, b.dwarf.strOffsets)
- b1.skip(int(off))
- if is64 {
- off = b1.uint64()
- } else {
- off = uint64(b1.uint32())
- }
- if b1.err != nil {
- b.err = b1.err
- return nil
- }
- if uint64(int(off)) != off {
- b.error("DW_FORM_strx indirect offset out of range")
- }
- b1 = makeBuf(b.dwarf, b.format, "str", 0, b.dwarf.str)
- b1.skip(int(off))
- val = b1.string()
- if b1.err != nil {
- b.err = b1.err
- return nil
- }
case formStrpSup:
is64, known := b.format.dwarf64()
if !known {
@@ -689,11 +711,32 @@ func (b *buf) entry(cu *Entry, atab abbrevTable, ubase Offset, vers int) *Entry
case formRnglistx:
val = b.uint()
}
+
e.Field[i].Val = val
}
if b.err != nil {
return nil
}
+
+ for _, del := range delay {
+ switch del.fmt {
+ case formAddrx:
+ addrBase, _ := e.Val(AttrAddrBase).(int64)
+ val, err := b.dwarf.debugAddr(b.format, uint64(addrBase), del.off)
+ if err != nil {
+ b.err = err
+ return nil
+ }
+ e.Field[del.idx].Val = val
+ case formStrx:
+ strBase, _ := e.Val(AttrStrOffsetsBase).(int64)
+ e.Field[del.idx].Val = resolveStrx(uint64(strBase), del.off)
+ if b.err != nil {
+ return nil
+ }
+ }
+ }
+
return e
}
@@ -877,6 +920,7 @@ func (r *Reader) SeekPC(pc uint64) (*Entry, error) {
r.err = nil
r.lastChildren = false
r.unit = unit
+ r.cu = nil
u := &r.d.unit[unit]
r.b = makeBuf(r.d, u, "info", u.off, u.data)
e, err := r.Next()
@@ -946,7 +990,7 @@ func (d *Data) Ranges(e *Entry) ([][2]uint64, error) {
if err != nil {
return nil, err
}
- return d.dwarf5Ranges(cu, base, ranges, ret)
+ return d.dwarf5Ranges(u, cu, base, ranges, ret)
case ClassRngList:
// TODO: support DW_FORM_rnglistx
@@ -1023,13 +1067,13 @@ func (d *Data) dwarf2Ranges(u *unit, base uint64, ranges int64, ret [][2]uint64)
// dwarf5Ranges interpets a debug_rnglists sequence, see DWARFv5 section
// 2.17.3 (page 53).
-func (d *Data) dwarf5Ranges(cu *Entry, base uint64, ranges int64, ret [][2]uint64) ([][2]uint64, error) {
+func (d *Data) dwarf5Ranges(u *unit, cu *Entry, base uint64, ranges int64, ret [][2]uint64) ([][2]uint64, error) {
var addrBase int64
if cu != nil {
addrBase, _ = cu.Val(AttrAddrBase).(int64)
}
- buf := makeBuf(d, d.rngLists, "rnglists", 0, d.rngLists.data)
+ buf := makeBuf(d, u, "rnglists", 0, d.rngLists)
buf.skip(int(ranges))
for {
opcode := buf.uint8()
@@ -1043,7 +1087,7 @@ func (d *Data) dwarf5Ranges(cu *Entry, base uint64, ranges int64, ret [][2]uint6
case rleBaseAddressx:
baseIdx := buf.uint()
var err error
- base, err = d.debugAddr(uint64(addrBase), baseIdx)
+ base, err = d.debugAddr(u, uint64(addrBase), baseIdx)
if err != nil {
return nil, err
}
@@ -1052,11 +1096,11 @@ func (d *Data) dwarf5Ranges(cu *Entry, base uint64, ranges int64, ret [][2]uint6
startIdx := buf.uint()
endIdx := buf.uint()
- start, err := d.debugAddr(uint64(addrBase), startIdx)
+ start, err := d.debugAddr(u, uint64(addrBase), startIdx)
if err != nil {
return nil, err
}
- end, err := d.debugAddr(uint64(addrBase), endIdx)
+ end, err := d.debugAddr(u, uint64(addrBase), endIdx)
if err != nil {
return nil, err
}
@@ -1065,7 +1109,7 @@ func (d *Data) dwarf5Ranges(cu *Entry, base uint64, ranges int64, ret [][2]uint6
case rleStartxLength:
startIdx := buf.uint()
len := buf.uint()
- start, err := d.debugAddr(uint64(addrBase), startIdx)
+ start, err := d.debugAddr(u, uint64(addrBase), startIdx)
if err != nil {
return nil, err
}
@@ -1093,19 +1137,18 @@ func (d *Data) dwarf5Ranges(cu *Entry, base uint64, ranges int64, ret [][2]uint6
}
// debugAddr returns the address at idx in debug_addr
-func (d *Data) debugAddr(addrBase, idx uint64) (uint64, error) {
- off := idx*uint64(d.addr.addrsize()) + addrBase
+func (d *Data) debugAddr(format dataFormat, addrBase, idx uint64) (uint64, error) {
+ off := idx*uint64(format.addrsize()) + addrBase
if uint64(int(off)) != off {
return 0, errors.New("offset out of range")
}
- b := makeBuf(d, d.addr, "addr", 0, d.addr.data)
+ b := makeBuf(d, format, "addr", 0, d.addr)
b.skip(int(off))
val := b.addr()
if b.err != nil {
return 0, b.err
}
-
return val, nil
}
diff --git a/src/debug/dwarf/entry_test.go b/src/debug/dwarf/entry_test.go
index 2e6ee048aa..b54f8b4f8d 100644
--- a/src/debug/dwarf/entry_test.go
+++ b/src/debug/dwarf/entry_test.go
@@ -55,6 +55,20 @@ func TestReaderSeek(t *testing.T) {
{0x400611, nil},
}
testRanges(t, "testdata/line-gcc.elf", want)
+
+ want = []wantRange{
+ {0x401122, [][2]uint64{{0x401122, 0x401166}}},
+ {0x401165, [][2]uint64{{0x401122, 0x401166}}},
+ {0x401166, [][2]uint64{{0x401166, 0x401179}}},
+ }
+ testRanges(t, "testdata/line-gcc-dwarf5.elf", want)
+
+ want = []wantRange{
+ {0x401130, [][2]uint64{{0x401130, 0x40117e}}},
+ {0x40117d, [][2]uint64{{0x401130, 0x40117e}}},
+ {0x40117e, nil},
+ }
+ testRanges(t, "testdata/line-clang-dwarf5.elf", want)
}
func TestRangesSection(t *testing.T) {
@@ -97,44 +111,72 @@ func testRanges(t *testing.T, name string, want []wantRange) {
}
func TestReaderRanges(t *testing.T) {
- d := elfData(t, "testdata/line-gcc.elf")
-
- subprograms := []struct {
+ type subprograms []struct {
name string
ranges [][2]uint64
+ }
+ tests := []struct {
+ filename string
+ subprograms subprograms
}{
- {"f1", [][2]uint64{{0x40059d, 0x4005e7}}},
- {"main", [][2]uint64{{0x4005e7, 0x400601}}},
- {"f2", [][2]uint64{{0x400601, 0x400611}}},
+ {
+ "testdata/line-gcc.elf",
+ subprograms{
+ {"f1", [][2]uint64{{0x40059d, 0x4005e7}}},
+ {"main", [][2]uint64{{0x4005e7, 0x400601}}},
+ {"f2", [][2]uint64{{0x400601, 0x400611}}},
+ },
+ },
+ {
+ "testdata/line-gcc-dwarf5.elf",
+ subprograms{
+ {"main", [][2]uint64{{0x401147, 0x401166}}},
+ {"f1", [][2]uint64{{0x401122, 0x401147}}},
+ {"f2", [][2]uint64{{0x401166, 0x401179}}},
+ },
+ },
+ {
+ "testdata/line-clang-dwarf5.elf",
+ subprograms{
+ {"main", [][2]uint64{{0x401130, 0x401144}}},
+ {"f1", [][2]uint64{{0x401150, 0x40117e}}},
+ {"f2", [][2]uint64{{0x401180, 0x401197}}},
+ },
+ },
}
- r := d.Reader()
- i := 0
- for entry, err := r.Next(); entry != nil && err == nil; entry, err = r.Next() {
- if entry.Tag != TagSubprogram {
- continue
+ for _, test := range tests {
+ d := elfData(t, test.filename)
+ subprograms := test.subprograms
+
+ r := d.Reader()
+ i := 0
+ for entry, err := r.Next(); entry != nil && err == nil; entry, err = r.Next() {
+ if entry.Tag != TagSubprogram {
+ continue
+ }
+
+ if i > len(subprograms) {
+ t.Fatalf("%s: too many subprograms (expected at most %d)", test.filename, i)
+ }
+
+ if got := entry.Val(AttrName).(string); got != subprograms[i].name {
+ t.Errorf("%s: subprogram %d name is %s, expected %s", test.filename, i, got, subprograms[i].name)
+ }
+ ranges, err := d.Ranges(entry)
+ if err != nil {
+ t.Errorf("%s: subprogram %d: %v", test.filename, i, err)
+ continue
+ }
+ if !reflect.DeepEqual(ranges, subprograms[i].ranges) {
+ t.Errorf("%s: subprogram %d ranges are %x, expected %x", test.filename, i, ranges, subprograms[i].ranges)
+ }
+ i++
}
- if i > len(subprograms) {
- t.Fatalf("too many subprograms (expected at most %d)", i)
+ if i < len(subprograms) {
+ t.Errorf("%s: saw only %d subprograms, expected %d", test.filename, i, len(subprograms))
}
-
- if got := entry.Val(AttrName).(string); got != subprograms[i].name {
- t.Errorf("subprogram %d name is %s, expected %s", i, got, subprograms[i].name)
- }
- ranges, err := d.Ranges(entry)
- if err != nil {
- t.Errorf("subprogram %d: %v", i, err)
- continue
- }
- if !reflect.DeepEqual(ranges, subprograms[i].ranges) {
- t.Errorf("subprogram %d ranges are %x, expected %x", i, ranges, subprograms[i].ranges)
- }
- i++
- }
-
- if i < len(subprograms) {
- t.Errorf("saw only %d subprograms, expected %d", i, len(subprograms))
}
}
diff --git a/src/debug/dwarf/open.go b/src/debug/dwarf/open.go
index 617b8c56dd..e94103a1d7 100644
--- a/src/debug/dwarf/open.go
+++ b/src/debug/dwarf/open.go
@@ -26,10 +26,10 @@ type Data struct {
str []byte
// New sections added in DWARF 5.
- addr *debugAddr
+ addr []byte
lineStr []byte
strOffsets []byte
- rngLists *rngLists
+ rngLists []byte
// parsed data
abbrevCache map[uint64]abbrevTable
@@ -40,21 +40,6 @@ type Data struct {
unit []unit
}
-// rngLists represents the contents of a debug_rnglists section (DWARFv5).
-type rngLists struct {
- is64 bool
- asize uint8
- data []byte
- ver uint16
-}
-
-// debugAddr represents the contents of a debug_addr section (DWARFv5).
-type debugAddr struct {
- is64 bool
- asize uint8
- data []byte
-}
-
var errSegmentSelector = errors.New("non-zero segment_selector size not supported")
// New returns a new Data object initialized from the given parameters.
@@ -132,76 +117,14 @@ func (d *Data) AddSection(name string, contents []byte) error {
var err error
switch name {
case ".debug_addr":
- d.addr, err = d.parseAddrHeader(contents)
+ d.addr = contents
case ".debug_line_str":
d.lineStr = contents
case ".debug_str_offsets":
d.strOffsets = contents
case ".debug_rnglists":
- d.rngLists, err = d.parseRngListsHeader(contents)
+ d.rngLists = contents
}
// Just ignore names that we don't yet support.
return err
}
-
-// parseRngListsHeader reads the header of a debug_rnglists section, see
-// DWARFv5 section 7.28 (page 242).
-func (d *Data) parseRngListsHeader(bytes []byte) (*rngLists, error) {
- rngLists := &rngLists{data: bytes}
-
- buf := makeBuf(d, unknownFormat{}, "rnglists", 0, bytes)
- _, rngLists.is64 = buf.unitLength()
-
- rngLists.ver = buf.uint16() // version
-
- rngLists.asize = buf.uint8()
- segsize := buf.uint8()
- if segsize != 0 {
- return nil, errSegmentSelector
- }
-
- // Header fields not read: offset_entry_count, offset table
-
- return rngLists, nil
-}
-
-func (rngLists *rngLists) version() int {
- return int(rngLists.ver)
-}
-
-func (rngLists *rngLists) dwarf64() (bool, bool) {
- return rngLists.is64, true
-}
-
-func (rngLists *rngLists) addrsize() int {
- return int(rngLists.asize)
-}
-
-// parseAddrHeader reads the header of a debug_addr section, see DWARFv5
-// section 7.27 (page 241).
-func (d *Data) parseAddrHeader(bytes []byte) (*debugAddr, error) {
- addr := &debugAddr{data: bytes}
-
- buf := makeBuf(d, unknownFormat{}, "addr", 0, bytes)
- _, addr.is64 = buf.unitLength()
-
- addr.asize = buf.uint8()
- segsize := buf.uint8()
- if segsize != 0 {
- return nil, errSegmentSelector
- }
-
- return addr, nil
-}
-
-func (addr *debugAddr) version() int {
- return 5
-}
-
-func (addr *debugAddr) dwarf64() (bool, bool) {
- return addr.is64, true
-}
-
-func (addr *debugAddr) addrsize() int {
- return int(addr.asize)
-}
diff --git a/src/debug/dwarf/testdata/line-clang-dwarf5.elf b/src/debug/dwarf/testdata/line-clang-dwarf5.elf
new file mode 100644
index 0000000000000000000000000000000000000000..7b80c9c5dad459bfc283da9cdda1629494169c30
GIT binary patch
literal 18384
zcmeHPeQX@X6`$R`J74VN?AU~uB;W;XnzZL8xBW|8Fk+k?-
zB9l04va%89#iWp#Xdm$n~le5;qSDpfrPS#j1BVhJV#rkk=M*PrWdOyA=fJSFqar3
zPPoqjj<-+bUy4!KM@4zH;=(8%f{W&|u1tEox2G!;@64pL#p%xJzTVE>o?sytT+7>i
z8B_rK)Ryf#*^eJOzv?&Roj1St^3OBcfz(ff+wZvs>y33le`te*_Ea48N77Nb+|YJH
zJsmdnC6kD0u40APubMstdbNr@o64uNW|A2O1SDn@%xK;;CZp*rLmA`I%eD*;^$!?p
zgKLB9z;0qPmlbvfI+S^vC1}M8km$M;SELtVUb`rBZj;7Sc#SDWsJLj;W2}f;HH|0h
z;EZi`$&G*;0XG6}1l$O?5pW~mM!=1L8-f452ojJjpHKw0Ad2}hV
zGa+E5Wd{NCeq-ApW2chA#Rl0FDkn9jQ+yM=F+liuPM&{ml8A=8ux7VNcs2U>B>0=-B3<^^Cw&6p!+;%-<;ax+sFNSvx&0YwPg=hb{
zQ$N(HgZkFtH6P(MJa+@&^phVc=F0BhH@30i*}o0XzCAemdbo7i%lgbINx$(A#q)S=
z@7Npue0Xp8&aeS3W_YD}AE>zMyfW^|jer{gHv(=1+z7Z4a3kPGz>R<#0XG6}1pbdA
zAi>kUR3ekf)x#cmrLsYXw&63$%jQa@?*i`u9tR!=ei(TByQR`|zz2c93ETv}7#{dN
z0{nX5?*li1E2N$O*cs^7uWd@OLa~7yb+)6Kl@Ip^cge&s%~pNn?&2^z!qF`
zYKL9JLRY6^B;x$y8w?{ct-i7R{kKU@MZ(%@5TK7K+{*{p+M`yN+h5j@0ZUo#2{HG(J!t+_AIq^O;?LqL}P^85cgUy)6Q%i*GX}07mgiP-@uM{%w
zv5?4*U%bbR`!XcT_gEtHD;iH-__&nAL`cZ|oo$eh3z^+RHU85p=pT|Jl>Pe-$AcL?4w4s~{~TO*PzmWgI3
z)P0G3A)U*rHwHt&?#}KWm8HRtmq|QY5_Bpn1xlH1hcoJBejh;Er7-Uph>C>Ua%q=W
zl05Q}eLhLq4KgIB7D*m7U|x^c`wDQ`_{ujOe`fc7upXrsidKKS4u7zgffPo>PFph|(;J}G`YTET&h7%AD4(s5+9*seX!hszb`|%_k_rYQLg#^$H
z9B6+Oj!)3OYL%|t5)7IZyi{!?Z0;oqeoE!o$~9!o@fTECG$J|f%ViRB>;z#&z+
zzITHj{m^<4ZISlDAyw%oUju!$`dia%fYC6>@2!LF(Hi!(;&2S?CDzOyxmtr%B~>f;
zC)}iELBBl%dWkLUx6ccEXaD~**Dw4XeZc)J?9ce@qZ#6cZ#^PWoL31w4gY}TbO-2F
zm;jvpzYX+Fpm+BF%h8X#a2&V}^}?r}-Bd%rNBDP^n*_aTcOcS5&@Yu+*=on{@qX0f
zQwvq&mN0#DIs$r(!%;E)@wpyyeg#Jp^us=fpC{2?4zMZFpF!kg2tS(8<5~{sXP`$v
z&iMRV*wgfj((PGu5iA|4D?w=k0FY}$zC^U?iAB5UUNvt&LxnK0tT
z$;tfyu}KD4niZzBrh#<|CUFurjLoCrZ4o1~eGnEXMkOZBjKMwI!`p@iDs%W(f}nyA
zAB~7EJm`a?%-Ax#qdz=s?AW~d*2tJK7VaO8pjZBFVXRQ(wa0aik-$Zk`1nxMD!(vv
ze2M7HMx^xtB6zO&8WCbz$Qh|LY+cqHL!-9qVlV)@rxS6+jic+uuOys9nFq<bgw-W11f{`obTS=-Qgh%7PC;IPLOxAdUz7u!O>}YGJYeB$0I^k*EN#8}c+l?Vj;}@xWAz{bU`t+P|sFI=JPP`6!
zyk|k>(|rxUVgaapx{u*^_!$KG1GpzZ_>iJ;i;%!m`<-~!^7mo=1UBVFC
zh_R#caZ7@<3l20T{BcqKae=4%ENF}5jQ^dW!+RWrr*-z6z*Bitf3hR~1;FDy6Ow5?
zeo^36$VYP4-_kO6FC_4q5T4fUt>Qw3gdvqr^`Z7ZAn^Udj_&*D0#9~`$2r}Je;9Na
z6Y|f*Jcd&y60HL)X<`4Hg$z4h6?j$PRRRhw)a0H$;=t29stLoBjtfS3a{EmOp7tM}
zX3K)^Z;`zS3yFN4hec5QX`R4S%LMzTot*e%kZH%y{~v*c8n%NW?Zo3c(2l2l&u-NM
zYM5ywx_+cO0SR1di|#hRKN1UBr#;EUp95^84NvH(jiuz;!
zN1}4+I{pcCXhL|}m(6vdHLjs5iSWe#0@-#v(=-bZvY2YI@|keN-+>%Ep4OYHz}G6D
z9A1C~`l9;N`Yj~zR1Vo=S$6sd2&fb0;fX7dptRj|LO6Wfu7tGHwy_3Y
z>9&ARTmpY(4g8Y=|KTO@YXsie{>Rr^!0*(+Q#*QUl)vc)3t0YL3qOP-w*xisVS!&w
zhBfdzYT(lXuU`T`F7VFw|4`s@ey|hO-_D(FMEg*Wg?dR0?Cl`pT7mi_%?mg_Qs1=@
e*4e+o;xAG`BGVzl-l{tOk2hO@yaV76*}niox8D;0
literal 0
HcmV?d00001
diff --git a/src/debug/dwarf/testdata/line-gcc-dwarf5.elf b/src/debug/dwarf/testdata/line-gcc-dwarf5.elf
new file mode 100644
index 0000000000000000000000000000000000000000..34ce17cc426b5b552404c8055136f5797e887603
GIT binary patch
literal 18040
zcmeHPe~cVe9e*=(d$;9!+q+&{4hnQyODw|e-IcbKmTPD4N4tmD7E22SEyLdJ-tFSv
zZnHZJS46BH0vBv45tE`2&=}MBkN!cBXd=`$EhdnZh(@Evf&~i{IEWCUh4u4&^S*nt
zb9)hEG%?OgX1+f^@5guE&U-WS-hQQjaFecSf|D*b2$HO3ORC(n5Fd6+QR&u-Mq!C%
zVyUQyrVfWCEks?8XPTTnsN<^5^g$KigoE)Wn?Ov
zT{GcA#41^+_Az}+6~L7JD&?63Mlvl)m>yC%rd}Myra9`mH*aupOik796^b&BM8cU0
zXDS@ild3$X98YRC9miCD$8-x4$rcgOC(qNAd?{V`s*@ysu1OM6tBMXvNeHHl`y6mo
z&rg~-?Auj&v&CgfwU4P1MMpL>v}RRDHrbxd=A$cRyBDA$)TcIY
z-6_6w_L}z&oyxw@dC{W>?rM7NQ2fc4UZ;9f9VkEYp+x>1e$w+nwojS}Grxv2#io{?
zE~{C?U+gJ4MPb`$=CECK5(UQ|OJs6_WNPIav3YQyr`KK?T^U^sztORLPWjoCovvD<
zp%rbAIo_oUGjqtgOqDsc(UKh1kK0a)4?TK{3#T^Al57Lc)Yc#c5eOm>L?DPj5P={9
zK?H&b1Q7@#@V^^@_{7<8{DIJ09YVyv{;Z>yPsS&Xg^yMmR9^iGOyx^Y<2-MP1&-u2
z*B4_X6|Rc}x0)I64xY
zx8xp~y_BEs!~;gWo6b(_)1;?r%z1_s
z@<9K&_@U!{q4%_j{&U*Im(R_)`|QDkyN{BSEc?t0$kOHLkx6o{IljO9n-L+-{Pg2;
z8HjmH_EDCx8wdAy-**L=8wMtS6Wcj3`F?CiZ1UXB`2O~BsIMQq>?68HXRZejYZ}(09C01VWr})HCEq?VMOK;G%`~2?M7h=0(x5R9eA?QlVYg~0z
zspKF95eOm>L?DPj5P={9K?H&b1Q7@#5JVt|!2eSOG<*e2r?S~R8m%oh*2h8VoAQFG
za{2q9t3Z>WNzj9!i{34lp9ftJdKUC%(7E_9=zv}U`Vy!EO5bBCX?JcH+IX|Jcy2@Z
zpw`e#-zDkW{&Vk?%a@Y_Qf*)N8z%Wa4`2TFxEyjPjx=;8sE9OginLujuknuXKC$t_
z^`E(N`7%-yZWoRo)caCW#3If2>b*_%x1u5t$v%!_Gwe%1EB2eG?T4V=1beI3zSXt&
zK}Qew7VNvp-Vxjuru^{OC*|YHuGIfE!t2WY1+L-s@jk=m
z-rjZQioVoPCXq9{IpUu5GL1uMESSYa)#~)
zI6^{`&PE4>i)oSdeK=~BRQEL)^iXIJgcc%Dk`Mc!+M}VmP$uVy`jIZ7X-$lmFAJpo
z0Xh$rMugEotp3oDmJxOJl$rieRy2GM%y)2v=`=^^Vc9oyt^N;?#RLwj>D{2Ztmz}*
zsHXlllBec^wYmn{q@ZcxUlGw8o|01iucZ|FC5YkHS__9>c5PHz-N;Iz8TJ00wMT`v
zN*LjFOSSclS2qr{>gbmGa?#khq0zuv1fxZ}G|~!oaim3?-_VTCUKbS`FEAqO8eIUX
zt+u=Hs}3m`LSG-%kf-!;?RQ?F;es`2+CVEY;iY1rwS#_%+H_g^%(9H>EZt(OGNnSr
zS8y2El0q^0d!z|xxmN|h9xa&~Dvfp|??@CzI-FF|NhX|xz>!a1$~`%ZAeSk=>sACvyX?gS9Ki)ZkJWK@?WdM
z%BZJYzAOuoZAkl>ZXnleJ~wKXa>dMOE|oN?AJ%FQc0EvYhH1-!+1quM`k9&SV@@fT
z>K;wyQiaSg#6)2@-Rq+&W>aH^~As;B{#)(oc;1tA+q>VKXPkIKFuueX6)
z$uZsXsw8iqOPr~xud9q3UXXzwB99l<`ufVaQmtJS*|*
zc{bwLUtFzFk|8dcp~rm(`;p!)`werU&_$Ej=exeR3rqcvefp(J&+{*81X7<}ZOa09L|AEYBWG22T3sj8GT`
zZ9AE_N3;2%MAl9^`9jf7l*Ywyer!)R<)o6)&e|UKNG6xD6NN%zubs*{g}q{=kQhtZ
z$H7X1_KsN3U_a$5cNY#9OS1L?lSbNgXjxTT3sZ6;
zHDf2D&&wt+cLO5wt=f%
z6y@e*hV4BW!0e%7QDrYDDz?32ORtKKh!*#bVHN}G6kM8S4l|BaVULLB@=hu`nkz+z
zN*Qb#%_Nm7)-!+!(5R5MbfTCR(d6D7@^h(Ea4ol|3dKx5S0&i6p{@x6C~i;I5mDKY
zsFNB8PrU-Ryo_Nql~(;AodlL87vXjY7r{I-PK;%SQEDD};S`kxxS1g!B8q-FhVF*S
z((D(wL~azFSc#e3NS^t`&`=?DJ4@8fm`AA8kMG|gG=kzMhcUrThjmLbyr0`Yl9I1C
zeF_3SFEO6ydAxslxz`yy-;Y?m28D>g&Jg+^e@TM%)-HYz6zfy}k!B9*Y&-33Yh3EGnTt3%_
z+kcP3_oxi{{fenB6#Ee#qw|dT9e|GN#qWaz&!3v1MB?{0t~9g%Ov2#Bn+k6#yvaaC
zl^SD}n;r)7;(1)Nl*4z)=t+!Y)wjWT@jQ<|-Qs%idnEQ(VPR1`0gmt-|H^#dgc6D0
zi@DOw_8*49i=W>2?;_|ehd24le+ot~o}V9fnJ&sAqbKq8XVtS{Xzr`JOXWF({};gT
z&oa~JfyHd4g6H{RTNFwp_H(6anf1Sgf%*=Y&+|zB--VN^{@lM9$Jg;?V9AB?{CqP-
zuX>Q!&y{AD{~8QleC0W)(?ysJRFunS`VRD7JkS43g`cf_&h~vUlo!{Z=Tn^u&*iW`
zmE}!;gFrgvUNJGAU$e1+@k|Xc%(D;CZ7RcCy-M(Y-}$rPf28mvy~_v2};lV3-W$5*<*-?^l6_WRO&o^<~Bjnj)Jq&HkrIWyi%E5H4U7uH3sa)oi#
taZQL+CBB|~U#0sCUwg2XbZVW;zQhG7i%-O}LT&t$*SLUQAHXMye*hNQ!F~V$
literal 0
HcmV?d00001
From c81343ce3aa1b8f1b2539a3d391f628f69a0a490 Mon Sep 17 00:00:00 2001
From: Anmol Sethi
Date: Fri, 11 Dec 2020 23:01:12 +0000
Subject: [PATCH 26/66] net/http: attempt deadlock fix in
TestDisableKeepAliveUpgrade
1. The test now checks the response status code.
2. The transport has been changed to not set "Connection: Close" if
DisableKeepAlive is set and the request is a HTTP/1.1 protocol
upgrade.
Updates #43073
Change-Id: I9977a18b33b8747ef847a8d11bb7b4f2d8053b8c
GitHub-Last-Rev: f809cebb139df4f5560a8456973351c95a3dfa97
GitHub-Pull-Request: golang/go#43086
Reviewed-on: https://go-review.googlesource.com/c/go/+/276375
Run-TryBot: Bryan C. Mills
TryBot-Result: Go Bot
Reviewed-by: Damien Neil
Trust: Dmitri Shuralyov
---
src/net/http/response.go | 9 +++++++--
src/net/http/serve_test.go | 4 ++++
src/net/http/transport.go | 4 +++-
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/net/http/response.go b/src/net/http/response.go
index b95abae646..b8985da3c8 100644
--- a/src/net/http/response.go
+++ b/src/net/http/response.go
@@ -361,7 +361,12 @@ func (r *Response) isProtocolSwitch() bool {
// isProtocolSwitchResponse reports whether the response code and
// response header indicate a successful protocol upgrade response.
func isProtocolSwitchResponse(code int, h Header) bool {
- return code == StatusSwitchingProtocols &&
- h.Get("Upgrade") != "" &&
+ return code == StatusSwitchingProtocols && isProtocolSwitchHeader(h)
+}
+
+// isProtocolSwitchHeader reports whether the request or response header
+// is for a protocol switch.
+func isProtocolSwitchHeader(h Header) bool {
+ return h.Get("Upgrade") != "" &&
httpguts.HeaderValuesContainsToken(h["Connection"], "Upgrade")
}
diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go
index b1bf8e6c5e..95e6bf4adb 100644
--- a/src/net/http/serve_test.go
+++ b/src/net/http/serve_test.go
@@ -6481,6 +6481,10 @@ func TestDisableKeepAliveUpgrade(t *testing.T) {
}
defer resp.Body.Close()
+ if resp.StatusCode != StatusSwitchingProtocols {
+ t.Fatalf("unexpected status code: %v", resp.StatusCode)
+ }
+
rwc, ok := resp.Body.(io.ReadWriteCloser)
if !ok {
t.Fatalf("Response.Body is not a io.ReadWriteCloser: %T", resp.Body)
diff --git a/src/net/http/transport.go b/src/net/http/transport.go
index a5830703af..6358c3897e 100644
--- a/src/net/http/transport.go
+++ b/src/net/http/transport.go
@@ -2566,7 +2566,9 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err
continueCh = make(chan struct{}, 1)
}
- if pc.t.DisableKeepAlives && !req.wantsClose() {
+ if pc.t.DisableKeepAlives &&
+ !req.wantsClose() &&
+ !isProtocolSwitchHeader(req.Header) {
req.extraHeaders().Set("Connection", "close")
}
From 2f5b1a397454b76ad71e7eda5d574c304a416372 Mon Sep 17 00:00:00 2001
From: Daniel S Fava
Date: Wed, 9 Dec 2020 23:56:50 +0100
Subject: [PATCH 27/66] test: make a race detector test robust to timing
variations
The `external_cgo_thread` test in `runtime/race/output_test.go` was
producing intermittent failures. The test was performing a sleep,
which may not be enough depending on how long it takes to setup the
callBack goroutine.
Added a synchronization to make sure callBack finishes before main ends.
Whether the increment to racy++ happens first in the callBack
or in main doesn't matter: the race detector should flag the race
regardless. The output check was changed so that the test passes
regardless of which increment occurs first.
Fixes #43008
Change-Id: I325ec3dea52b3725e739fbf2bd7ae92875d2de10
Reviewed-on: https://go-review.googlesource.com/c/go/+/276752
Reviewed-by: Dmitry Vyukov
Run-TryBot: Dmitry Vyukov
TryBot-Result: Go Bot
Trust: Ian Lance Taylor
---
src/runtime/race/output_test.go | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/runtime/race/output_test.go b/src/runtime/race/output_test.go
index 986667332f..69496874c6 100644
--- a/src/runtime/race/output_test.go
+++ b/src/runtime/race/output_test.go
@@ -284,32 +284,31 @@ static inline void startThread(cb* c) {
*/
import "C"
-import "time"
-
+var done chan bool
var racy int
//export goCallback
func goCallback() {
racy++
+ done <- true
}
func main() {
+ done = make(chan bool)
var c C.cb
C.startThread(&c)
- time.Sleep(time.Second)
racy++
+ <- done
}
`, `==================
WARNING: DATA RACE
-Read at 0x[0-9,a-f]+ by main goroutine:
- main\.main\(\)
- .*/main\.go:34 \+0x[0-9,a-f]+
+Read at 0x[0-9,a-f]+ by .*:
+ main\..*
+ .*/main\.go:[0-9]+ \+0x[0-9,a-f]+(?s).*
-Previous write at 0x[0-9,a-f]+ by goroutine [0-9]:
- main\.goCallback\(\)
- .*/main\.go:27 \+0x[0-9,a-f]+
- _cgoexp_[0-9a-z]+_goCallback\(\)
- .*_cgo_gotypes\.go:[0-9]+ \+0x[0-9,a-f]+
+Previous write at 0x[0-9,a-f]+ by .*:
+ main\..*
+ .*/main\.go:[0-9]+ \+0x[0-9,a-f]+(?s).*
Goroutine [0-9] \(running\) created at:
runtime\.newextram\(\)
From dea6d94a4453dfcadbfcaf923100aa1e1d3e469a Mon Sep 17 00:00:00 2001
From: Katie Hockman
Date: Tue, 24 Nov 2020 15:37:25 -0500
Subject: [PATCH 28/66] math/big: add test for recursive division panic
The vulnerability that allowed this panic is
CVE-2020-28362 and has been fixed in a security
release, per #42552.
Change-Id: I774bcda2cc83cdd5a273d21c8d9f4b53fa17c88f
Reviewed-on: https://go-review.googlesource.com/c/go/+/277959
Run-TryBot: Katie Hockman
TryBot-Result: Go Bot
Trust: Katie Hockman
Reviewed-by: Filippo Valsorda
---
src/math/big/nat_test.go | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/math/big/nat_test.go b/src/math/big/nat_test.go
index 89e913fc16..0850818932 100644
--- a/src/math/big/nat_test.go
+++ b/src/math/big/nat_test.go
@@ -804,3 +804,13 @@ func TestIssue37499(t *testing.T) {
t.Fatalf("incorrect quotient: %s", s)
}
}
+
+// TestIssue42552 triggers an edge case of recursive division
+// where the first division loop is never entered, and correcting
+// the remainder takes exactly two iterations in the final loop.
+func TestIssue42552(t *testing.T) {
+ u := natFromString("0xc23b166884c3869092a520eceedeced2b00847bd256c9cf3b2c5e2227c15bd5e6ee7ef8a2f49236ad0eedf2c8a3b453cf6e0706f64285c526b372c4b1321245519d430540804a50b7ca8b6f1b34a2ec05cdbc24de7599af112d3e3c8db347e8799fe70f16e43c6566ba3aeb169463a3ecc486172deb2d9b80a3699c776e44fef20036bd946f1b4d054dd88a2c1aeb986199b0b2b7e58c42288824b74934d112fe1fc06e06b4d99fe1c5e725946b23210521e209cd507cce90b5f39a523f27e861f9e232aee50c3f585208b4573dcc0b897b6177f2ba20254fd5c50a033e849dee1b3a93bd2dc44ba8ca836cab2c2ae50e50b126284524fa0187af28628ff0face68d87709200329db1392852c8b8963fbe3d05fb1efe19f0ed5ca9fadc2f96f82187c24bb2512b2e85a66333a7e176605695211e1c8e0b9b9e82813e50654964945b1e1e66a90840396c7d10e23e47f364d2d3f660fa54598e18d1ca2ea4fe4f35a40a11f69f201c80b48eaee3e2e9b0eda63decf92bec08a70f731587d4ed0f218d5929285c8b2ccbc497e20db42de73885191fa453350335990184d8df805072f958d5354debda38f5421effaaafd6cb9b721ace74be0892d77679f62a4a126697cd35797f6858193da4ba1770c06aea2e5c59ec04b8ea26749e61b72ecdde403f3bc7e5e546cd799578cc939fa676dfd5e648576d4a06cbadb028adc2c0b461f145b2321f42e5e0f3b4fb898ecd461df07a6f5154067787bf74b5cc5c03704a1ce47494961931f0263b0aac32505102595957531a2de69dd71aac51f8a49902f81f21283dbe8e21e01e5d82517868826f86acf338d935aa6b4d5a25c8d540389b277dd9d64569d68baf0f71bd03dba45b92a7fc052601d1bd011a2fc6790a23f97c6fa5caeea040ab86841f268d39ce4f7caf01069df78bba098e04366492f0c2ac24f1bf16828752765fa523c9a4d42b71109d123e6be8c7b1ab3ccf8ea03404075fe1a9596f1bba1d267f9a7879ceece514818316c9c0583469d2367831fc42b517ea028a28df7c18d783d16ea2436cee2b15d52db68b5dfdee6b4d26f0905f9b030c911a04d078923a4136afea96eed6874462a482917353264cc9bee298f167ac65a6db4e4eda88044b39cc0b33183843eaa946564a00c3a0ab661f2c915e70bf0bb65bfbb6fa2eea20aed16bf2c1a1d00ec55fb4ff2f76b8e462ea70c19efa579c9ee78194b86708fdae66a9ce6e2cf3d366037798cfb50277ba6d2fd4866361022fd788ab7735b40b8b61d55e32243e06719e53992e9ac16c9c4b6e6933635c3c47c8f7e73e17dd54d0dd8aeba5d76de46894e7b3f9d3ec25ad78ee82297ba69905ea0fa094b8667faa2b8885e2187b3da80268aa1164761d7b0d6de206b676777348152b8ae1d4afed753bc63c739a5ca8ce7afb2b241a226bd9e502baba391b5b13f5054f070b65a9cf3a67063bfaa803ba390732cd03888f664023f888741d04d564e0b5674b0a183ace81452001b3fbb4214c77d42ca75376742c471e58f67307726d56a1032bd236610cbcbcd03d0d7a452900136897dc55bb3ce959d10d4e6a10fb635006bd8c41cd9ded2d3dfdd8f2e229590324a7370cb2124210b2330f4c56155caa09a2564932ceded8d92c79664dcdeb87faad7d3da006cc2ea267ee3df41e9677789cc5a8cc3b83add6491561b3047919e0648b1b2e97d7ad6f6c2aa80cab8e9ae10e1f75b1fdd0246151af709d259a6a0ed0b26bd711024965ecad7c41387de45443defce53f66612948694a6032279131c257119ed876a8e805dfb49576ef5c563574115ee87050d92d191bc761ef51d966918e2ef925639400069e3959d8fe19f36136e947ff430bf74e71da0aa5923b00000000")
+ v := natFromString("0x838332321d443a3d30373d47301d47073847473a383d3030f25b3d3d3e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e00000000000000000041603038331c3d32f5303441e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e01c0a5459bfc7b9be9fcbb9d2383840464319434707303030f43a32f53034411c0a5459413820878787878787878787878787878787878787878787878787878787878787878787870630303a3a30334036605b923a6101f83638413943413960204337602043323801526040523241846038414143015238604060328452413841413638523c0240384141364036605b923a6101f83638413943413960204334602043323801526040523241846038414143015238604060328452413841413638523c02403841413638433030f25a8b83838383838383838383838383838383837d838383ffffffffffffffff838383838383838383000000000000000000030000007d26e27c7c8b83838383838383838383838383838383837d838383ffffffffffffffff83838383838383838383838383838383838383838383435960f535073030f3343200000000000000011881301938343030fa398383300000002300000000000000000000f11af4600c845252904141364138383c60406032414443095238010241414303364443434132305b595a15434160b042385341ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff47476043410536613603593a6005411c437405fcfcfcfcfcfcfc0000000000005a3b075815054359000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
+ q := nat(nil).make(16)
+ q.div(q, u, v)
+}
From d06794da4a9fcfee27850757e99567ad02ba0851 Mon Sep 17 00:00:00 2001
From: Tobias Klauser
Date: Mon, 14 Dec 2020 11:25:04 +0100
Subject: [PATCH 29/66] doc/go1.16: add missing tag
For #40700.
Change-Id: I616429f82a44cea32701ed0af6e42ed6c71ee097
Reviewed-on: https://go-review.googlesource.com/c/go/+/277378
Trust: Tobias Klauser
Reviewed-by: Ian Lance Taylor
Reviewed-by: Dmitri Shuralyov
---
doc/go1.16.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/go1.16.html b/doc/go1.16.html
index 2ff763f9b6..edac1dbd35 100644
--- a/doc/go1.16.html
+++ b/doc/go1.16.html
@@ -379,7 +379,7 @@ func TestFoo(t *testing.T) {
summarizing its execution time and memory allocation. This trace can
be used to find bottlenecks or regressions in Go startup
performance.
- The GODEBUG<
+ The GODEBUG
documentation describes the format.
@@ -461,7 +461,7 @@ func TestFoo(t *testing.T) {
On the producer side of the interface,
- the new embed.FS type
+ the new embed.FS type
implements fs.FS, as does
zip.Reader.
The new os.DirFS function
From 278b9a8a4a905ca91feb145b949303bd91a2a154 Mon Sep 17 00:00:00 2001
From: Tobias Klauser
Date: Mon, 14 Dec 2020 11:14:05 +0100
Subject: [PATCH 30/66] io/fs: fix package reference in FS godoc
Reported by Ben on golang-dev
https://groups.google.com/g/golang-dev/c/gsoj5Vv15j0/m/kZxzYUdnAQAJ
Change-Id: Ic2c9600b831592ad54036b816138760b7fbb737a
Reviewed-on: https://go-review.googlesource.com/c/go/+/277377
Trust: Tobias Klauser
Run-TryBot: Tobias Klauser
TryBot-Result: Go Bot
Reviewed-by: Russ Cox
---
src/io/fs/fs.go | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/io/fs/fs.go b/src/io/fs/fs.go
index d9f89fc6ee..b691a86049 100644
--- a/src/io/fs/fs.go
+++ b/src/io/fs/fs.go
@@ -16,8 +16,7 @@ import (
//
// The FS interface is the minimum implementation required of the file system.
// A file system may implement additional interfaces,
-// such as fsutil.ReadFileFS, to provide additional or optimized functionality.
-// See io/fsutil for details.
+// such as ReadFileFS, to provide additional or optimized functionality.
type FS interface {
// Open opens the named file.
//
From 6e3cc5c56fa532df1f7690ee4955a1751b1ccbce Mon Sep 17 00:00:00 2001
From: Rob Findley
Date: Fri, 11 Dec 2020 16:24:26 -0500
Subject: [PATCH 31/66] go/types: report invalid ... in conversions
This is a port of CL 277072 from the dev.typeparams branch.
Fixes #43124
Change-Id: I1424c396dc1ea984ec85b8f31a4d43353bf7e4fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/277352
Run-TryBot: Robert Findley
TryBot-Result: Go Bot
Trust: Robert Findley
Reviewed-by: Robert Griesemer
---
src/go/types/call.go | 4 ++++
src/go/types/fixedbugs/issue43124.src | 16 ++++++++++++++++
2 files changed, 20 insertions(+)
create mode 100644 src/go/types/fixedbugs/issue43124.src
diff --git a/src/go/types/call.go b/src/go/types/call.go
index 992598d08c..6765b17bf3 100644
--- a/src/go/types/call.go
+++ b/src/go/types/call.go
@@ -33,6 +33,10 @@ func (check *Checker) call(x *operand, e *ast.CallExpr) exprKind {
case 1:
check.expr(x, e.Args[0])
if x.mode != invalid {
+ if e.Ellipsis.IsValid() {
+ check.errorf(e.Args[0], _BadDotDotDotSyntax, "invalid use of ... in conversion to %s", T)
+ break
+ }
check.conversion(x, T)
}
default:
diff --git a/src/go/types/fixedbugs/issue43124.src b/src/go/types/fixedbugs/issue43124.src
new file mode 100644
index 0000000000..f429f74a74
--- /dev/null
+++ b/src/go/types/fixedbugs/issue43124.src
@@ -0,0 +1,16 @@
+// Copyright 2020 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 _ = int(0 /* ERROR invalid use of \.\.\. in conversion to int */ ...)
+
+// test case from issue
+
+type M []string
+
+var (
+ x = []string{"a", "b"}
+ _ = M(x /* ERROR invalid use of \.\.\. in conversion to M */ ...)
+)
From 48906a6d57fdc3c6fd2b6b9fe4c0e31dc225a058 Mon Sep 17 00:00:00 2001
From: Brad Fitzpatrick
Date: Mon, 14 Dec 2020 12:09:17 -0800
Subject: [PATCH 32/66] net/http/pprof: don't treat os.Args as format string in
Cmdline handler
Found by @josharian running staticcheck against a fork of this code
elsewhere.
Change-Id: Ica8bae5df71adde1a71e541dd55b0b81b97b3baf
Reviewed-on: https://go-review.googlesource.com/c/go/+/277992
Reviewed-by: Josh Bleecher Snyder
Reviewed-by: Ian Lance Taylor
Trust: Josh Bleecher Snyder
---
src/net/http/pprof/pprof.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/net/http/pprof/pprof.go b/src/net/http/pprof/pprof.go
index 2bfcfb9545..5389a388c1 100644
--- a/src/net/http/pprof/pprof.go
+++ b/src/net/http/pprof/pprof.go
@@ -91,7 +91,7 @@ func init() {
func Cmdline(w http.ResponseWriter, r *http.Request) {
w.Header().Set("X-Content-Type-Options", "nosniff")
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
- fmt.Fprintf(w, strings.Join(os.Args, "\x00"))
+ fmt.Fprint(w, strings.Join(os.Args, "\x00"))
}
func sleep(r *http.Request, d time.Duration) {
From 033390d9adb0e7a96d0558bb1702e270ef986c90 Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld"
Date: Sun, 8 Nov 2020 02:48:09 +0100
Subject: [PATCH 33/66] cmd/link: recognize arm header of PE objects
The linker recognizes headers for 386 and amd64 PE objects, but not arm
objects. This is easily overlooked, since its the same as the 386 header
value, except the two nibbles of the first word are swapped. This commit
simply adds the check for this. Without it, .syso objects are rejected,
which means Windows binaries can't have resources built into them. At
the same time, we add comments to better indicate which condition
applies to which arch.
Change-Id: I210411d978504c1a9540e23abc5a180e24f159ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/268237
Reviewed-by: Cherry Zhang
Trust: Alex Brainman
Trust: Jason A. Donenfeld
---
src/cmd/link/internal/ld/lib.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
index e1cc7184de..8dd24371d5 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -1801,7 +1801,7 @@ func ldobj(ctxt *Link, f *bio.Reader, lib *sym.Library, length int64, pn string,
return ldhostobj(ldmacho, ctxt.HeadType, f, pkg, length, pn, file)
}
- if c1 == 0x4c && c2 == 0x01 || c1 == 0x64 && c2 == 0x86 {
+ if /* x86 */ c1 == 0x4c && c2 == 0x01 || /* x86_64 */ c1 == 0x64 && c2 == 0x86 || /* armv7 */ c1 == 0xc4 && c2 == 0x01 {
ldpe := func(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
textp, rsrc, err := loadpe.Load(ctxt.loader, ctxt.Arch, ctxt.IncVersion(), f, pkg, length, pn)
if err != nil {
From 48dfa2b2dca43c6dc80d7e1d1c605e2918fad3af Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld"
Date: Sun, 8 Nov 2020 03:09:42 +0100
Subject: [PATCH 34/66] cmd/link: deal with ADDR32NB relocations the same way
as ADDR32 on arm
As far as I can tell, the addend is the same for both of these, and in
this context we don't really care about setting or unsetting the thumb
selection bit, so just treat these the same way.
Change-Id: I3756c027239f77778c32b317733df9ac92272580
Reviewed-on: https://go-review.googlesource.com/c/go/+/268238
Reviewed-by: Cherry Zhang
Trust: Jason A. Donenfeld
---
src/cmd/link/internal/loadpe/ldpe.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cmd/link/internal/loadpe/ldpe.go b/src/cmd/link/internal/loadpe/ldpe.go
index 7677278ec5..c72965dddc 100644
--- a/src/cmd/link/internal/loadpe/ldpe.go
+++ b/src/cmd/link/internal/loadpe/ldpe.go
@@ -308,7 +308,7 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, input *bio.Read
rAdd = int64(int32(binary.LittleEndian.Uint32(sectdata[rsect][rOff:])))
- case IMAGE_REL_ARM_ADDR32:
+ case IMAGE_REL_ARM_ADDR32, IMAGE_REL_ARM_ADDR32NB:
rType = objabi.R_ADDR
rAdd = int64(int32(binary.LittleEndian.Uint32(sectdata[rsect][rOff:])))
From 663cd862edf8dfa9c78d9df0f372c9bea03139e4 Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld"
Date: Sun, 8 Nov 2020 11:11:27 +0100
Subject: [PATCH 35/66] cmd/link: do not mark resource section as writable
Resources are immutable, and all other linkers set this section to be
read-only and not read-write. Fix this oversight by removing the writable
flag.
Change-Id: Ib441bde6620be2000f1685df1ea7bfaebdbe7860
Reviewed-on: https://go-review.googlesource.com/c/go/+/268258
Reviewed-by: Cherry Zhang
Trust: Alex Brainman
Trust: Jason A. Donenfeld
---
src/cmd/link/internal/ld/pe.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cmd/link/internal/ld/pe.go b/src/cmd/link/internal/ld/pe.go
index d60aa55c36..adbf516d5c 100644
--- a/src/cmd/link/internal/ld/pe.go
+++ b/src/cmd/link/internal/ld/pe.go
@@ -1524,7 +1524,7 @@ func addpersrc(ctxt *Link) {
data := ctxt.loader.Data(rsrcsym)
size := len(data)
h := pefile.addSection(".rsrc", size, size)
- h.characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE | IMAGE_SCN_CNT_INITIALIZED_DATA
+ h.characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA
h.checkOffset(ctxt.Out.Offset())
// relocation
From 5a25a3fd1d8248c039e34f5ae02cc9c8198fc6d6 Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor
Date: Mon, 14 Dec 2020 13:26:35 -0800
Subject: [PATCH 36/66] test: recognize gofrontend error messages
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
fixedbugs/issue26416.go:24:16: error: unknown field ‘t1f1’ in ‘t2’
fixedbugs/issue26416.go:25:16: error: unknown field ‘t1f2’ in ‘t3’
fixedbugs/issue26416.go:26:16: error: unknown field ‘t2f1’ in ‘t3’
fixedbugs/issue26616.go:15:9: error: single variable set to multiple-value function call
fixedbugs/issue26616.go:9:5: error: incompatible type in initialization (multiple-value function call in single-value context)
fixedbugs/issue26616.go:12:13: error: incompatible type in initialization (multiple-value function call in single-value context)
fixedbugs/issue26616.go:13:13: error: incompatible type in initialization (multiple-value function call in single-value context)
fixedbugs/issue26616.go:15:9: error: incompatible type in initialization (multiple-value function call in single-value context)
fixedbugs/issue26616.go:14:11: error: incompatible types in assignment (multiple-value function call in single-value context)
fixedbugs/issue26855.go:23:12: error: incompatible type for field 1 in struct construction
fixedbugs/issue26855.go:27:12: error: incompatible type for field 1 in struct construction
fixedbugs/issue25958.go:14:18: error: expected ‘<-’ or ‘=’
fixedbugs/issue25958.go:15:35: error: expected ‘<-’ or ‘=’
fixedbugs/issue28079b.go:13:9: error: array bound is not constant
fixedbugs/issue28079b.go:16:22: error: invalid context-determined non-integer type for left operand of shift
fixedbugs/issue28079c.go:14:22: error: invalid context-determined non-integer type for left operand of shift
fixedbugs/issue28450.go:9:19: error: ‘...’ only permits one name
fixedbugs/issue28450.go:10:18: error: ‘...’ must be last parameter
fixedbugs/issue28450.go:11:16: error: ‘...’ must be last parameter
fixedbugs/issue28450.go:11:24: error: ‘...’ must be last parameter
fixedbugs/issue28450.go:13:25: error: ‘...’ must be last parameter
fixedbugs/issue28450.go:15:19: error: ‘...’ must be last parameter
fixedbugs/issue28450.go:16:21: error: ‘...’ must be last parameter
fixedbugs/issue28450.go:16:31: error: ‘...’ must be last parameter
fixedbugs/issue28268.go:20:1: error: method ‘E’ redeclares struct field name
fixedbugs/issue28268.go:19:1: error: method ‘b’ redeclares struct field name
fixedbugs/issue27356.go:14:14: error: expected function
fixedbugs/issue27356.go:18:9: error: expected function
fixedbugs/issue29855.go:13:11: error: unknown field ‘Name’ in ‘T’
fixedbugs/issue27938.go:14:15: error: expected package
fixedbugs/issue27938.go:18:13: error: expected package
fixedbugs/issue27938.go:22:13: error: expected package
fixedbugs/issue27938.go:22:9: error: expected signature or type name
fixedbugs/issue29870b.go:13:9: error: ‘x’ declared but not used
fixedbugs/issue30085.go:10:18: error: wrong number of initializations
fixedbugs/issue30085.go:11:21: error: wrong number of initializations
fixedbugs/issue30087.go:10:18: error: wrong number of initializations
fixedbugs/issue30087.go:11:11: error: number of variables does not match number of values
fixedbugs/issue30087.go:12:9: error: wrong number of initializations
fixedbugs/issue30087.go:13:9: error: wrong number of initializations
fixedbugs/issue28926.go:16:14: error: use of undefined type ‘G’
fixedbugs/issue28926.go:18:14: error: use of undefined type ‘E’
fixedbugs/issue28926.go:22:24: error: use of undefined type ‘T’
fixedbugs/issue30722.go:13:13: error: invalid numeric literal
fixedbugs/issue30722.go:14:13: error: invalid numeric literal
fixedbugs/issue30722.go:15:13: error: invalid numeric literal
fixedbugs/issue33308.go:12:19: error: invalid context-determined non-integer type for left operand of shift
fixedbugs/issue33386.go:16:9: error: expected operand
fixedbugs/issue33386.go:22:9: error: expected operand
fixedbugs/issue33386.go:26:17: error: expected operand
fixedbugs/issue33386.go:27:18: error: expected operand
fixedbugs/issue33386.go:28:29: error: expected operand
fixedbugs/issue33386.go:15:17: error: reference to undefined name ‘send’
fixedbugs/issue33386.go:27:13: error: reference to undefined name ‘a’
fixedbugs/issue33386.go:21:19: error: value computed is not used
fixedbugs/issue33460.go:34:10: error: duplicate key in map literal
fixedbugs/issue33460.go:21:9: error: duplicate case in switch
fixedbugs/issue33460.go:24:9: error: duplicate case in switch
fixedbugs/issue33460.go:25:9: error: duplicate case in switch
fixedbugs/issue32723.go:12:14: error: invalid comparison of non-ordered type
fixedbugs/issue32723.go:13:13: error: invalid comparison of non-ordered type
fixedbugs/issue32723.go:16:16: error: invalid comparison of non-ordered type
fixedbugs/issue32723.go:17:16: error: invalid comparison of non-ordered type
fixedbugs/issue32723.go:18:15: error: invalid comparison of non-ordered type
fixedbugs/issue32723.go:21:15: error: invalid comparison of non-ordered type
fixedbugs/issue35291.go:13:9: error: duplicate value for index 1
fixedbugs/issue38745.go:12:12: error: reference to undefined field or method ‘M’
fixedbugs/issue38745.go:13:16: error: reference to undefined field or method ‘M’
fixedbugs/issue38745.go:17:19: error: reference to undefined field or method ‘M’
fixedbugs/issue38745.go:17:9: error: not enough arguments to return
fixedbugs/issue41500.go:16:22: error: incompatible types in binary expression
fixedbugs/issue41500.go:17:26: error: incompatible types in binary expression
fixedbugs/issue41500.go:18:22: error: incompatible types in binary expression
fixedbugs/issue41500.go:19:26: error: incompatible types in binary expression
fixedbugs/issue41575.go:23:6: error: invalid recursive type
fixedbugs/issue41575.go:9:6: error: invalid recursive type ‘T1’
fixedbugs/issue41575.go:13:6: error: invalid recursive type ‘T2’
fixedbugs/issue41575.go:17:6: error: invalid recursive type ‘a’
fixedbugs/issue41575.go:18:6: error: invalid recursive type ‘b’
fixedbugs/issue41575.go:19:6: error: invalid recursive type ‘c’
fixedbugs/issue41575.go:25:6: error: invalid recursive type ‘g’
fixedbugs/issue41575.go:32:6: error: invalid recursive type ‘x’
fixedbugs/issue41575.go:33:6: error: invalid recursive type ‘y’
fixedbugs/issue4215.go:10:9: error: not enough arguments to return
fixedbugs/issue4215.go:14:9: error: return with value in function with no return type
fixedbugs/issue4215.go:19:17: error: not enough arguments to return
fixedbugs/issue4215.go:21:9: error: not enough arguments to return
fixedbugs/issue4215.go:27:17: error: not enough arguments to return
fixedbugs/issue4215.go:29:17: error: too many values in return statement
fixedbugs/issue4215.go:31:17: error: not enough arguments to return
fixedbugs/issue4215.go:43:17: error: not enough arguments to return
fixedbugs/issue4215.go:46:17: error: not enough arguments to return
fixedbugs/issue4215.go:48:9: error: too many values in return statement
fixedbugs/issue4215.go:52:9: error: too many values in return statement
fixedbugs/issue41247.go:10:16: error: incompatible type for return value 1
fixedbugs/issue41440.go:13:9: error: too many arguments
fixedbugs/issue6772.go:10:16: error: ‘a’ repeated on left side of :=
fixedbugs/issue6772.go:17:16: error: ‘a’ repeated on left side of :=
fixedbugs/issue6402.go:12:16: error: incompatible type for return value 1
fixedbugs/issue6403.go:13:23: error: reference to undefined identifier ‘syscall.X’
fixedbugs/issue6403.go:14:15: error: reference to undefined name ‘voidpkg’
fixedbugs/issue7746.go:24:20: error: constant multiplication overflow
fixedbugs/issue7760.go:15:7: error: invalid constant type
fixedbugs/issue7760.go:16:7: error: invalid constant type
fixedbugs/issue7760.go:18:7: error: invalid constant type
fixedbugs/issue7760.go:19:7: error: invalid constant type
fixedbugs/issue7760.go:21:11: error: expression is not constant
fixedbugs/issue7760.go:22:11: error: expression is not constant
fixedbugs/issue7760.go:24:7: error: invalid constant type
fixedbugs/issue7760.go:25:7: error: invalid constant type
fixedbugs/issue7129.go:18:11: error: argument 1 has incompatible type (cannot use type bool as type int)
fixedbugs/issue7129.go:19:11: error: argument 1 has incompatible type (cannot use type bool as type int)
fixedbugs/issue7129.go:20:11: error: argument 1 has incompatible type (cannot use type bool as type int)
fixedbugs/issue7129.go:20:17: error: argument 2 has incompatible type (cannot use type bool as type int)
fixedbugs/issue7150.go:12:20: error: index expression is negative
fixedbugs/issue7150.go:13:13: error: some element keys in composite literal are out of range
fixedbugs/issue7150.go:14:13: error: some element keys in composite literal are out of range
fixedbugs/issue7150.go:15:13: error: some element keys in composite literal are out of range
fixedbugs/issue7150.go:16:13: error: some element keys in composite literal are out of range
fixedbugs/issue7675.go:16:11: error: argument 1 has incompatible type (cannot use type int as type string)
fixedbugs/issue7675.go:16:24: error: argument 3 has incompatible type (cannot use type string as type float64)
fixedbugs/issue7675.go:16:9: error: not enough arguments
fixedbugs/issue7675.go:16:14: error: floating-point constant truncated to integer
fixedbugs/issue7675.go:18:11: error: argument 1 has incompatible type (cannot use type int as type string)
fixedbugs/issue7675.go:18:24: error: argument 3 has incompatible type (cannot use type string as type float64)
fixedbugs/issue7675.go:18:28: error: argument 4 has incompatible type (cannot use type int as type string)
fixedbugs/issue7675.go:18:9: error: too many arguments
fixedbugs/issue7675.go:18:14: error: floating-point constant truncated to integer
fixedbugs/issue7675.go:19:11: error: argument 1 has incompatible type (cannot use type int as type string)
fixedbugs/issue7675.go:19:9: error: not enough arguments
fixedbugs/issue7675.go:19:14: error: floating-point constant truncated to integer
fixedbugs/issue7675.go:21:11: error: argument 1 has incompatible type (cannot use type int as type string)
fixedbugs/issue7675.go:21:19: error: argument 3 has incompatible type
fixedbugs/issue7675.go:21:14: error: floating-point constant truncated to integer
fixedbugs/issue7675.go:23:14: error: floating-point constant truncated to integer
fixedbugs/issue7153.go:11:15: error: reference to undefined name ‘a’
fixedbugs/issue7153.go:11:18: error: incompatible type for element 1 in composite literal
fixedbugs/issue7153.go:11:24: error: incompatible type for element 2 in composite literal
fixedbugs/issue7310.go:12:13: error: left argument must be a slice
fixedbugs/issue7310.go:13:13: error: second argument must be slice or string
fixedbugs/issue7310.go:14:15: error: incompatible types in binary expression
fixedbugs/issue6964.go:10:13: error: invalid type conversion (cannot use type complex128 as type string)
fixedbugs/issue7538a.go:14:9: error: reference to undefined label ‘_’
fixedbugs/issue8311.go:14:9: error: increment or decrement of non-numeric type
fixedbugs/issue8507.go:12:6: error: invalid recursive type ‘T’
fixedbugs/issue9521.go:16:20: error: argument 2 has incompatible type
fixedbugs/issue9521.go:17:20: error: argument 2 has incompatible type (cannot use type float64 as type int)
fixedbugs/issue8385.go:30:19: error: argument 1 has incompatible type (type has no methods)
fixedbugs/issue8385.go:30:14: error: not enough arguments
fixedbugs/issue8385.go:35:9: error: not enough arguments
fixedbugs/issue8385.go:36:9: error: not enough arguments
fixedbugs/issue8385.go:37:10: error: not enough arguments
fixedbugs/issue8385.go:38:10: error: not enough arguments
fixedbugs/issue8385.go:39:10: error: not enough arguments
fixedbugs/issue8385.go:40:10: error: not enough arguments
fixedbugs/issue8385.go:41:13: error: not enough arguments
fixedbugs/issue8438.go:13:23: error: incompatible type for element 1 in composite literal
fixedbugs/issue8438.go:14:22: error: incompatible type for element 1 in composite literal
fixedbugs/issue8438.go:15:23: error: incompatible type for element 1 in composite literal
fixedbugs/issue8440.go:10:9: error: reference to undefined name ‘n’
Change-Id: I5707aec7d3c9178c4f4d794d4827fc907b52efb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/278032
Trust: Ian Lance Taylor
Run-TryBot: Ian Lance Taylor
TryBot-Result: Go Bot
Reviewed-by: Cherry Zhang
---
test/fixedbugs/issue25958.go | 4 ++--
test/fixedbugs/issue26416.go | 6 +++---
test/fixedbugs/issue26616.go | 10 +++++-----
test/fixedbugs/issue26855.go | 4 ++--
test/fixedbugs/issue27356.go | 4 ++--
test/fixedbugs/issue27938.go | 6 +++---
test/fixedbugs/issue28079b.go | 4 ++--
test/fixedbugs/issue28079c.go | 2 +-
test/fixedbugs/issue28268.go | 4 ++--
test/fixedbugs/issue28450.go | 12 ++++++------
test/fixedbugs/issue28926.go | 6 +++---
test/fixedbugs/issue29855.go | 2 +-
test/fixedbugs/issue29870b.go | 2 +-
test/fixedbugs/issue30085.go | 4 ++--
test/fixedbugs/issue30087.go | 8 ++++----
test/fixedbugs/issue30722.go | 6 +++---
test/fixedbugs/issue32723.go | 12 ++++++------
test/fixedbugs/issue33308.go | 2 +-
test/fixedbugs/issue33386.go | 16 ++++++++--------
test/fixedbugs/issue33460.go | 12 ++++++------
test/fixedbugs/issue35291.go | 2 +-
test/fixedbugs/issue38745.go | 6 +++---
test/fixedbugs/issue41247.go | 2 +-
test/fixedbugs/issue41440.go | 2 +-
test/fixedbugs/issue41500.go | 8 ++++----
test/fixedbugs/issue41575.go | 18 +++++++++---------
test/fixedbugs/issue42058a.go | 4 ++--
test/fixedbugs/issue42058b.go | 2 +-
test/fixedbugs/issue4215.go | 22 +++++++++++-----------
test/fixedbugs/issue6402.go | 2 +-
test/fixedbugs/issue6403.go | 4 ++--
test/fixedbugs/issue6772.go | 4 ++--
test/fixedbugs/issue6889.go | 2 +-
test/fixedbugs/issue6964.go | 2 +-
test/fixedbugs/issue7129.go | 6 +++---
test/fixedbugs/issue7150.go | 10 +++++-----
test/fixedbugs/issue7153.go | 2 +-
test/fixedbugs/issue7310.go | 6 +++---
test/fixedbugs/issue7538a.go | 2 +-
test/fixedbugs/issue7675.go | 10 +++++-----
test/fixedbugs/issue7746.go | 4 ++--
test/fixedbugs/issue7760.go | 16 ++++++++--------
test/fixedbugs/issue8311.go | 2 +-
test/fixedbugs/issue8385.go | 16 ++++++++--------
test/fixedbugs/issue8438.go | 6 +++---
test/fixedbugs/issue8440.go | 2 +-
test/fixedbugs/issue8507.go | 2 +-
test/fixedbugs/issue9521.go | 4 ++--
48 files changed, 147 insertions(+), 147 deletions(-)
diff --git a/test/fixedbugs/issue25958.go b/test/fixedbugs/issue25958.go
index ba7ee82230..90fcee15fd 100644
--- a/test/fixedbugs/issue25958.go
+++ b/test/fixedbugs/issue25958.go
@@ -11,7 +11,7 @@ package p
func f(done chan struct{}) {
select {
- case done: // ERROR "must be receive", "not used"
- case (chan struct{})(done): // ERROR "must be receive"
+ case done: // ERROR "must be receive|expected .*<-.* or .*=" "not used"
+ case (chan struct{})(done): // ERROR "must be receive|expected .*<-.* or .*="
}
}
diff --git a/test/fixedbugs/issue26416.go b/test/fixedbugs/issue26416.go
index bc37fd9d3a..44a4fc73b7 100644
--- a/test/fixedbugs/issue26416.go
+++ b/test/fixedbugs/issue26416.go
@@ -21,7 +21,7 @@ type t3 struct {
}
var (
- _ = t2{t1f1: 600} // ERROR "cannot use promoted field t1.t1f1 in struct literal of type t2"
- _ = t3{t1f2: 800} // ERROR "cannot use promoted field t2.t1.t1f2 in struct literal of type t3"
- _ = t3{t2f1: 900} // ERROR "cannot use promoted field t2.t2f1 in struct literal of type t3"
+ _ = t2{t1f1: 600} // ERROR "cannot use promoted field t1.t1f1 in struct literal of type t2|unknown field"
+ _ = t3{t1f2: 800} // ERROR "cannot use promoted field t2.t1.t1f2 in struct literal of type t3|unknown field"
+ _ = t3{t2f1: 900} // ERROR "cannot use promoted field t2.t2f1 in struct literal of type t3|unknown field"
)
diff --git a/test/fixedbugs/issue26616.go b/test/fixedbugs/issue26616.go
index e5565b68ca..87c0293661 100644
--- a/test/fixedbugs/issue26616.go
+++ b/test/fixedbugs/issue26616.go
@@ -6,13 +6,13 @@
package p
-var x int = three() // ERROR "assignment mismatch: 1 variable but three returns 3 values"
+var x int = three() // ERROR "assignment mismatch: 1 variable but three returns 3 values|multiple-value function call in single-value context"
func f() {
- var _ int = three() // ERROR "assignment mismatch: 1 variable but three returns 3 values"
- var a int = three() // ERROR "assignment mismatch: 1 variable but three returns 3 values"
- a = three() // ERROR "assignment mismatch: 1 variable but three returns 3 values"
- b := three() // ERROR "assignment mismatch: 1 variable but three returns 3 values"
+ var _ int = three() // ERROR "assignment mismatch: 1 variable but three returns 3 values|multiple-value function call in single-value context"
+ var a int = three() // ERROR "assignment mismatch: 1 variable but three returns 3 values|multiple-value function call in single-value context"
+ a = three() // ERROR "assignment mismatch: 1 variable but three returns 3 values|multiple-value function call in single-value context"
+ b := three() // ERROR "assignment mismatch: 1 variable but three returns 3 values|single variable set to multiple-value|multiple-value function call in single-value context"
_, _ = a, b
}
diff --git a/test/fixedbugs/issue26855.go b/test/fixedbugs/issue26855.go
index 144e4415f7..b965635a65 100644
--- a/test/fixedbugs/issue26855.go
+++ b/test/fixedbugs/issue26855.go
@@ -20,9 +20,9 @@ type P struct {
type T struct{}
var _ = S{
- f: &T{}, // ERROR "cannot use &T{}"
+ f: &T{}, // ERROR "cannot use &T{}|incompatible type"
}
var _ = P{
- f: T{}, // ERROR "cannot use T{}"
+ f: T{}, // ERROR "cannot use T{}|incompatible type"
}
diff --git a/test/fixedbugs/issue27356.go b/test/fixedbugs/issue27356.go
index 42784876a5..c3e686df33 100644
--- a/test/fixedbugs/issue27356.go
+++ b/test/fixedbugs/issue27356.go
@@ -11,9 +11,9 @@ package p
var a = []int{1,2,3}
func _(len int) {
- _ = len(a) // ERROR "cannot call non-function"
+ _ = len(a) // ERROR "cannot call non-function|expected function"
}
var cap = false
-var _ = cap(a) // ERROR "cannot call non-function"
+var _ = cap(a) // ERROR "cannot call non-function|expected function"
diff --git a/test/fixedbugs/issue27938.go b/test/fixedbugs/issue27938.go
index b0007be928..ed974e642d 100644
--- a/test/fixedbugs/issue27938.go
+++ b/test/fixedbugs/issue27938.go
@@ -11,13 +11,13 @@
package p
type _ struct {
- F sync.Mutex // ERROR "undefined: sync"
+ F sync.Mutex // ERROR "undefined: sync|expected package"
}
type _ struct {
- sync.Mutex // ERROR "undefined: sync"
+ sync.Mutex // ERROR "undefined: sync|expected package"
}
type _ interface {
- sync.Mutex // ERROR "undefined: sync"
+ sync.Mutex // ERROR "undefined: sync|expected package|expected signature or type name"
}
diff --git a/test/fixedbugs/issue28079b.go b/test/fixedbugs/issue28079b.go
index 47cc16dfb2..d1992e1d09 100644
--- a/test/fixedbugs/issue28079b.go
+++ b/test/fixedbugs/issue28079b.go
@@ -10,8 +10,8 @@ package p
import "unsafe"
-type T [uintptr(unsafe.Pointer(nil))]int // ERROR "non-constant array bound"
+type T [uintptr(unsafe.Pointer(nil))]int // ERROR "non-constant array bound|array bound is not constant"
func f() {
- _ = complex(1<= 0 {
- return 1 // ERROR "not enough arguments to return\n\thave \(number\)\n\twant \(int, int, int, int\)"
+ return 1 // ERROR "not enough arguments to return\n\thave \(number\)\n\twant \(int, int, int, int\)|not enough arguments to return"
}
- return 2, 3 // ERROR "not enough arguments to return\n\thave \(number, number\)\n\twant \(int, int, int, int\)"
+ return 2, 3 // ERROR "not enough arguments to return\n\thave \(number, number\)\n\twant \(int, int, int, int\)|not enough arguments to return"
}
func foo4(name string) (string, int) {
switch name {
case "cow":
- return "moo" // ERROR "not enough arguments to return\n\thave \(string\)\n\twant \(string, int\)"
+ return "moo" // ERROR "not enough arguments to return\n\thave \(string\)\n\twant \(string, int\)|not enough arguments to return"
case "dog":
- return "dog", 10, true // ERROR "too many arguments to return\n\thave \(string, number, bool\)\n\twant \(string, int\)"
+ return "dog", 10, true // ERROR "too many arguments to return\n\thave \(string, number, bool\)\n\twant \(string, int\)|too many values in return statement"
case "fish":
- return "" // ERROR "not enough arguments to return\n\thave \(string\)\n\twant \(string, int\)"
+ return "" // ERROR "not enough arguments to return\n\thave \(string\)\n\twant \(string, int\)|not enough arguments to return"
default:
return "lizard", 10
}
@@ -40,14 +40,14 @@ type U float64
func foo5() (S, T, U) {
if false {
- return "" // ERROR "not enough arguments to return\n\thave \(string\)\n\twant \(S, T, U\)"
+ return "" // ERROR "not enough arguments to return\n\thave \(string\)\n\twant \(S, T, U\)|not enough arguments to return"
} else {
ptr := new(T)
- return ptr // ERROR "not enough arguments to return\n\thave \(\*T\)\n\twant \(S, T, U\)"
+ return ptr // ERROR "not enough arguments to return\n\thave \(\*T\)\n\twant \(S, T, U\)|not enough arguments to return"
}
- return new(S), 12.34, 1 + 0i, 'r', true // ERROR "too many arguments to return\n\thave \(\*S, number, number, number, bool\)\n\twant \(S, T, U\)"
+ return new(S), 12.34, 1 + 0i, 'r', true // ERROR "too many arguments to return\n\thave \(\*S, number, number, number, bool\)\n\twant \(S, T, U\)|too many values in return statement"
}
func foo6() (T, string) {
- return "T", true, true // ERROR "too many arguments to return\n\thave \(string, bool, bool\)\n\twant \(T, string\)"
+ return "T", true, true // ERROR "too many arguments to return\n\thave \(string, bool, bool\)\n\twant \(T, string\)|too many values in return statement"
}
diff --git a/test/fixedbugs/issue6402.go b/test/fixedbugs/issue6402.go
index da5980c9ab..ecde9ae510 100644
--- a/test/fixedbugs/issue6402.go
+++ b/test/fixedbugs/issue6402.go
@@ -9,5 +9,5 @@
package p
func f() uintptr {
- return nil // ERROR "cannot use nil as type uintptr in return argument"
+ return nil // ERROR "cannot use nil as type uintptr in return argument|incompatible type"
}
diff --git a/test/fixedbugs/issue6403.go b/test/fixedbugs/issue6403.go
index b61e2e225d..809efefa0f 100644
--- a/test/fixedbugs/issue6403.go
+++ b/test/fixedbugs/issue6403.go
@@ -10,5 +10,5 @@ package p
import "syscall"
-const A int = syscall.X // ERROR "undefined: syscall.X"
-const B int = voidpkg.X // ERROR "undefined: voidpkg"
+const A int = syscall.X // ERROR "undefined: syscall.X|undefined identifier .*syscall.X"
+const B int = voidpkg.X // ERROR "undefined: voidpkg|undefined name .*voidpkg"
diff --git a/test/fixedbugs/issue6772.go b/test/fixedbugs/issue6772.go
index 4d0001c870..5bd15ba72e 100644
--- a/test/fixedbugs/issue6772.go
+++ b/test/fixedbugs/issue6772.go
@@ -7,14 +7,14 @@
package p
func f1() {
- for a, a := range []int{1, 2, 3} { // ERROR "a repeated on left side of :="
+ for a, a := range []int{1, 2, 3} { // ERROR "a.* repeated on left side of :="
println(a)
}
}
func f2() {
var a int
- for a, a := range []int{1, 2, 3} { // ERROR "a repeated on left side of :="
+ for a, a := range []int{1, 2, 3} { // ERROR "a.* repeated on left side of :="
println(a)
}
println(a)
diff --git a/test/fixedbugs/issue6889.go b/test/fixedbugs/issue6889.go
index 805a877d58..efd8b76148 100644
--- a/test/fixedbugs/issue6889.go
+++ b/test/fixedbugs/issue6889.go
@@ -107,5 +107,5 @@ const (
f96 = f95 * 96
f97 = f96 * 97
f98 = f97 * 98
- f99 = f98 * 99 // ERROR "overflow"
+ f99 = f98 * 99 // GC_ERROR "overflow"
)
diff --git a/test/fixedbugs/issue6964.go b/test/fixedbugs/issue6964.go
index 7ad83364ab..36a3c5bb40 100644
--- a/test/fixedbugs/issue6964.go
+++ b/test/fixedbugs/issue6964.go
@@ -7,5 +7,5 @@
package main
func main() {
- _ = string(-4 + 2i + 2) // ERROR "-4 \+ 2i"
+ _ = string(-4 + 2i + 2) // ERROR "-4 \+ 2i|invalid type conversion"
}
diff --git a/test/fixedbugs/issue7129.go b/test/fixedbugs/issue7129.go
index 2425cbd343..2765200ac8 100644
--- a/test/fixedbugs/issue7129.go
+++ b/test/fixedbugs/issue7129.go
@@ -15,7 +15,7 @@ func g() bool { return true }
func h(int, int) {}
func main() {
- f(g()) // ERROR "in argument to f"
- f(true) // ERROR "in argument to f"
- h(true, true) // ERROR "in argument to h"
+ f(g()) // ERROR "in argument to f|incompatible type"
+ f(true) // ERROR "in argument to f|incompatible type"
+ h(true, true) // ERROR "in argument to h|incompatible type"
}
diff --git a/test/fixedbugs/issue7150.go b/test/fixedbugs/issue7150.go
index 8a8a7d088f..7cddf4875e 100644
--- a/test/fixedbugs/issue7150.go
+++ b/test/fixedbugs/issue7150.go
@@ -9,9 +9,9 @@
package main
func main() {
- _ = [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\]"
+ _ = [0]int{-1: 50} // ERROR "index must be non-negative integer constant|index expression is negative"
+ _ = [0]int{0: 0} // ERROR "index 0 out of bounds \[0:0\]|out of range"
+ _ = [0]int{5: 25} // ERROR "index 5 out of bounds \[0:0\]|out of range"
+ _ = [10]int{2: 10, 15: 30} // ERROR "index 15 out of bounds \[0:10\]|out of range"
+ _ = [10]int{5: 5, 1: 1, 12: 12} // ERROR "index 12 out of bounds \[0:10\]|out of range"
}
diff --git a/test/fixedbugs/issue7153.go b/test/fixedbugs/issue7153.go
index 66b1338496..e8b95d5db8 100644
--- a/test/fixedbugs/issue7153.go
+++ b/test/fixedbugs/issue7153.go
@@ -8,4 +8,4 @@
package p
-var _ = []int{a: true, true} // ERROR "undefined: a" "cannot use true \(type untyped bool\) as type int in slice literal"
+var _ = []int{a: true, true} // ERROR "undefined: a" "cannot use true \(type untyped bool\) as type int in slice literal|undefined name .*a|incompatible type"
diff --git a/test/fixedbugs/issue7310.go b/test/fixedbugs/issue7310.go
index 6829d5e126..ba50e4237b 100644
--- a/test/fixedbugs/issue7310.go
+++ b/test/fixedbugs/issue7310.go
@@ -9,7 +9,7 @@
package main
func main() {
- _ = copy(nil, []int{}) // ERROR "use of untyped nil"
- _ = copy([]int{}, nil) // ERROR "use of untyped nil"
- _ = 1 + true // ERROR "mismatched types untyped int and untyped bool"
+ _ = copy(nil, []int{}) // ERROR "use of untyped nil|left argument must be a slice"
+ _ = copy([]int{}, nil) // ERROR "use of untyped nil|second argument must be slice or string"
+ _ = 1 + true // ERROR "mismatched types untyped int and untyped bool|incompatible types"
}
diff --git a/test/fixedbugs/issue7538a.go b/test/fixedbugs/issue7538a.go
index 283d9eb1ba..b1701508d8 100644
--- a/test/fixedbugs/issue7538a.go
+++ b/test/fixedbugs/issue7538a.go
@@ -11,5 +11,5 @@ package p
func f() {
_:
_:
- goto _ // ERROR "not defined"
+ goto _ // ERROR "not defined|undefined label"
}
diff --git a/test/fixedbugs/issue7675.go b/test/fixedbugs/issue7675.go
index d97ee357a2..6cda05f332 100644
--- a/test/fixedbugs/issue7675.go
+++ b/test/fixedbugs/issue7675.go
@@ -13,12 +13,12 @@ func f(string, int, float64, string)
func g(string, int, float64, ...string)
func main() {
- f(1, 0.5, "hello") // ERROR "not enough arguments"
+ f(1, 0.5, "hello") // ERROR "not enough arguments|incompatible type"
f("1", 2, 3.1, "4")
- f(1, 0.5, "hello", 4, 5) // ERROR "too many arguments"
- g(1, 0.5) // ERROR "not enough arguments"
+ f(1, 0.5, "hello", 4, 5) // ERROR "too many arguments|incompatible type"
+ g(1, 0.5) // ERROR "not enough arguments|incompatible type"
g("1", 2, 3.1)
- g(1, 0.5, []int{3, 4}...) // ERROR "not enough arguments"
+ g(1, 0.5, []int{3, 4}...) // ERROR "not enough arguments|incompatible type"
g("1", 2, 3.1, "4", "5")
- g(1, 0.5, "hello", 4, []int{5, 6}...) // ERROR "too many arguments"
+ g(1, 0.5, "hello", 4, []int{5, 6}...) // ERROR "too many arguments|truncated to integer"
}
diff --git a/test/fixedbugs/issue7746.go b/test/fixedbugs/issue7746.go
index 0dc119d2e6..745496293d 100644
--- a/test/fixedbugs/issue7746.go
+++ b/test/fixedbugs/issue7746.go
@@ -10,7 +10,7 @@ const (
c0 = 1 << 100
c1 = c0 * c0
c2 = c1 * c1
- c3 = c2 * c2 // ERROR "overflow"
+ c3 = c2 * c2 // GC_ERROR "overflow"
c4 = c3 * c3
c5 = c4 * c4
c6 = c5 * c5
@@ -21,7 +21,7 @@ const (
c11 = c10 * c10
c12 = c11 * c11
c13 = c12 * c12
- c14 = c13 * c13
+ c14 = c13 * c13 // GCCGO_ERROR "overflow"
c15 = c14 * c14
c16 = c15 * c15
c17 = c16 * c16
diff --git a/test/fixedbugs/issue7760.go b/test/fixedbugs/issue7760.go
index cccae48910..7e1d03596e 100644
--- a/test/fixedbugs/issue7760.go
+++ b/test/fixedbugs/issue7760.go
@@ -12,14 +12,14 @@ import "unsafe"
type myPointer unsafe.Pointer
-const _ = unsafe.Pointer(uintptr(1)) // ERROR "is not (a )?constant"
-const _ = myPointer(uintptr(1)) // ERROR "is not (a )?constant"
+const _ = unsafe.Pointer(uintptr(1)) // ERROR "is not (a )?constant|invalid constant type"
+const _ = myPointer(uintptr(1)) // ERROR "is not (a )?constant|invalid constant type"
-const _ = (*int)(unsafe.Pointer(uintptr(1))) // ERROR "is not (a )?constant"
-const _ = (*int)(myPointer(uintptr(1))) // ERROR "is not (a )?constant"
+const _ = (*int)(unsafe.Pointer(uintptr(1))) // ERROR "is not (a )?constant|invalid constant type"
+const _ = (*int)(myPointer(uintptr(1))) // ERROR "is not (a )?constant|invalid constant type"
-const _ = uintptr(unsafe.Pointer(uintptr(1))) // ERROR "is not (a )?constant"
-const _ = uintptr(myPointer(uintptr(1))) // ERROR "is not (a )?constant"
+const _ = uintptr(unsafe.Pointer(uintptr(1))) // ERROR "is not (a )?constant|expression is not constant"
+const _ = uintptr(myPointer(uintptr(1))) // ERROR "is not (a )?constant|expression is no constant"
-const _ = []byte("") // ERROR "is not (a )?constant"
-const _ = []rune("") // ERROR "is not (a )?constant"
+const _ = []byte("") // ERROR "is not (a )?constant|invalid constant type"
+const _ = []rune("") // ERROR "is not (a )?constant|invalid constant type"
diff --git a/test/fixedbugs/issue8311.go b/test/fixedbugs/issue8311.go
index 375b480a17..b5fd5daea1 100644
--- a/test/fixedbugs/issue8311.go
+++ b/test/fixedbugs/issue8311.go
@@ -11,6 +11,6 @@ package p
func f() {
var x []byte
- x++ // ERROR "invalid operation: x[+][+]"
+ x++ // ERROR "invalid operation: x[+][+]|non-numeric type"
}
diff --git a/test/fixedbugs/issue8385.go b/test/fixedbugs/issue8385.go
index 6447e9f0e8..f3d395e521 100644
--- a/test/fixedbugs/issue8385.go
+++ b/test/fixedbugs/issue8385.go
@@ -27,16 +27,16 @@ func (t T) M(x int) {
func g() func(int)
func main() {
- Fooer.Foo(5, 6) // ERROR "not enough arguments in call to method expression Fooer.Foo"
+ Fooer.Foo(5, 6) // ERROR "not enough arguments in call to method expression Fooer.Foo|incompatible type|not enough arguments"
var i I
var t *T
- g()() // ERROR "not enough arguments in call to g\(\)"
- f() // ERROR "not enough arguments in call to f"
- i.M() // ERROR "not enough arguments in call to i\.M"
- I.M() // ERROR "not enough arguments in call to method expression I\.M"
- t.M() // ERROR "not enough arguments in call to t\.M"
- T.M() // ERROR "not enough arguments in call to method expression T\.M"
- (*T).M() // ERROR "not enough arguments in call to method expression \(\*T\)\.M"
+ g()() // ERROR "not enough arguments in call to g\(\)|not enough arguments"
+ f() // ERROR "not enough arguments in call to f|not enough arguments"
+ i.M() // ERROR "not enough arguments in call to i\.M|not enough arguments"
+ I.M() // ERROR "not enough arguments in call to method expression I\.M|not enough arguments"
+ t.M() // ERROR "not enough arguments in call to t\.M|not enough arguments"
+ T.M() // ERROR "not enough arguments in call to method expression T\.M|not enough arguments"
+ (*T).M() // ERROR "not enough arguments in call to method expression \(\*T\)\.M|not enough arguments"
}
diff --git a/test/fixedbugs/issue8438.go b/test/fixedbugs/issue8438.go
index 3a4f193b57..f433e36924 100644
--- a/test/fixedbugs/issue8438.go
+++ b/test/fixedbugs/issue8438.go
@@ -10,8 +10,8 @@
package main
func main() {
- _ = []byte{"foo"} // ERROR "cannot use"
- _ = []int{"foo"} // ERROR "cannot use"
- _ = []rune{"foo"} // ERROR "cannot use"
+ _ = []byte{"foo"} // ERROR "cannot use|incompatible type"
+ _ = []int{"foo"} // ERROR "cannot use|incompatible type"
+ _ = []rune{"foo"} // ERROR "cannot use|incompatible type"
_ = []string{"foo"} // OK
}
diff --git a/test/fixedbugs/issue8440.go b/test/fixedbugs/issue8440.go
index f9b1dea3eb..e9c5b54d51 100644
--- a/test/fixedbugs/issue8440.go
+++ b/test/fixedbugs/issue8440.go
@@ -7,5 +7,5 @@
package main
func main() {
- n.foo = 6 // ERROR "undefined: n in n.foo"
+ n.foo = 6 // ERROR "undefined: n in n.foo|undefined name .*n"
}
diff --git a/test/fixedbugs/issue8507.go b/test/fixedbugs/issue8507.go
index ad6ba8ac68..392ecf4063 100644
--- a/test/fixedbugs/issue8507.go
+++ b/test/fixedbugs/issue8507.go
@@ -9,7 +9,7 @@
package p
-type T struct{ T } // ERROR "invalid recursive type T"
+type T struct{ T } // ERROR "invalid recursive type .*T"
func f() {
println(T{} == T{})
diff --git a/test/fixedbugs/issue9521.go b/test/fixedbugs/issue9521.go
index a33f0483f3..1ad40bdfda 100644
--- a/test/fixedbugs/issue9521.go
+++ b/test/fixedbugs/issue9521.go
@@ -13,6 +13,6 @@ func f() (_, _ []int) { return }
func g() (x []int, y float64) { return }
func main() {
- _ = append(f()) // ERROR "cannot use \[\]int value as type int in append"
- _ = append(g()) // ERROR "cannot use float64 value as type int in append"
+ _ = append(f()) // ERROR "cannot use \[\]int value as type int in append|incompatible type"
+ _ = append(g()) // ERROR "cannot use float64 value as type int in append|incompatible type"
}
From 3298300ddf45a0792b4d8ea5e05f0fbceec4c9f9 Mon Sep 17 00:00:00 2001
From: Meng Zhuo
Date: Thu, 10 Dec 2020 09:52:52 +0800
Subject: [PATCH 37/66] text/template: error on range over send channel
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
template range require channel contains RecvDir
if recv on send only channel will raise an panic.
Fixes #43065
Change-Id: Ie0ea70ce60e074bf8c9f2378e07ef1d4c41dc38f
Reviewed-on: https://go-review.googlesource.com/c/go/+/276532
Trust: Meng Zhuo
Run-TryBot: Meng Zhuo
TryBot-Result: Go Bot
Reviewed-by: Jonathan Amsterdam
Reviewed-by: Daniel Martí
---
src/text/template/exec.go | 4 ++++
src/text/template/exec_test.go | 13 +++++++++++++
2 files changed, 17 insertions(+)
diff --git a/src/text/template/exec.go b/src/text/template/exec.go
index 7ac5175006..19154fc640 100644
--- a/src/text/template/exec.go
+++ b/src/text/template/exec.go
@@ -373,6 +373,10 @@ func (s *state) walkRange(dot reflect.Value, r *parse.RangeNode) {
if val.IsNil() {
break
}
+ if val.Type().ChanDir() == reflect.SendDir {
+ s.errorf("range over send-only channel %v", val)
+ break
+ }
i := 0
for ; ; i++ {
elem, ok := val.Recv()
diff --git a/src/text/template/exec_test.go b/src/text/template/exec_test.go
index 1611ee054f..1a129ed5af 100644
--- a/src/text/template/exec_test.go
+++ b/src/text/template/exec_test.go
@@ -1697,3 +1697,16 @@ func TestIssue31810(t *testing.T) {
t.Errorf("%s got %q, expected %q", textCall, b.String(), "result")
}
}
+
+// Issue 43065, range over send only channel
+func TestIssue43065(t *testing.T) {
+ var b bytes.Buffer
+ tmp := Must(New("").Parse(`{{range .}}{{end}}`))
+ ch := make(chan<- int)
+ err := tmp.Execute(&b, ch)
+ if err == nil {
+ t.Error("expected err got nil")
+ } else if !strings.Contains(err.Error(), "range over send-only channel") {
+ t.Errorf("%s", err)
+ }
+}
From 5046cb8a6e8496f70e47f648ed368ffe87bc5e4e Mon Sep 17 00:00:00 2001
From: Tobias Klauser
Date: Tue, 15 Dec 2020 10:36:10 +0100
Subject: [PATCH 38/66] doc/go1.16: fix formatting in net, net/http and
net/http/httputil sections
For #40700.
Change-Id: I83d9ef9f79d59a0165a47ccc938fc2bf40e90703
Reviewed-on: https://go-review.googlesource.com/c/go/+/278212
Trust: Tobias Klauser
Reviewed-by: Dmitri Shuralyov
---
doc/go1.16.html | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/doc/go1.16.html b/doc/go1.16.html
index edac1dbd35..2190ed6cd3 100644
--- a/doc/go1.16.html
+++ b/doc/go1.16.html
@@ -721,8 +721,8 @@ func TestFoo(t *testing.T) {
The case of I/O on a closed network connection, or I/O on a network
connection that is closed before any of the I/O completes, can now
- be detected using the new ErrClosed error.
- A typical use would be errors.Is(err, net.ErrClosed).
+ be detected using the new ErrClosed
+ error. A typical use would be errors.Is(err, net.ErrClosed).
In earlier releases the only way to reliably detect this case was to
match the string returned by the Error method
with "use of closed network connection".
@@ -786,9 +786,10 @@ func TestFoo(t *testing.T) {
- The ProxyFromEnvironment function
- no longer returns the setting of the HTTP_PROXY environment
- variable for https:// URLs when HTTPS_PROXY is unset.
+ The ProxyFromEnvironment
+ function no longer returns the setting of the HTTP_PROXY
+ environment variable for https:// URLs when
+ HTTPS_PROXY is unset.