aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-07-20 12:46:13 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-07-20 14:34:09 -0700
commite4994e71fb1809d8ce7df89e471586e05797e171 (patch)
treec48395ef73ff6e411de6512877e7d8ffd9a76e52
parentc6d3d0b0ad10926fc1952deda913d139ed608cb3 (diff)
parentc8f4e6152d5f0b767a8177b7d09884cf2279d8e6 (diff)
downloadgo-e4994e71fb1809d8ce7df89e471586e05797e171.tar.gz
go-e4994e71fb1809d8ce7df89e471586e05797e171.zip
[dev.typeparams] all: merge master (c8f4e61) into dev.typeparams
Conflicts: - src/runtime/internal/sys/zgoarch_386.go - src/runtime/internal/sys/zgoarch_amd64.go - src/runtime/internal/sys/zgoarch_arm.go - src/runtime/internal/sys/zgoarch_arm64.go - src/runtime/internal/sys/zgoarch_arm64be.go - src/runtime/internal/sys/zgoarch_armbe.go - src/runtime/internal/sys/zgoarch_mips.go - src/runtime/internal/sys/zgoarch_mips64.go - src/runtime/internal/sys/zgoarch_mips64le.go - src/runtime/internal/sys/zgoarch_mips64p32.go - src/runtime/internal/sys/zgoarch_mips64p32le.go - src/runtime/internal/sys/zgoarch_mipsle.go - src/runtime/internal/sys/zgoarch_ppc.go - src/runtime/internal/sys/zgoarch_ppc64.go - src/runtime/internal/sys/zgoarch_ppc64le.go - src/runtime/internal/sys/zgoarch_riscv.go - src/runtime/internal/sys/zgoarch_riscv64.go - src/runtime/internal/sys/zgoarch_s390.go - src/runtime/internal/sys/zgoarch_s390x.go - src/runtime/internal/sys/zgoarch_sparc.go - src/runtime/internal/sys/zgoarch_sparc64.go - src/runtime/internal/sys/zgoarch_wasm.go On dev.typeparams, CL 328336 moved these files to internal/goarch; whereas on master, CL 333909 reserved GOARCH=loong64. For this CL, I resolved the conflict by simply running "go generate internal/goarch". Merge List: + 2021-07-19 c8f4e6152d spec: correct example comment in Conversions from slice to array + 2021-07-19 1d91551b73 time: correct typo in documentation for UnixMicro + 2021-07-19 404127c30f cmd/compile: fix off-by-one error in traceback argument counting + 2021-07-19 6298cfe672 cmd/compile: fix typo in fatal message of builtinCall + 2021-07-19 49402bee36 cmd/{compile,link}: fix bug in map.zero handling + 2021-07-18 a66190ecee test/bench/go1: fix size for RegexpMatchMedium_32 + 2021-07-18 650fc2117a text/scanner: use Go convention in Position doc comment + 2021-07-16 aa4e0f528e net/http: correct capitalization in cancelTimeBody comment + 2021-07-15 0941dbca6a testing: clarify in docs that TestMain is advanced + 2021-07-15 69728ead87 cmd/go: update error messages in tests to match CL 332573 + 2021-07-15 c1cc9f9c3d cmd/compile: fix lookup package of redeclared dot import symbol + 2021-07-15 21a04e3335 doc/go1.17: mention GOARCH=loong64 + 2021-07-14 2b00a54baf go/build, runtime/internal/sys: reserve GOARCH=loong64 + 2021-07-14 60ddf42b46 cmd/go: change link in error message from /wiki to /doc. + 2021-07-13 d8f348a589 cmd/go: remove a duplicated word from 'go help mod graph' + 2021-07-12 a98589711d crypto/tls: test key type when casting + 2021-07-12 cfbd73ba33 doc/go1.17: editing pass over the "Compiler" section + 2021-07-09 ab4085ce84 runtime/pprof: call runtime.GC twice in memory profile test Change-Id: I1490a4c7e4c560659c21a4eb67d243f35d1f908e
-rw-r--r--doc/go1.17.html73
-rw-r--r--doc/go_spec.html2
-rw-r--r--src/cmd/compile/internal/gc/obj.go2
-rw-r--r--src/cmd/compile/internal/ssagen/ssa.go43
-rw-r--r--src/cmd/compile/internal/typecheck/dcl.go12
-rw-r--r--src/cmd/compile/internal/typecheck/iimport.go2
-rw-r--r--src/cmd/go/alldocs.go2
-rw-r--r--src/cmd/go/internal/modcmd/graph.go2
-rw-r--r--src/cmd/go/internal/modload/load.go2
-rw-r--r--src/cmd/go/testdata/script/mod_tidy_compat_ambiguous.txt2
-rw-r--r--src/cmd/go/testdata/script/mod_tidy_compat_deleted.txt2
-rw-r--r--src/cmd/go/testdata/script/mod_tidy_compat_implicit.txt2
-rw-r--r--src/cmd/go/testdata/script/mod_tidy_compat_incompatible.txt2
-rw-r--r--src/cmd/link/internal/loader/loader.go9
-rw-r--r--src/crypto/tls/key_agreement.go6
-rw-r--r--src/go/build/syslist.go2
-rw-r--r--src/internal/goarch/zgoarch_386.go1
-rw-r--r--src/internal/goarch/zgoarch_amd64.go1
-rw-r--r--src/internal/goarch/zgoarch_arm.go1
-rw-r--r--src/internal/goarch/zgoarch_arm64.go1
-rw-r--r--src/internal/goarch/zgoarch_arm64be.go1
-rw-r--r--src/internal/goarch/zgoarch_armbe.go1
-rw-r--r--src/internal/goarch/zgoarch_loong64.go33
-rw-r--r--src/internal/goarch/zgoarch_mips.go1
-rw-r--r--src/internal/goarch/zgoarch_mips64.go1
-rw-r--r--src/internal/goarch/zgoarch_mips64le.go1
-rw-r--r--src/internal/goarch/zgoarch_mips64p32.go1
-rw-r--r--src/internal/goarch/zgoarch_mips64p32le.go1
-rw-r--r--src/internal/goarch/zgoarch_mipsle.go1
-rw-r--r--src/internal/goarch/zgoarch_ppc.go1
-rw-r--r--src/internal/goarch/zgoarch_ppc64.go1
-rw-r--r--src/internal/goarch/zgoarch_ppc64le.go1
-rw-r--r--src/internal/goarch/zgoarch_riscv.go1
-rw-r--r--src/internal/goarch/zgoarch_riscv64.go1
-rw-r--r--src/internal/goarch/zgoarch_s390.go1
-rw-r--r--src/internal/goarch/zgoarch_s390x.go1
-rw-r--r--src/internal/goarch/zgoarch_sparc.go1
-rw-r--r--src/internal/goarch/zgoarch_sparc64.go1
-rw-r--r--src/internal/goarch/zgoarch_wasm.go1
-rw-r--r--src/net/http/client.go2
-rw-r--r--src/runtime/pprof/mprof_test.go11
-rw-r--r--src/runtime/traceback_test.go179
-rw-r--r--src/testing/testing.go2
-rw-r--r--src/text/scanner/scanner.go2
-rw-r--r--src/time/time.go2
-rw-r--r--test/bench/go1/regexp_test.go2
-rw-r--r--test/fixedbugs/issue47185.dir/bad/bad.go72
-rw-r--r--test/fixedbugs/issue47185.dir/main.go28
-rw-r--r--test/fixedbugs/issue47185.go11
-rw-r--r--test/fixedbugs/issue47201.dir/a.go13
-rw-r--r--test/fixedbugs/issue47201.dir/b.go9
-rw-r--r--test/fixedbugs/issue47201.go7
-rw-r--r--test/run.go1
53 files changed, 486 insertions, 75 deletions
diff --git a/doc/go1.17.html b/doc/go1.17.html
index 4fa30158bb..b31006fe65 100644
--- a/doc/go1.17.html
+++ b/doc/go1.17.html
@@ -119,6 +119,17 @@ Do not send CLs removing the interior tags from such phrases.
stack frame pointers only on Linux, macOS, and iOS.
</p>
+<h3 id="loong64">loong64 GOARCH value reserved</h3>
+
+<p><!-- CL 333909 -->
+ The main Go compiler does not yet support the LoongArch
+ architecture, but we've reserved the <code>GOARCH</code> value
+ "<code>loong64</code>".
+ This means that Go files named <code>*_loong64.go</code> will now
+ be <a href="/pkg/go/build/#hdr-Build_Constraints">ignored by Go
+ tools</a> except when that GOARCH value is being used.
+</p>
+
<h2 id="tools">Tools</h2>
<h3 id="go-command">Go command</h3>
@@ -401,30 +412,37 @@ func Foo() bool {
<p><!-- golang.org/issue/40724 -->
Go 1.17 implements a new way of passing function arguments and results using
- registers instead of the stack. This work is enabled for Linux, macOS, and
- Windows on the 64-bit x86 architecture (the <code>linux/amd64</code>,
- <code>darwin/amd64</code>, <code>windows/amd64</code> ports). For a
- representative set of Go packages and programs, benchmarking has shown
- performance improvements of about 5%, and a typical reduction in binary size
- of about 2%.
+ registers instead of the stack.
+ Benchmarks for a representative set of Go packages and programs show
+ performance improvements of about 5%, and a typical reduction in
+ binary size of about 2%.
+ This is currently enabled for Linux, macOS, and Windows on the
+ 64-bit x86 architecture (the <code>linux/amd64</code>,
+ <code>darwin/amd64</code>, and <code>windows/amd64</code> ports).
</p>
<p>
- This change does not affect the functionality of any safe Go code. It can affect
- code outside the <a href="/doc/go1compat">compatibility guidelines</a> with
- minimal impact. To maintain compatibility with existing assembly functions,
- adapter functions converting between the new register-based calling convention
- and the previous stack-based calling convention (also known as ABI wrappers)
- are sometimes used. This is mostly invisible to users, except for assembly
- functions that have their addresses taken in Go. Using <code>reflect.ValueOf(fn).Pointer()</code>
- (or similar approaches such as via <code>unsafe.Pointer</code>) to get the address
- of an assembly function will now return the address of the ABI wrapper. This is
- mostly harmless, except for special-purpose assembly code (such as accessing
- thread-local storage or requiring a special stack alignment). Assembly functions
- called indirectly from Go via <code>func</code> values will now be made through
- ABI wrappers, which may cause a very small performance overhead. Also, calling
- Go functions from assembly may now go through ABI wrappers, with a very small
- performance overhead.
+ This change does not affect the functionality of any safe Go code
+ and is designed to have no impact on most assembly code.
+ It may affect code that violates
+ the <a href="/pkg/unsafe#Pointer"><code>unsafe.Pointer</code></a>
+ rules when accessing function arguments, or that depends on
+ undocumented behavior involving comparing function code pointers.
+ To maintain compatibility with existing assembly functions, the
+ compiler generates adapter functions that convert between the new
+ register-based calling convention and the previous stack-based
+ calling convention.
+ These adapters are typically invisible to users, except that taking
+ the address of a Go function in assembly code or taking the address
+ of an assembly function in Go code
+ using <code>reflect.ValueOf(fn).Pointer()</code>
+ or <code>unsafe.Pointer</code> will now return the address of the
+ adapter.
+ Code that depends on the value of these code pointers may no longer
+ behave as expected.
+ Adapters also may cause a very small performance overhead in two
+ cases: calling an assembly function indirectly from Go via
+ a <code>func</code> value, and calling Go functions from assembly.
</p>
<p><!-- CL 304470 -->
@@ -440,11 +458,14 @@ func Foo() bool {
</p>
<p><!-- CL 283112, golang.org/issue/28727 -->
- Functions containing closures can now be inlined. One effect of this change is
- that a function with a closure may actually produce a distinct closure function
- for each place that the function is inlined. Hence, this change could reveal
- bugs where Go functions are compared (incorrectly) by pointer value. Go
- functions are by definition not comparable.
+ Functions containing closures can now be inlined.
+ One effect of this change is that a function with a closure may
+ produce a distinct closure code pointer for each place that the
+ function is inlined.
+ Go function values are not directly comparable, but this change
+ could reveal bugs in code that uses <code>reflect</code>
+ or <code>unsafe.Pointer</code> to bypass this language restriction
+ and compare functions by code pointer.
</p>
<h2 id="library">Core library</h2>
diff --git a/doc/go_spec.html b/doc/go_spec.html
index ad21ffb1b8..df256f0f0e 100644
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -4334,7 +4334,7 @@ s4 := (*[4]byte)(s) // panics: len([4]byte) > len(s)
var t []string
t0 := (*[0]string)(t) // t0 == nil
-t1 := (*[1]string)(t) // panics: len([1]string) > len(s)
+t1 := (*[1]string)(t) // panics: len([1]string) > len(t)
</pre>
<h3 id="Constant_expressions">Constant expressions</h3>
diff --git a/src/cmd/compile/internal/gc/obj.go b/src/cmd/compile/internal/gc/obj.go
index 440f898211..c86bf5f084 100644
--- a/src/cmd/compile/internal/gc/obj.go
+++ b/src/cmd/compile/internal/gc/obj.go
@@ -149,7 +149,7 @@ func dumpdata() {
if reflectdata.ZeroSize > 0 {
zero := base.PkgLinksym("go.map", "zero", obj.ABI0)
objw.Global(zero, int32(reflectdata.ZeroSize), obj.DUPOK|obj.RODATA)
- zero.Set(obj.AttrContentAddressable, true)
+ zero.Set(obj.AttrStatic, true)
}
staticdata.WriteFuncSyms()
diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go
index 8367751dd5..c087b71fe6 100644
--- a/src/cmd/compile/internal/ssagen/ssa.go
+++ b/src/cmd/compile/internal/ssagen/ssa.go
@@ -6434,6 +6434,7 @@ func EmitArgInfo(f *ir.Func, abiInfo *abi.ABIParamResultInfo) *obj.LSym {
x := base.Ctxt.Lookup(fmt.Sprintf("%s.arginfo%d", f.LSym.Name, f.ABI))
PtrSize := int64(types.PtrSize)
+ uintptrTyp := types.Types[types.TUINTPTR]
isAggregate := func(t *types.Type) bool {
return t.IsStruct() || t.IsArray() || t.IsComplex() || t.IsInterface() || t.IsString() || t.IsSlice()
@@ -6477,12 +6478,8 @@ func EmitArgInfo(f *ir.Func, abiInfo *abi.ABIParamResultInfo) *obj.LSym {
n := 0
writebyte := func(o uint8) { wOff = objw.Uint8(x, wOff, o) }
- // Write one non-aggrgate arg/field/element if there is room.
- // Returns whether to continue.
- write1 := func(sz, offset int64) bool {
- if n >= limit {
- return false
- }
+ // Write one non-aggrgate arg/field/element.
+ write1 := func(sz, offset int64) {
if offset >= _special {
writebyte(_offsetTooLarge)
} else {
@@ -6490,7 +6487,6 @@ func EmitArgInfo(f *ir.Func, abiInfo *abi.ABIParamResultInfo) *obj.LSym {
writebyte(uint8(sz))
}
n++
- return true
}
// Visit t recursively and write it out.
@@ -6498,10 +6494,12 @@ func EmitArgInfo(f *ir.Func, abiInfo *abi.ABIParamResultInfo) *obj.LSym {
var visitType func(baseOffset int64, t *types.Type, depth int) bool
visitType = func(baseOffset int64, t *types.Type, depth int) bool {
if n >= limit {
+ writebyte(_dotdotdot)
return false
}
if !isAggregate(t) {
- return write1(t.Size(), baseOffset)
+ write1(t.Size(), baseOffset)
+ return true
}
writebyte(_startAgg)
depth++
@@ -6511,58 +6509,47 @@ func EmitArgInfo(f *ir.Func, abiInfo *abi.ABIParamResultInfo) *obj.LSym {
n++
return true
}
- var r bool
switch {
case t.IsInterface(), t.IsString():
- r = write1(PtrSize, baseOffset) &&
- write1(PtrSize, baseOffset+PtrSize)
+ _ = visitType(baseOffset, uintptrTyp, depth) &&
+ visitType(baseOffset+PtrSize, uintptrTyp, depth)
case t.IsSlice():
- r = write1(PtrSize, baseOffset) &&
- write1(PtrSize, baseOffset+PtrSize) &&
- write1(PtrSize, baseOffset+PtrSize*2)
+ _ = visitType(baseOffset, uintptrTyp, depth) &&
+ visitType(baseOffset+PtrSize, uintptrTyp, depth) &&
+ visitType(baseOffset+PtrSize*2, uintptrTyp, depth)
case t.IsComplex():
- r = write1(t.Size()/2, baseOffset) &&
- write1(t.Size()/2, baseOffset+t.Size()/2)
+ _ = visitType(baseOffset, types.FloatForComplex(t), depth) &&
+ visitType(baseOffset+t.Size()/2, types.FloatForComplex(t), depth)
case t.IsArray():
- r = true
if t.NumElem() == 0 {
n++ // {} counts as a component
break
}
for i := int64(0); i < t.NumElem(); i++ {
if !visitType(baseOffset, t.Elem(), depth) {
- r = false
break
}
baseOffset += t.Elem().Size()
}
case t.IsStruct():
- r = true
if t.NumFields() == 0 {
n++ // {} counts as a component
break
}
for _, field := range t.Fields().Slice() {
if !visitType(baseOffset+field.Offset, field.Type, depth) {
- r = false
break
}
}
}
- if !r {
- writebyte(_dotdotdot)
- }
writebyte(_endAgg)
- return r
+ return true
}
- c := true
for _, a := range abiInfo.InParams() {
- if !c {
- writebyte(_dotdotdot)
+ if !visitType(a.FrameOffset(abiInfo), a.Type, 0) {
break
}
- c = visitType(a.FrameOffset(abiInfo), a.Type, 0)
}
writebyte(_endSeq)
if wOff > maxLen {
diff --git a/src/cmd/compile/internal/typecheck/dcl.go b/src/cmd/compile/internal/typecheck/dcl.go
index 90d3020fe0..11e20f0f07 100644
--- a/src/cmd/compile/internal/typecheck/dcl.go
+++ b/src/cmd/compile/internal/typecheck/dcl.go
@@ -106,7 +106,17 @@ func Export(n *ir.Name) {
// Redeclared emits a diagnostic about symbol s being redeclared at pos.
func Redeclared(pos src.XPos, s *types.Sym, where string) {
if !s.Lastlineno.IsKnown() {
- pkgName := DotImportRefs[s.Def.(*ir.Ident)]
+ var pkgName *ir.PkgName
+ if s.Def == nil {
+ for id, pkg := range DotImportRefs {
+ if id.Sym().Name == s.Name {
+ pkgName = pkg
+ break
+ }
+ }
+ } else {
+ pkgName = DotImportRefs[s.Def.(*ir.Ident)]
+ }
base.ErrorfAt(pos, "%v redeclared %s\n"+
"\t%v: previous declaration during import %q", s, where, base.FmtPos(pkgName.Pos()), pkgName.Pkg.Path)
} else {
diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go
index bf7f84b5cd..9bef07b636 100644
--- a/src/cmd/compile/internal/typecheck/iimport.go
+++ b/src/cmd/compile/internal/typecheck/iimport.go
@@ -1741,7 +1741,7 @@ func (r *importReader) exprsOrNil() (a, b ir.Node) {
func builtinCall(pos src.XPos, op ir.Op) *ir.CallExpr {
if go117ExportTypes {
// These should all be encoded as direct ops, not OCALL.
- base.Fatalf("builtinCall should not be invoked when types are included in inport/export")
+ base.Fatalf("builtinCall should not be invoked when types are included in import/export")
}
return ir.NewCallExpr(pos, ir.OCALL, ir.NewIdent(base.Pos, types.BuiltinPkg.Lookup(ir.OpNames[op])), nil)
}
diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go
index 90eb3e2a00..954caae9fb 100644
--- a/src/cmd/go/alldocs.go
+++ b/src/cmd/go/alldocs.go
@@ -1193,7 +1193,7 @@
// and one of its requirements. Each module is identified as a string of the form
// path@version, except for the main module, which has no @version suffix.
//
-// The -go flag causes graph to report the module graph as loaded by by the
+// The -go flag causes graph to report the module graph as loaded by the
// given Go version, instead of the version indicated by the 'go' directive
// in the go.mod file.
//
diff --git a/src/cmd/go/internal/modcmd/graph.go b/src/cmd/go/internal/modcmd/graph.go
index 903bd9970f..ac81f26dad 100644
--- a/src/cmd/go/internal/modcmd/graph.go
+++ b/src/cmd/go/internal/modcmd/graph.go
@@ -26,7 +26,7 @@ in text form. Each line in the output has two space-separated fields: a module
and one of its requirements. Each module is identified as a string of the form
path@version, except for the main module, which has no @version suffix.
-The -go flag causes graph to report the module graph as loaded by by the
+The -go flag causes graph to report the module graph as loaded by the
given Go version, instead of the version indicated by the 'go' directive
in the go.mod file.
diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go
index 771b142b73..bce9ad85f4 100644
--- a/src/cmd/go/internal/modload/load.go
+++ b/src/cmd/go/internal/modload/load.go
@@ -1808,7 +1808,7 @@ func (ld *loader) checkTidyCompatibility(ctx context.Context, rs *Requirements)
fmt.Fprintf(os.Stderr, "If reproducibility with go %s is not needed:\n\tgo mod tidy%s -compat=%s\n", ld.TidyCompatibleVersion, goFlag, ld.GoVersion)
// TODO(#46141): Populate the linked wiki page.
- fmt.Fprintf(os.Stderr, "For other options, see:\n\thttps://golang.org/wiki/PruningModules\n")
+ fmt.Fprintf(os.Stderr, "For other options, see:\n\thttps://golang.org/doc/modules/pruning\n")
}
mg, err := rs.Graph(ctx)
diff --git a/src/cmd/go/testdata/script/mod_tidy_compat_ambiguous.txt b/src/cmd/go/testdata/script/mod_tidy_compat_ambiguous.txt
index ed1dd53eff..c544cb7413 100644
--- a/src/cmd/go/testdata/script/mod_tidy_compat_ambiguous.txt
+++ b/src/cmd/go/testdata/script/mod_tidy_compat_ambiguous.txt
@@ -23,7 +23,7 @@ cp go.mod go.mod.orig
stderr '^example\.com/m imports\n\texample\.net/indirect imports\n\texample\.net/ambiguous/nested/pkg loaded from example\.net/ambiguous/nested@v0\.1\.0,\n\tbut go 1.16 would fail to locate it:\n\tambiguous import: found package example\.net/ambiguous/nested/pkg in multiple modules:\n\texample\.net/ambiguous v0.1.0 \(.*\)\n\texample\.net/ambiguous/nested v0.1.0 \(.*\)\n\n'
-stderr '\n\nTo proceed despite packages unresolved in go 1\.16:\n\tgo mod tidy -e\nIf reproducibility with go 1.16 is not needed:\n\tgo mod tidy -compat=1\.17\nFor other options, see:\n\thttps://golang\.org/wiki/PruningModules\n'
+stderr '\n\nTo proceed despite packages unresolved in go 1\.16:\n\tgo mod tidy -e\nIf reproducibility with go 1.16 is not needed:\n\tgo mod tidy -compat=1\.17\nFor other options, see:\n\thttps://golang\.org/doc/modules/pruning\n'
cmp go.mod go.mod.orig
diff --git a/src/cmd/go/testdata/script/mod_tidy_compat_deleted.txt b/src/cmd/go/testdata/script/mod_tidy_compat_deleted.txt
index 3aacde2025..dcf13e2049 100644
--- a/src/cmd/go/testdata/script/mod_tidy_compat_deleted.txt
+++ b/src/cmd/go/testdata/script/mod_tidy_compat_deleted.txt
@@ -19,7 +19,7 @@ cp go.mod go.mod.orig
stderr '^example\.com/m imports\n\texample\.net/deleted loaded from example\.net/deleted@v0\.1\.0,\n\tbut go 1\.16 would fail to locate it in example\.net/deleted@v0\.2\.0\n\n'
-stderr '\n\nTo upgrade to the versions selected by go 1.16, leaving some packages unresolved:\n\tgo mod tidy -e -go=1\.16 && go mod tidy -e -go=1\.17\nIf reproducibility with go 1.16 is not needed:\n\tgo mod tidy -compat=1\.17\nFor other options, see:\n\thttps://golang\.org/wiki/PruningModules\n'
+stderr '\n\nTo upgrade to the versions selected by go 1.16, leaving some packages unresolved:\n\tgo mod tidy -e -go=1\.16 && go mod tidy -e -go=1\.17\nIf reproducibility with go 1.16 is not needed:\n\tgo mod tidy -compat=1\.17\nFor other options, see:\n\thttps://golang\.org/doc/modules/pruning\n'
# The suggested 'go mod tidy -e' command should proceed anyway.
diff --git a/src/cmd/go/testdata/script/mod_tidy_compat_implicit.txt b/src/cmd/go/testdata/script/mod_tidy_compat_implicit.txt
index e00aea930e..186a3f8e67 100644
--- a/src/cmd/go/testdata/script/mod_tidy_compat_implicit.txt
+++ b/src/cmd/go/testdata/script/mod_tidy_compat_implicit.txt
@@ -33,7 +33,7 @@ env MODFMT='{{with .Module}}{{.Path}} {{.Version}}{{end}}'
cp go.mod go.mod.orig
! go mod tidy
stderr '^example\.com/m imports\n\texample\.net/lazy tested by\n\texample\.net/lazy.test imports\n\texample\.com/retract/incompatible loaded from example\.com/retract/incompatible@v1\.0\.0,\n\tbut go 1\.16 would select v2\.0\.0\+incompatible\n\n'
-stderr '\n\nTo upgrade to the versions selected by go 1\.16:\n\tgo mod tidy -go=1\.16 && go mod tidy -go=1\.17\nIf reproducibility with go 1.16 is not needed:\n\tgo mod tidy -compat=1.17\nFor other options, see:\n\thttps://golang\.org/wiki/PruningModules\n'
+stderr '\n\nTo upgrade to the versions selected by go 1\.16:\n\tgo mod tidy -go=1\.16 && go mod tidy -go=1\.17\nIf reproducibility with go 1.16 is not needed:\n\tgo mod tidy -compat=1.17\nFor other options, see:\n\thttps://golang\.org/doc/modules/pruning\n'
cmp go.mod go.mod.orig
diff --git a/src/cmd/go/testdata/script/mod_tidy_compat_incompatible.txt b/src/cmd/go/testdata/script/mod_tidy_compat_incompatible.txt
index 2d8726544a..ea9e42e87e 100644
--- a/src/cmd/go/testdata/script/mod_tidy_compat_incompatible.txt
+++ b/src/cmd/go/testdata/script/mod_tidy_compat_incompatible.txt
@@ -33,7 +33,7 @@ env MODFMT='{{with .Module}}{{.Path}} {{.Version}}{{end}}'
cp go.mod go.mod.orig
! go mod tidy
stderr '^example\.com/m imports\n\texample\.net/lazy imports\n\texample\.com/retract/incompatible loaded from example\.com/retract/incompatible@v1\.0\.0,\n\tbut go 1\.16 would select v2\.0\.0\+incompatible\n\n'
-stderr '\n\nTo upgrade to the versions selected by go 1\.16:\n\tgo mod tidy -go=1\.16 && go mod tidy -go=1\.17\nIf reproducibility with go 1\.16 is not needed:\n\tgo mod tidy -compat=1.17\nFor other options, see:\n\thttps://golang\.org/wiki/PruningModules\n'
+stderr '\n\nTo upgrade to the versions selected by go 1\.16:\n\tgo mod tidy -go=1\.16 && go mod tidy -go=1\.17\nIf reproducibility with go 1\.16 is not needed:\n\tgo mod tidy -compat=1.17\nFor other options, see:\n\thttps://golang\.org/doc/modules/pruning\n'
cmp go.mod go.mod.orig
diff --git a/src/cmd/link/internal/loader/loader.go b/src/cmd/link/internal/loader/loader.go
index efca824d98..9d5319c312 100644
--- a/src/cmd/link/internal/loader/loader.go
+++ b/src/cmd/link/internal/loader/loader.go
@@ -459,6 +459,15 @@ func (st *loadState) addSym(name string, ver int, r *oReader, li uint32, kind in
if l.flags&FlagStrictDups != 0 {
l.checkdup(name, r, li, oldi)
}
+ // Fix for issue #47185 -- given two dupok symbols with
+ // different sizes, favor symbol with larger size. See
+ // also issue #46653.
+ szdup := l.SymSize(oldi)
+ sz := int64(r.Sym(li).Siz())
+ if szdup < sz {
+ // new symbol overwrites old symbol.
+ l.objSyms[oldi] = objSym{r.objidx, li}
+ }
return oldi
}
oldr, oldli := l.toLocal(oldi)
diff --git a/src/crypto/tls/key_agreement.go b/src/crypto/tls/key_agreement.go
index 8cfbd734f1..c28a64f3a8 100644
--- a/src/crypto/tls/key_agreement.go
+++ b/src/crypto/tls/key_agreement.go
@@ -86,7 +86,11 @@ func (ka rsaKeyAgreement) generateClientKeyExchange(config *Config, clientHello
return nil, nil, err
}
- encrypted, err := rsa.EncryptPKCS1v15(config.rand(), cert.PublicKey.(*rsa.PublicKey), preMasterSecret)
+ rsaKey, ok := cert.PublicKey.(*rsa.PublicKey)
+ if !ok {
+ return nil, nil, errors.New("tls: server certificate contains incorrect key type for selected ciphersuite")
+ }
+ encrypted, err := rsa.EncryptPKCS1v15(config.rand(), rsaKey, preMasterSecret)
if err != nil {
return nil, nil, err
}
diff --git a/src/go/build/syslist.go b/src/go/build/syslist.go
index 1275f7c986..60ac5511bd 100644
--- a/src/go/build/syslist.go
+++ b/src/go/build/syslist.go
@@ -8,4 +8,4 @@ package build
// Do not remove from this list, as these are used for go/build filename matching.
const goosList = "aix android darwin dragonfly freebsd hurd illumos ios js linux nacl netbsd openbsd plan9 solaris windows zos "
-const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc riscv riscv64 s390 s390x sparc sparc64 wasm "
+const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be ppc64 ppc64le loong64 mips mipsle mips64 mips64le mips64p32 mips64p32le ppc riscv riscv64 s390 s390x sparc sparc64 wasm "
diff --git a/src/internal/goarch/zgoarch_386.go b/src/internal/goarch/zgoarch_386.go
index 7fa23b07ef..2395b80951 100644
--- a/src/internal/goarch/zgoarch_386.go
+++ b/src/internal/goarch/zgoarch_386.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_amd64.go b/src/internal/goarch/zgoarch_amd64.go
index a6bf1cc6f4..c301d279c1 100644
--- a/src/internal/goarch/zgoarch_amd64.go
+++ b/src/internal/goarch/zgoarch_amd64.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_arm.go b/src/internal/goarch/zgoarch_arm.go
index dcdaa1f44d..4a5ff37999 100644
--- a/src/internal/goarch/zgoarch_arm.go
+++ b/src/internal/goarch/zgoarch_arm.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_arm64.go b/src/internal/goarch/zgoarch_arm64.go
index dd8d9806ab..840e280f94 100644
--- a/src/internal/goarch/zgoarch_arm64.go
+++ b/src/internal/goarch/zgoarch_arm64.go
@@ -16,6 +16,7 @@ const IsArm64 = 1
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_arm64be.go b/src/internal/goarch/zgoarch_arm64be.go
index a37df97031..bdbe5faacf 100644
--- a/src/internal/goarch/zgoarch_arm64be.go
+++ b/src/internal/goarch/zgoarch_arm64be.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 1
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_armbe.go b/src/internal/goarch/zgoarch_armbe.go
index 909b114330..36be514a0b 100644
--- a/src/internal/goarch/zgoarch_armbe.go
+++ b/src/internal/goarch/zgoarch_armbe.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_loong64.go b/src/internal/goarch/zgoarch_loong64.go
new file mode 100644
index 0000000000..9465cf5bf5
--- /dev/null
+++ b/src/internal/goarch/zgoarch_loong64.go
@@ -0,0 +1,33 @@
+// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
+
+//go:build loong64
+// +build loong64
+
+package goarch
+
+const GOARCH = `loong64`
+
+const Is386 = 0
+const IsAmd64 = 0
+const IsAmd64p32 = 0
+const IsArm = 0
+const IsArmbe = 0
+const IsArm64 = 0
+const IsArm64be = 0
+const IsPpc64 = 0
+const IsPpc64le = 0
+const IsLoong64 = 1
+const IsMips = 0
+const IsMipsle = 0
+const IsMips64 = 0
+const IsMips64le = 0
+const IsMips64p32 = 0
+const IsMips64p32le = 0
+const IsPpc = 0
+const IsRiscv = 0
+const IsRiscv64 = 0
+const IsS390 = 0
+const IsS390x = 0
+const IsSparc = 0
+const IsSparc64 = 0
+const IsWasm = 0
diff --git a/src/internal/goarch/zgoarch_mips.go b/src/internal/goarch/zgoarch_mips.go
index 0ff91f201a..e1458c0485 100644
--- a/src/internal/goarch/zgoarch_mips.go
+++ b/src/internal/goarch/zgoarch_mips.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 1
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_mips64.go b/src/internal/goarch/zgoarch_mips64.go
index 3b61356b18..7de345e321 100644
--- a/src/internal/goarch/zgoarch_mips64.go
+++ b/src/internal/goarch/zgoarch_mips64.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 1
diff --git a/src/internal/goarch/zgoarch_mips64le.go b/src/internal/goarch/zgoarch_mips64le.go
index 14c9330cad..96b1c3c021 100644
--- a/src/internal/goarch/zgoarch_mips64le.go
+++ b/src/internal/goarch/zgoarch_mips64le.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_mips64p32.go b/src/internal/goarch/zgoarch_mips64p32.go
index b7429f2bf3..91d1f3c4df 100644
--- a/src/internal/goarch/zgoarch_mips64p32.go
+++ b/src/internal/goarch/zgoarch_mips64p32.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_mips64p32le.go b/src/internal/goarch/zgoarch_mips64p32le.go
index 35c21c1675..18f2ef2347 100644
--- a/src/internal/goarch/zgoarch_mips64p32le.go
+++ b/src/internal/goarch/zgoarch_mips64p32le.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_mipsle.go b/src/internal/goarch/zgoarch_mipsle.go
index ba7be189bc..4551de1a32 100644
--- a/src/internal/goarch/zgoarch_mipsle.go
+++ b/src/internal/goarch/zgoarch_mipsle.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 1
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_ppc.go b/src/internal/goarch/zgoarch_ppc.go
index ab19982a12..ffed58c2e5 100644
--- a/src/internal/goarch/zgoarch_ppc.go
+++ b/src/internal/goarch/zgoarch_ppc.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_ppc64.go b/src/internal/goarch/zgoarch_ppc64.go
index d3e35ca877..c369c74166 100644
--- a/src/internal/goarch/zgoarch_ppc64.go
+++ b/src/internal/goarch/zgoarch_ppc64.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 1
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_ppc64le.go b/src/internal/goarch/zgoarch_ppc64le.go
index ef24e95c4d..de5bae2a81 100644
--- a/src/internal/goarch/zgoarch_ppc64le.go
+++ b/src/internal/goarch/zgoarch_ppc64le.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 1
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_riscv.go b/src/internal/goarch/zgoarch_riscv.go
index fe6b385c50..07c9d81b39 100644
--- a/src/internal/goarch/zgoarch_riscv.go
+++ b/src/internal/goarch/zgoarch_riscv.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_riscv64.go b/src/internal/goarch/zgoarch_riscv64.go
index 85299a6b4b..24e6ef3fdf 100644
--- a/src/internal/goarch/zgoarch_riscv64.go
+++ b/src/internal/goarch/zgoarch_riscv64.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_s390.go b/src/internal/goarch/zgoarch_s390.go
index 39325c473e..429206d653 100644
--- a/src/internal/goarch/zgoarch_s390.go
+++ b/src/internal/goarch/zgoarch_s390.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_s390x.go b/src/internal/goarch/zgoarch_s390x.go
index 64d714ace2..0c59005216 100644
--- a/src/internal/goarch/zgoarch_s390x.go
+++ b/src/internal/goarch/zgoarch_s390x.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_sparc.go b/src/internal/goarch/zgoarch_sparc.go
index 9ccd362414..83a356e4c7 100644
--- a/src/internal/goarch/zgoarch_sparc.go
+++ b/src/internal/goarch/zgoarch_sparc.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_sparc64.go b/src/internal/goarch/zgoarch_sparc64.go
index 490a714eb6..7c9d40986e 100644
--- a/src/internal/goarch/zgoarch_sparc64.go
+++ b/src/internal/goarch/zgoarch_sparc64.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/internal/goarch/zgoarch_wasm.go b/src/internal/goarch/zgoarch_wasm.go
index a4b4a38401..5aac1dfc47 100644
--- a/src/internal/goarch/zgoarch_wasm.go
+++ b/src/internal/goarch/zgoarch_wasm.go
@@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
+const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
diff --git a/src/net/http/client.go b/src/net/http/client.go
index e0cabc9d4c..4d380c65db 100644
--- a/src/net/http/client.go
+++ b/src/net/http/client.go
@@ -951,7 +951,7 @@ func (c *Client) CloseIdleConnections() {
}
// cancelTimerBody is an io.ReadCloser that wraps rc with two features:
-// 1) on Read error or close, the stop func is called.
+// 1) On Read error or close, the stop func is called.
// 2) On Read failure, if reqDidTimeout is true, the error is wrapped and
// marked as net.Error that hit its timeout.
type cancelTimerBody struct {
diff --git a/src/runtime/pprof/mprof_test.go b/src/runtime/pprof/mprof_test.go
index 3ef40d3de7..b4680fbdee 100644
--- a/src/runtime/pprof/mprof_test.go
+++ b/src/runtime/pprof/mprof_test.go
@@ -86,6 +86,17 @@ func TestMemoryProfiler(t *testing.T) {
runtime.GC() // materialize stats
+ // TODO(mknyszek): Fix #45315 and remove this extra call.
+ //
+ // Unfortunately, it's possible for the sweep termination condition
+ // to flap, so with just one runtime.GC call, a freed object could be
+ // missed, leading this test to fail. A second call reduces the chance
+ // of this happening to zero, because sweeping actually has to finish
+ // to move on to the next GC, during which nothing will happen.
+ //
+ // See #46500 for more details.
+ runtime.GC()
+
memoryProfilerRun++
tests := []struct {
diff --git a/src/runtime/traceback_test.go b/src/runtime/traceback_test.go
index 2a0497e9a9..83b86a7e90 100644
--- a/src/runtime/traceback_test.go
+++ b/src/runtime/traceback_test.go
@@ -19,8 +19,8 @@ func TestTracebackArgs(t *testing.T) {
}{
// simple ints
{
- func() int { return testTracebackArgs1(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) },
- "testTracebackArgs1(0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, ...)",
+ func() int { return testTracebackArgs1(1, 2, 3, 4, 5) },
+ "testTracebackArgs1(0x1, 0x2, 0x3, 0x4, 0x5)",
},
// some aggregates
{
@@ -53,6 +53,58 @@ func TestTracebackArgs(t *testing.T) {
},
"testTracebackArgs5(0x0, {0x1, {}, {{}, {}}}, {}, {}, {}, {}, {}, ...)",
},
+
+ // edge cases for ...
+ // no ... for 10 args
+ {
+ func() int { return testTracebackArgs6a(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) },
+ "testTracebackArgs6a(0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa)",
+ },
+ // has ... for 11 args
+ {
+ func() int { return testTracebackArgs6b(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) },
+ "testTracebackArgs6b(0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, ...)",
+ },
+ // no ... for aggregates with 10 words
+ {
+ func() int { return testTracebackArgs7a([10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) },
+ "testTracebackArgs7a({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa})",
+ },
+ // has ... for aggregates with 11 words
+ {
+ func() int { return testTracebackArgs7b([11]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}) },
+ "testTracebackArgs7b({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, ...})",
+ },
+ // no ... for aggregates, but with more args
+ {
+ func() int { return testTracebackArgs7c([10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 11) },
+ "testTracebackArgs7c({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa}, ...)",
+ },
+ // has ... for aggregates and also for more args
+ {
+ func() int { return testTracebackArgs7d([11]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 12) },
+ "testTracebackArgs7d({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, ...}, ...)",
+ },
+ // nested aggregates, no ...
+ {
+ func() int { return testTracebackArgs8a(testArgsType8a{1, 2, 3, 4, 5, 6, 7, 8, [2]int{9, 10}}) },
+ "testTracebackArgs8a({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, {0x9, 0xa}})",
+ },
+ // nested aggregates, ... in inner but not outer
+ {
+ func() int { return testTracebackArgs8b(testArgsType8b{1, 2, 3, 4, 5, 6, 7, 8, [3]int{9, 10, 11}}) },
+ "testTracebackArgs8b({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, {0x9, 0xa, ...}})",
+ },
+ // nested aggregates, ... in outer but not inner
+ {
+ func() int { return testTracebackArgs8c(testArgsType8c{1, 2, 3, 4, 5, 6, 7, 8, [2]int{9, 10}, 11}) },
+ "testTracebackArgs8c({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, {0x9, 0xa}, ...})",
+ },
+ // nested aggregates, ... in both inner and outer
+ {
+ func() int { return testTracebackArgs8d(testArgsType8d{1, 2, 3, 4, 5, 6, 7, 8, [3]int{9, 10, 11}, 12}) },
+ "testTracebackArgs8d({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, {0x9, 0xa, ...}, ...})",
+ },
}
for _, test := range tests {
n := test.fn()
@@ -64,11 +116,11 @@ func TestTracebackArgs(t *testing.T) {
}
//go:noinline
-func testTracebackArgs1(a, b, c, d, e, f, g, h, i, j, k, l int) int {
+func testTracebackArgs1(a, b, c, d, e int) int {
n := runtime.Stack(testTracebackArgsBuf[:], false)
if a < 0 {
// use in-reg args to keep them alive
- return a + b + c + d + e + f + g + h + i + j + k + l
+ return a + b + c + d + e
}
return n
}
@@ -119,3 +171,122 @@ func testTracebackArgs5(a bool, x struct {
}
return n
}
+
+//go:noinline
+func testTracebackArgs6a(a, b, c, d, e, f, g, h, i, j int) int {
+ n := runtime.Stack(testTracebackArgsBuf[:], false)
+ if a < 0 {
+ // use in-reg args to keep them alive
+ return a + b + c + d + e + f + g + h + i + j
+ }
+ return n
+}
+
+//go:noinline
+func testTracebackArgs6b(a, b, c, d, e, f, g, h, i, j, k int) int {
+ n := runtime.Stack(testTracebackArgsBuf[:], false)
+ if a < 0 {
+ // use in-reg args to keep them alive
+ return a + b + c + d + e + f + g + h + i + j + k
+ }
+ return n
+}
+
+//go:noinline
+func testTracebackArgs7a(a [10]int) int {
+ n := runtime.Stack(testTracebackArgsBuf[:], false)
+ if a[0] < 0 {
+ // use in-reg args to keep them alive
+ return a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9]
+ }
+ return n
+}
+
+//go:noinline
+func testTracebackArgs7b(a [11]int) int {
+ n := runtime.Stack(testTracebackArgsBuf[:], false)
+ if a[0] < 0 {
+ // use in-reg args to keep them alive
+ return a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9] + a[10]
+ }
+ return n
+}
+
+//go:noinline
+func testTracebackArgs7c(a [10]int, b int) int {
+ n := runtime.Stack(testTracebackArgsBuf[:], false)
+ if a[0] < 0 {
+ // use in-reg args to keep them alive
+ return a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9] + b
+ }
+ return n
+}
+
+//go:noinline
+func testTracebackArgs7d(a [11]int, b int) int {
+ n := runtime.Stack(testTracebackArgsBuf[:], false)
+ if a[0] < 0 {
+ // use in-reg args to keep them alive
+ return a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9] + a[10] + b
+ }
+ return n
+}
+
+type testArgsType8a struct {
+ a, b, c, d, e, f, g, h int
+ i [2]int
+}
+type testArgsType8b struct {
+ a, b, c, d, e, f, g, h int
+ i [3]int
+}
+type testArgsType8c struct {
+ a, b, c, d, e, f, g, h int
+ i [2]int
+ j int
+}
+type testArgsType8d struct {
+ a, b, c, d, e, f, g, h int
+ i [3]int
+ j int
+}
+
+//go:noinline
+func testTracebackArgs8a(a testArgsType8a) int {
+ n := runtime.Stack(testTracebackArgsBuf[:], false)
+ if a.a < 0 {
+ // use in-reg args to keep them alive
+ return a.b + a.c + a.d + a.e + a.f + a.g + a.h + a.i[0] + a.i[1]
+ }
+ return n
+}
+
+//go:noinline
+func testTracebackArgs8b(a testArgsType8b) int {
+ n := runtime.Stack(testTracebackArgsBuf[:], false)
+ if a.a < 0 {
+ // use in-reg args to keep them alive
+ return a.b + a.c + a.d + a.e + a.f + a.g + a.h + a.i[0] + a.i[1] + a.i[2]
+ }
+ return n
+}
+
+//go:noinline
+func testTracebackArgs8c(a testArgsType8c) int {
+ n := runtime.Stack(testTracebackArgsBuf[:], false)
+ if a.a < 0 {
+ // use in-reg args to keep them alive
+ return a.b + a.c + a.d + a.e + a.f + a.g + a.h + a.i[0] + a.i[1] + a.j
+ }
+ return n
+}
+
+//go:noinline
+func testTracebackArgs8d(a testArgsType8d) int {
+ n := runtime.Stack(testTracebackArgsBuf[:], false)
+ if a.a < 0 {
+ // use in-reg args to keep them alive
+ return a.b + a.c + a.d + a.e + a.f + a.g + a.h + a.i[0] + a.i[1] + a.i[2] + a.j
+ }
+ return n
+}
diff --git a/src/testing/testing.go b/src/testing/testing.go
index eeee0aac17..681f99ef93 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -233,6 +233,8 @@
// os.Exit(m.Run())
// }
//
+// TestMain is a low-level primitive and should not be necessary for casual
+// testing needs, where ordinary test functions suffice.
package testing
import (
diff --git a/src/text/scanner/scanner.go b/src/text/scanner/scanner.go
index e0847a7239..c5fc4ff93b 100644
--- a/src/text/scanner/scanner.go
+++ b/src/text/scanner/scanner.go
@@ -23,7 +23,7 @@ import (
"unicode/utf8"
)
-// A source position is represented by a Position value.
+// Position is a value that represents a source position.
// A position is valid if Line > 0.
type Position struct {
Filename string // filename, if any
diff --git a/src/time/time.go b/src/time/time.go
index 1cf1e2bbf6..4ecc3d82dc 100644
--- a/src/time/time.go
+++ b/src/time/time.go
@@ -1334,7 +1334,7 @@ func UnixMilli(msec int64) Time {
}
// UnixMicro returns the local Time corresponding to the given Unix time,
-// usec milliseconds since January 1, 1970 UTC.
+// usec microseconds since January 1, 1970 UTC.
func UnixMicro(usec int64) Time {
return Unix(usec/1e6, (usec%1e6)*1e3)
}
diff --git a/test/bench/go1/regexp_test.go b/test/bench/go1/regexp_test.go
index 3ce9f3a2c6..dd1034fde5 100644
--- a/test/bench/go1/regexp_test.go
+++ b/test/bench/go1/regexp_test.go
@@ -53,7 +53,7 @@ func BenchmarkRegexpMatchEasy0_32(b *testing.B) { benchmark(b, easy0, 32<<0) }
func BenchmarkRegexpMatchEasy0_1K(b *testing.B) { benchmark(b, easy0, 1<<10) }
func BenchmarkRegexpMatchEasy1_32(b *testing.B) { benchmark(b, easy1, 32<<0) }
func BenchmarkRegexpMatchEasy1_1K(b *testing.B) { benchmark(b, easy1, 1<<10) }
-func BenchmarkRegexpMatchMedium_32(b *testing.B) { benchmark(b, medium, 1<<0) }
+func BenchmarkRegexpMatchMedium_32(b *testing.B) { benchmark(b, medium, 32<<0) }
func BenchmarkRegexpMatchMedium_1K(b *testing.B) { benchmark(b, medium, 1<<10) }
func BenchmarkRegexpMatchHard_32(b *testing.B) { benchmark(b, hard, 32<<0) }
func BenchmarkRegexpMatchHard_1K(b *testing.B) { benchmark(b, hard, 1<<10) }
diff --git a/test/fixedbugs/issue47185.dir/bad/bad.go b/test/fixedbugs/issue47185.dir/bad/bad.go
new file mode 100644
index 0000000000..1aa4fbb909
--- /dev/null
+++ b/test/fixedbugs/issue47185.dir/bad/bad.go
@@ -0,0 +1,72 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package a
+
+// Note that the use of CGO here is solely to trigger external
+// linking, since that is required to trigger that bad behavior
+// in this bug.
+
+// #include <stdlib.h>
+import "C"
+
+func Bad() {
+ m := make(map[int64]A)
+ a := m[0]
+ if len(a.B.C1.D2.E2.F1) != 0 ||
+ len(a.B.C1.D2.E2.F2) != 0 ||
+ len(a.B.C1.D2.E2.F3) != 0 ||
+ len(a.B.C1.D2.E2.F4) != 0 ||
+ len(a.B.C1.D2.E2.F5) != 0 ||
+ len(a.B.C1.D2.E2.F6) != 0 ||
+ len(a.B.C1.D2.E2.F7) != 0 ||
+ len(a.B.C1.D2.E2.F8) != 0 ||
+ len(a.B.C1.D2.E2.F9) != 0 ||
+ len(a.B.C1.D2.E2.F10) != 0 ||
+ len(a.B.C1.D2.E2.F11) != 0 ||
+ len(a.B.C1.D2.E2.F16) != 0 {
+ panic("bad")
+ }
+ C.malloc(100)
+}
+
+type A struct {
+ B
+}
+
+type B struct {
+ C1 C
+ C2 C
+}
+
+type C struct {
+ D1 D
+ D2 D
+}
+
+type D struct {
+ E1 E
+ E2 E
+ E3 E
+ E4 E
+}
+
+type E struct {
+ F1 string
+ F2 string
+ F3 string
+ F4 string
+ F5 string
+ F6 string
+ F7 string
+ F8 string
+ F9 string
+ F10 string
+ F11 string
+ F12 string
+ F13 string
+ F14 string
+ F15 string
+ F16 string
+}
diff --git a/test/fixedbugs/issue47185.dir/main.go b/test/fixedbugs/issue47185.dir/main.go
new file mode 100644
index 0000000000..7b46e55d8b
--- /dev/null
+++ b/test/fixedbugs/issue47185.dir/main.go
@@ -0,0 +1,28 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ bad "issue47185.dir/bad"
+)
+
+func main() {
+ another()
+ bad.Bad()
+}
+
+func another() L {
+ m := make(map[string]L)
+ return m[""]
+}
+
+type L struct {
+ A Data
+ B Data
+}
+
+type Data struct {
+ F1 [22][]string
+}
diff --git a/test/fixedbugs/issue47185.go b/test/fixedbugs/issue47185.go
new file mode 100644
index 0000000000..9c921b8698
--- /dev/null
+++ b/test/fixedbugs/issue47185.go
@@ -0,0 +1,11 @@
+// +build cgo
+// runindir
+
+// Copyright 2021 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.
+
+// Another test to verify compiler and linker handling of multiple
+// competing map.zero symbol definitions.
+
+package ignored
diff --git a/test/fixedbugs/issue47201.dir/a.go b/test/fixedbugs/issue47201.dir/a.go
new file mode 100644
index 0000000000..54b7079092
--- /dev/null
+++ b/test/fixedbugs/issue47201.dir/a.go
@@ -0,0 +1,13 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ . "fmt"
+)
+
+func test() {
+ Println("foo")
+}
diff --git a/test/fixedbugs/issue47201.dir/b.go b/test/fixedbugs/issue47201.dir/b.go
new file mode 100644
index 0000000000..5fd0635af2
--- /dev/null
+++ b/test/fixedbugs/issue47201.dir/b.go
@@ -0,0 +1,9 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+func Println() {} // ERROR "Println redeclared in this block"
+
+func main() {}
diff --git a/test/fixedbugs/issue47201.go b/test/fixedbugs/issue47201.go
new file mode 100644
index 0000000000..e3a470b419
--- /dev/null
+++ b/test/fixedbugs/issue47201.go
@@ -0,0 +1,7 @@
+// errorcheckdir
+
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ignored
diff --git a/test/run.go b/test/run.go
index 3ccf1046ce..ce0d645985 100644
--- a/test/run.go
+++ b/test/run.go
@@ -2151,6 +2151,7 @@ var types2Failures = setOf(
"fixedbugs/issue4232.go", // types2 reports (correct) extra errors
"fixedbugs/issue4452.go", // types2 reports (correct) extra errors
"fixedbugs/issue4510.go", // types2 reports different (but ok) line numbers
+ "fixedbugs/issue47201.go", // types2 spells the error message differently
"fixedbugs/issue5609.go", // types2 needs a better error message
"fixedbugs/issue7525b.go", // types2 reports init cycle error on different line - ok otherwise
"fixedbugs/issue7525c.go", // types2 reports init cycle error on different line - ok otherwise