1
0
mirror of https://github.com/golang/go synced 2024-09-29 14:14:29 -06:00
Commit Graph

46272 Commits

Author SHA1 Message Date
Tobias Klauser
d06794da4a doc/go1.16: add missing <code> tag
For #40700.

Change-Id: I616429f82a44cea32701ed0af6e42ed6c71ee097
Reviewed-on: https://go-review.googlesource.com/c/go/+/277378
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-12-14 21:09:33 +00:00
Katie Hockman
dea6d94a44 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 <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-12-14 20:56:03 +00:00
Daniel S Fava
2f5b1a3974 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 <dvyukov@google.com>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
2020-12-14 20:30:16 +00:00
Robert Griesemer
91803a2df3 [dev.typeparams] merge: merge branch 'dev.regabi' into 'dev.typeparams'
The following files had merge conflicts and were merged manually:

	src/cmd/compile/fmtmap_test.go
	src/cmd/compile/internal/gc/noder.go
	src/go/parser/error_test.go
	test/assign.go
	test/chan/perm.go
	test/fixedbugs/issue22822.go
	test/fixedbugs/issue4458.go
	test/init.go
	test/interface/explicit.go
	test/map1.go
	test/method2.go

The following files had manual changes to make tests pass:

	test/run.go
	test/used.go
	src/cmd/compile/internal/types2/stdlib_test.go

Change-Id: Ia495aaaa80ce321ee4ec2a9105780fbe913dbd4c
2020-12-14 12:13:36 -08:00
Anmol Sethi
c81343ce3a 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: f809cebb13
GitHub-Pull-Request: golang/go#43086
Reviewed-on: https://go-review.googlesource.com/c/go/+/276375
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2020-12-14 19:19:09 +00:00
Ian Lance Taylor
828746ec57 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 <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-12-14 18:06:06 +00:00
Ian Lance Taylor
be10af7c4e test: match gofrontend error messages
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 <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-12-14 17:37:52 +00:00
Than McIntosh
89f38323fa [dev.regabi] cmd/compile: add register ABI analysis utilities
Introduce a new utility routine for analyzing a given function
signature to how its various input and output parameters will be
passed (in registers or on the stack) for a given ABI description,
along with some unit tests.

Change-Id: Id64a98a0a142e42dd9c2dc9f6607c0d827ef84fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/273011
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Trust: Than McIntosh <thanm@google.com>
2020-12-14 17:34:36 +00:00
Ian Lance Taylor
ce61ccca8f test: match gofrontend error messages
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 <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-14 17:26:06 +00:00
Ruixin Bao
a58be734ea 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 <khr@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2020-12-14 17:17:59 +00:00
Matthew Dempsky
8ce37e4110 [dev.regabi] cmd/compile: fix noopt builder
The non-simple, phi-insertion algorithm can leave OpFwdRefs in the SSA
graph unresolved if they're in dead blocks. Normally, these would be
harmlessly removed later during SSA dead-code elimination, but those
passes are omitted for -N builds. And so they reach zcse, where the
Value.Aux is used within a hash map.

This became a problem after golang.org/cl/275788, which added
FwdRefAux to wrap OpFwdRef's ir.Node, and to ensure that it's not
compared for equality / used as a map key.

This CL adds a simple fix: if there are any OpFwdRefs remaining after
resolveFwdRef, then they must be dead code and we can simply replace
them with OpUnknown.

Change-Id: I72e4116d52d3f6441ebb0bf6160906617cd59513
Reviewed-on: https://go-review.googlesource.com/c/go/+/277075
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2020-12-14 11:43:58 -05:00
Than McIntosh
7e17b46c58 [dev.regabi] cmd/compile/internal/types: add IsScalar query method
Add method Type.IsScalar() method, which returns TRUE
for numeric and pointer-shaped types, false for composites
such as string/array/slice/struct.

Change-Id: Ie53c71c07c5b3fbae11b48addd172343dc6bf3fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/274857
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Than McIntosh <thanm@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-14 11:43:51 -05:00
Than McIntosh
2b76429eb0 [dev.regabi] cmd/compile: refactor type initialization code into helper
Create a helper routine for initializing the types package, so as make
it easier to use in unit testing (in a follow-on patch).

Change-Id: I0f937788dfd34ac6641a4f28c16e47008aa08116
Reviewed-on: https://go-review.googlesource.com/c/go/+/273010
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Than McIntosh <thanm@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-14 11:43:39 -05:00
Matthew Dempsky
9c5241e520 [dev.regabi] cmd/compile: remove unnecessary String methods
There were only a few places these were still used, none of which
justify generating all this code. Instead rewrite them to use
fmt.Sprint or simpler means.

Passes buildall w/ toolstash -cmp.

Change-Id: Ibd123a1696941a597f0cb4dcc96cda8ced672140
Reviewed-on: https://go-review.googlesource.com/c/go/+/276072
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2020-12-14 11:43:32 -05:00
Alexander Rakoczy
267975dc47 Merge branch 'master' into dev.regabi
Change-Id: I098acdbc5e2676aeb8700d935e796a9c29d04b88
2020-12-14 11:42:42 -05:00
Jay Conrod
64d8846aae 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 <jayconrod@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-12-14 15:40:56 +00:00
Jay Conrod
451b6b38fd 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 <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-12-14 15:03:28 +00:00
Cuong Manh Le
0a02371b05 cmd/compile: set correct type for OpIData
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 <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-12-14 03:21:35 +00:00
Russ Cox
41d8e61a6b 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 <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-11 22:13:50 +00:00
Matthew Dempsky
14305527f6 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 <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2020-12-11 22:02:02 +00:00
Michael Matloob
1341a3decd 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 <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-12-11 17:26:14 +00:00
Joel Sing
e508c1c67b 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 <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-11 08:18:17 +00:00
Ian Lance Taylor
58e381b0b2 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 <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-11 06:46:11 +00:00
Robert Griesemer
a20021227e [dev.typeparams] cmd/compile/internal/types2: bring over subst.go changes from go/types
This CL make this code match closely with the go/types version
(see https://golang.org/cl/276253).

Change-Id: I2b7841309fdbda7e2c9533768bd98317729b13b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/276814
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2020-12-11 00:09:37 +00:00
Ian Lance Taylor
e012d0dc34 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 <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-10 23:24:38 +00:00
Tim King
1fe891a937 doc/go1.16: add vet release note for CL 235677
For #40700
Fixes #42895

Change-Id: I05b60f0d000512d5dddb3d61e0e695aa01943d6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/274617
Trust: Tim King <taking@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-12-10 23:11:25 +00:00
Dmitri Shuralyov
6d3d3fb37f doc/go1.16: address some remaining high-level TODOs
The tools section TODO can be removed since the tools section looks
complete by now.

All TODOs in the minor changes to the library section have been done,
so the top-level TODO is resolved. Delete it.

The currently highlighted entries under Core library section look
good. It's worth reviewing this further based on feedback from Go
1.16 pre-releases, so keep the TODO but make it non-user-visible
to unblock Go 1.16 Beta 1.

For #40700.

Change-Id: Ie72661bd457b0a93ef92e1bfc0844072f3b618a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/277212
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-10 22:58:49 +00:00
Jeremy Faller
6a64f6dc31 cmd/go: encode backslash and newline in response files
Fixes #42295

Change-Id: Ie324bc99a74c1d864c6c2da2e7b929b338c2e033
Reviewed-on: https://go-review.googlesource.com/c/go/+/272870
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-12-10 22:14:50 +00:00
Michael Anthony Knyszek
985d91666c runtime/metrics: add a note about floating-point values to package docs
This change adds a note to the package documentation that the package
will never produce a NaN or infinity, to help ease usability.

Change-Id: I72ff6ab636ca23722a68ef11e707c68b0724ac04
Reviewed-on: https://go-review.googlesource.com/c/go/+/275854
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2020-12-10 21:08:22 +00:00
Michael Anthony Knyszek
e0d20e52ee runtime/metrics: expand Read documention with caveats
This change modifies the documentation of Read with some caveats about
reusing the slice passed in to Read as well as with what concurrent
situations are safe.

Change-Id: I76fd31acc67ae384546a8442dfbf9d16b7445cff
Reviewed-on: https://go-review.googlesource.com/c/go/+/275853
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2020-12-10 21:08:17 +00:00
Michael Anthony Knyszek
d0f40d2922 runtime/metrics: add ordering line to supported metrics docs
This change adds an additional line explaining the ordering of the
supported metrics list. It's also necessary to ensure "Supported
metrics" is displayed by godoc as a proper header.

This modification does mean the description test, that ensures
descriptions line up with documentation, needs to change slightly
so it it doesn't read this new line as documentation. Make this
new line the line the test uses to decide when to begin.

Change-Id: I654c1c20e97a80ea79c8eb864445153ce91950bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/275852
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2020-12-10 21:08:10 +00:00
Ian Lance Taylor
6d2b3351f6 test: match gofrontend error messages
fixedbugs/bug13343.go:10:12: error: initialization expressions for ‘b’ and ‘c’ depend upon each other
fixedbugs/bug13343.go:11:9: note: ‘c’ defined here
fixedbugs/bug13343.go:11:9: error: initialization expression for ‘c’ depends upon itself
fixedbugs/bug13343.go:11:9: error: initialization expressions for ‘c’ and ‘b’ depend upon each other
fixedbugs/bug13343.go:10:12: note: ‘b’ defined here

fixedbugs/issue10700.dir/test.go:24:10: error: reference to method ‘Do’ in type that is pointer to interface, not interface
fixedbugs/issue10700.dir/test.go:25:10: error: reference to method ‘do’ in type that is pointer to interface, not interface
fixedbugs/issue10700.dir/test.go:27:10: error: reference to method ‘Dont’ in type that is pointer to interface, not interface
fixedbugs/issue10700.dir/test.go:28:13: error: reference to undefined field or method ‘Dont’
fixedbugs/issue10700.dir/test.go:31:10: error: reference to undefined field or method ‘do’
fixedbugs/issue10700.dir/test.go:33:13: error: reference to undefined field or method ‘do’
fixedbugs/issue10700.dir/test.go:34:10: error: reference to undefined field or method ‘Dont’
fixedbugs/issue10700.dir/test.go:35:13: error: reference to undefined field or method ‘Dont’
fixedbugs/issue10700.dir/test.go:37:10: error: reference to method ‘Do’ in type that is pointer to interface, not interface
fixedbugs/issue10700.dir/test.go:38:10: error: reference to method ‘do’ in type that is pointer to interface, not interface
fixedbugs/issue10700.dir/test.go:40:13: error: reference to undefined field or method ‘do’
fixedbugs/issue10700.dir/test.go:41:10: error: reference to method ‘Dont’ in type that is pointer to interface, not interface
fixedbugs/issue10700.dir/test.go:42:13: error: reference to undefined field or method ‘Dont’
fixedbugs/issue10700.dir/test.go:43:10: error: reference to method ‘secret’ in type that is pointer to interface, not interface
fixedbugs/issue10700.dir/test.go:44:13: error: reference to unexported field or method ‘secret’

fixedbugs/issue10975.go:13:9: error: interface contains embedded non-interface

fixedbugs/issue11326.go:26:17: error: floating-point constant overflow
fixedbugs/issue11326.go:27:17: error: floating-point constant overflow
fixedbugs/issue11326.go:28:17: error: floating-point constant overflow

fixedbugs/issue11361.go:9:11: error: import file ‘fmt’ not found
fixedbugs/issue11361.go:11:11: error: reference to undefined name ‘fmt’

fixedbugs/issue11371.go:12:15: error: floating-point constant truncated to integer
fixedbugs/issue11371.go:13:15: error: integer constant overflow
fixedbugs/issue11371.go:17:15: error: floating-point constant truncated to integer

fixedbugs/issue11590.go:9:17: error: integer constant overflow
fixedbugs/issue11590.go:9:17: error: integer constant overflow
fixedbugs/issue11590.go:10:22: error: complex real part overflow
fixedbugs/issue11590.go:10:22: error: complex real part overflow
fixedbugs/issue11590.go:11:23: error: complex real part overflow
fixedbugs/issue11590.go:11:23: error: complex real part overflow
fixedbugs/issue11590.go:9:19: error: integer constant overflow
fixedbugs/issue11590.go:10:24: error: complex real part overflow
fixedbugs/issue11590.go:11:25: error: complex real part overflow

fixedbugs/issue11610.go:11:7: error: import path is empty
fixedbugs/issue11610.go:12:4: error: invalid character 0x3f in input file
fixedbugs/issue11610.go:14:1: error: expected identifier
fixedbugs/issue11610.go:14:1: error: expected type

fixedbugs/issue11614.go:14:9: error: interface contains embedded non-interface

fixedbugs/issue13248.go:13:1: error: expected operand
fixedbugs/issue13248.go:13:1: error: missing ‘)’
fixedbugs/issue13248.go:12:5: error: reference to undefined name ‘foo’

fixedbugs/issue13266.go:10:8: error: package name must be an identifier
fixedbugs/issue13266.go:10:8: error: expected ‘;’ or newline after package clause
fixedbugs/issue13266.go:10:8: error: expected declaration

fixedbugs/issue13273.go:50:18: error: expected ‘chan’
fixedbugs/issue13273.go:53:24: error: expected ‘chan’

fixedbugs/issue13274.go:11:58: error: expected ‘}’

fixedbugs/issue13365.go:14:19: error: index expression is negative
fixedbugs/issue13365.go:15:21: error: index expression is negative
fixedbugs/issue13365.go:16:22: error: index expression is negative
fixedbugs/issue13365.go:19:13: error: some element keys in composite literal are out of range
fixedbugs/issue13365.go:22:19: error: incompatible type for element 1 in composite literal
fixedbugs/issue13365.go:23:21: error: incompatible type for element 1 in composite literal
fixedbugs/issue13365.go:24:22: error: incompatible type for element 1 in composite literal

fixedbugs/issue13415.go:14:5: error: redefinition of ‘x’
fixedbugs/issue13415.go:14:5: note: previous definition of ‘x’ was here
fixedbugs/issue13415.go:14:5: error: ‘x’ declared but not used

fixedbugs/issue13471.go:12:25: error: floating-point constant truncated to integer
fixedbugs/issue13471.go:13:25: error: floating-point constant truncated to integer
fixedbugs/issue13471.go:14:25: error: floating-point constant truncated to integer
fixedbugs/issue13471.go:15:24: error: floating-point constant truncated to integer
fixedbugs/issue13471.go:16:23: error: floating-point constant truncated to integer
fixedbugs/issue13471.go:18:26: error: floating-point constant truncated to integer
fixedbugs/issue13471.go:19:26: error: floating-point constant truncated to integer
fixedbugs/issue13471.go:20:26: error: floating-point constant truncated to integer
fixedbugs/issue13471.go:21:25: error: floating-point constant truncated to integer
fixedbugs/issue13471.go:22:24: error: floating-point constant truncated to integer
fixedbugs/issue13471.go:24:24: error: floating-point constant truncated to integer

fixedbugs/issue13821b.go:18:12: error: incompatible types in binary expression
fixedbugs/issue13821b.go:19:13: error: incompatible types in binary expression
fixedbugs/issue13821b.go:20:13: error: incompatible types in binary expression
fixedbugs/issue13821b.go:21:13: error: incompatible types in binary expression
fixedbugs/issue13821b.go:22:13: error: incompatible types in binary expression
fixedbugs/issue13821b.go:24:12: error: incompatible types in binary expression

fixedbugs/issue14006.go:24:18: error: expected ‘;’ or ‘}’ or newline
fixedbugs/issue14006.go:30:18: error: expected ‘;’ or ‘}’ or newline
fixedbugs/issue14006.go:37:22: error: expected ‘;’ or ‘}’ or newline
fixedbugs/issue14006.go:43:22: error: expected ‘;’ or ‘}’ or newline
fixedbugs/issue14006.go:59:17: note: previous definition of ‘labelname’ was here
fixedbugs/issue14006.go:64:17: error: label ‘labelname’ already defined
fixedbugs/issue14006.go:24:17: error: value computed is not used
fixedbugs/issue14006.go:30:17: error: value computed is not used
fixedbugs/issue14006.go:37:20: error: value computed is not used
fixedbugs/issue14006.go:43:20: error: value computed is not used
fixedbugs/issue14006.go:59:17: error: label ‘labelname’ defined and not used

fixedbugs/issue14010.go:13:14: error: invalid left hand side of assignment
fixedbugs/issue14010.go:14:14: error: invalid left hand side of assignment
fixedbugs/issue14010.go:14:9: error: invalid use of type

fixedbugs/issue14321.go:30:10: error: method ‘F’ is ambiguous in type ‘C’
fixedbugs/issue14321.go:31:10: error: ‘G’ is ambiguous via ‘A’ and ‘B’
fixedbugs/issue14321.go:33:10: error: type ‘C’ has no method ‘I’

fixedbugs/issue8183.go:12:14: error: integer constant overflow

fixedbugs/issue9036.go:21:12: error: invalid prefix for floating constant
fixedbugs/issue9036.go:22:12: error: invalid prefix for floating constant

fixedbugs/issue9076.go:14:5: error: incompatible type in initialization (cannot use type uintptr as type int32)
fixedbugs/issue9076.go:15:5: error: incompatible type in initialization (cannot use type uintptr as type int32)

For issue9083.go avoid an error about a variable that is set but not used.

fixedbugs/issue9370.go:105:13: error: cannot use ‘_’ as value
fixedbugs/issue9370.go:106:13: error: cannot use ‘_’ as value
fixedbugs/issue9370.go:107:13: error: cannot use ‘_’ as value
fixedbugs/issue9370.go:108:13: error: cannot use ‘_’ as value
fixedbugs/issue9370.go:109:13: error: cannot use ‘_’ as value
fixedbugs/issue9370.go:110:13: error: cannot use ‘_’ as value
fixedbugs/issue9370.go:112:18: error: cannot use ‘_’ as value
fixedbugs/issue9370.go:113:18: error: cannot use ‘_’ as value
fixedbugs/issue9370.go:114:18: error: cannot use ‘_’ as value
fixedbugs/issue9370.go:115:18: error: cannot use ‘_’ as value
fixedbugs/issue9370.go:116:18: error: cannot use ‘_’ as value
fixedbugs/issue9370.go:117:18: error: cannot use ‘_’ as value
fixedbugs/issue9370.go:119:13: error: cannot use ‘_’ as value
fixedbugs/issue9370.go:119:18: error: cannot use ‘_’ as value
fixedbugs/issue9370.go:36:15: error: invalid comparison of non-ordered type
fixedbugs/issue9370.go:39:15: error: invalid comparison of non-ordered type
fixedbugs/issue9370.go:43:15: error: invalid comparison of non-ordered type
fixedbugs/issue9370.go:46:15: error: invalid comparison of non-ordered type
fixedbugs/issue9370.go:50:15: error: invalid comparison of non-ordered type
fixedbugs/issue9370.go:53:15: error: invalid comparison of non-ordered type
fixedbugs/issue9370.go:56:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:57:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:58:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:59:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:60:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:61:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:65:15: error: invalid comparison of non-ordered type
fixedbugs/issue9370.go:68:15: error: invalid comparison of non-ordered type
fixedbugs/issue9370.go:70:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:71:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:72:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:73:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:74:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:75:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:77:15: error: invalid operation (func can only be compared to nil)
fixedbugs/issue9370.go:78:15: error: invalid operation (func can only be compared to nil)
fixedbugs/issue9370.go:79:15: error: invalid comparison of non-ordered type
fixedbugs/issue9370.go:80:15: error: invalid operation (func can only be compared to nil)
fixedbugs/issue9370.go:81:15: error: invalid operation (func can only be compared to nil)
fixedbugs/issue9370.go:82:15: error: invalid comparison of non-ordered type
fixedbugs/issue9370.go:84:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:85:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:86:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:87:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:88:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:89:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:91:15: error: invalid operation (func can only be compared to nil)
fixedbugs/issue9370.go:92:15: error: invalid operation (func can only be compared to nil)
fixedbugs/issue9370.go:93:15: error: invalid comparison of non-ordered type
fixedbugs/issue9370.go:94:15: error: invalid operation (func can only be compared to nil)
fixedbugs/issue9370.go:95:15: error: invalid operation (func can only be compared to nil)
fixedbugs/issue9370.go:96:15: error: invalid comparison of non-ordered type
fixedbugs/issue9370.go:98:15: error: invalid operation (func can only be compared to nil)
fixedbugs/issue9370.go:99:15: error: invalid operation (func can only be compared to nil)
fixedbugs/issue9370.go💯15: error: invalid comparison of non-ordered type
fixedbugs/issue9370.go:101:15: error: invalid operation (func can only be compared to nil)
fixedbugs/issue9370.go:102:15: error: invalid operation (func can only be compared to nil)
fixedbugs/issue9370.go:103:15: error: invalid comparison of non-ordered type
fixedbugs/issue9370.go:121:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:122:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:123:15: error: incompatible types in binary expression
fixedbugs/issue9370.go:124:15: error: incompatible types in binary expression

Change-Id: I4089de4919112b08f5f2bbec20f84fcc7dbe3955
Reviewed-on: https://go-review.googlesource.com/c/go/+/276832
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-12-10 18:34:40 +00:00
Dmitri Shuralyov
e5522c882d std: update golang.org/x/net to 20201209123823-ac852fbbde11
Done with:

	go get -d golang.org/x/net@latest
	go mod tidy
	go mod vendor
	go generate -run bundle std

The cmd module was updated as well, but go mod tidy undoes the change
because the x/net module doesn't contribute any packages to cmd module.
cmd/internal/moddeps.TestDependencyVersionsConsistent is happy with it:

	// It's ok if there are undetected differences in modules that do not
	// provide imported packages: we will not have to pull in any backports of
	// fixes to those modules anyway.

Fixes #31192.
Updates #42498.

Change-Id: If303c9a7aa2ce8c2553fcb1ced7fccc9e6652ad6
Reviewed-on: https://go-review.googlesource.com/c/go/+/277012
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-12-10 18:27:38 +00:00
Hein Khant Zaw
422dc83baa database/sql: fix typo in comment
Fixes #43116

Change-Id: Ib04fab6ae03f322aa1508ec00523f628d891247a
GitHub-Last-Rev: 0a86e665b2
GitHub-Pull-Request: golang/go#43122
Reviewed-on: https://go-review.googlesource.com/c/go/+/276992
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
2020-12-10 18:23:15 +00:00
Robert Griesemer
ddf44904f1 [dev.typeparams] test: exclude 32bit-specific test that fails on 32bit platforms (fix build)
Change-Id: I4f1d5d34dd9b26cea8e837a8ff7e833e02c913e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/276815
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2020-12-10 16:47:54 +00:00
Than McIntosh
56b783ad94 cmd/go, cmd/asm: pass -linkshared to assembler for shared linkage builds
When the -linkshared build mode is in effect, the Go command passes
the "-linkshared" command line option to the compiler so as to insure
special handling for things like builtin functions (which may appear
in a shared library and not the main executable). This patch extends
this behavior to the assembler, since the assembler may also wind up
referencing builtins when emitting a stack-split prolog.

Fixes #43107.

Change-Id: I56eaded79789b083f3c3d800fb140353dee33ba9
Reviewed-on: https://go-review.googlesource.com/c/go/+/276932
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-10 16:38:15 +00:00
Cherry Zhang
b110733327 cmd/link: reject too-large relocation addend on darwin/arm64
Mach-O relocation addend is signed 24-bit. If the addend
overflows, it is better to fail the build than emitting an
incorrect binary. (I'm still working on a fix.)

Updates #42738.

Change-Id: I647f0cd4f6b84d9ac75ef3bf36673bea01dfc211
Reviewed-on: https://go-review.googlesource.com/c/go/+/276694
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-12-10 15:37:33 +00:00
Cherry Zhang
0aba8f24cb cmd/link: truncate file after code signature
When external linking, in case that the external linker generates
a code signature with a different size (e.g. as it uses a
different identifier), truncate the file after rewriting the code
signature, to make sure that no bytes after the signature (which
will invalidate the signature).

Fixes #43105.

Change-Id: I732f949fedd6de42d9f3cf6d017f7ba3f4e59e7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/276693
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-12-10 15:37:19 +00:00
Keith Randall
6c64b6db68 cmd/compile: don't constant fold divide by zero
It just makes the compiler crash. Oops.

Fixes #43099

Change-Id: Id996c14799c1a5d0063ecae3b8770568161c2440
Reviewed-on: https://go-review.googlesource.com/c/go/+/276652
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-10 03:18:00 +00:00
Robert Griesemer
dbce27d29c [dev.typeparams] cmd/compile/internal/types2: report correct line number for missing key
Use the Key position of a syntax.KeyValueExpr (not the position of the
":") when reporting an error for a missing key.

(In go/types, the KeyValueExpr position is the start of the expression
not the ":", so there this works as expected.)

Change-Id: I74147d245927847274cf4e53b4f03dbb5110c324
Reviewed-on: https://go-review.googlesource.com/c/go/+/276813
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2020-12-10 00:09:51 +00:00
Robert Griesemer
edf80c4209 [dev.typeparams] cmd/compile/internal/types2: adjusted more error messages for compiler
Triaged and adjusted more test/fixedbugs/* tests.

Change-Id: I80b9ead2445bb8d126b7d79db4bea9ddcb225a84
Reviewed-on: https://go-review.googlesource.com/c/go/+/276812
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-09 23:59:57 +00:00
Robert Griesemer
43c7b214db [dev.typeparams] cmd/compile/internal/types2: adjusted qualified identifier error message for compiler
Also: Triaged/adjusted some more test/fixedbugs tests.
Change-Id: I050847b6dfccc7f301f8100bfdbe84e0487e33fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/276512
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-09 23:56:19 +00:00
Robert Griesemer
6812eae2e2 [dev.typeparams] cmd/compile/internal/types2: adjust init cycle error message for compiler
Enabled some more test/fixedbugs tests.

Change-Id: I02102b698eedfbee582b3234850fb01418ebbf7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/276453
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
2020-12-09 23:55:41 +00:00
Robert Griesemer
810957b155 [dev.typeparams] cmd/compile/internal/types2: adjusted array error message for compiler
Also: Triaged/adjusted some more test/fixedbugs tests.
Change-Id: Idaba1875273d6da6ef82dd8de8edd8daa885d32c
Reviewed-on: https://go-review.googlesource.com/c/go/+/276472
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2020-12-09 23:54:59 +00:00
Rob Findley
89f465c2b5 go/types: avoid endless recursion in the Comparable predicate
This is a port of CL 276374 from the dev.typeparams branch. Avoid an
endless recursion in Comparable by tracking types that have already been
considered.

Fixes #43088

Change-Id: I927b29ac544df9bfb5c8c04699d57fafe6cfff73
Reviewed-on: https://go-review.googlesource.com/c/go/+/276552
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-12-09 21:05:24 +00:00
Russ Cox
f1980efb92 all: update to use os.ReadDir where appropriate
os.ReadDir is a replacement for ioutil.ReadDir that returns
a slice of fs.DirEntry instead of fs.FileInfo, meaning it is the
more efficient form.

This CL updates call sites throughout the Go source tree
wherever possible. As usual, code built using the Go 1.4
bootstrap toolchain is not included. There is also a use in
go/build that appears in the public API and can't be changed,
at least not without additional changes.

Fixes #42026.

Change-Id: Icfc9dd52c6045020f6830e22c72128499462d561
Reviewed-on: https://go-review.googlesource.com/c/go/+/266366
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-09 19:12:27 +00:00
Russ Cox
4f1b0a44cb all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTemp
As part of #42026, these helpers from io/ioutil were moved to os.
(ioutil.TempFile and TempDir became os.CreateTemp and MkdirTemp.)

Update the Go tree to use the preferred names.

As usual, code compiled with the Go 1.4 bootstrap toolchain
and code vendored from other sources is excluded.

ReadDir changes are in a separate CL, because they are not a
simple search and replace.

For #42026.

Change-Id: If318df0216d57e95ea0c4093b89f65e5b0ababb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/266365
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-09 19:12:23 +00:00
Matthew Dempsky
63bc23b545 [dev.regabi] cmd/compile: first start towards using Ident
This CL adds Ident, which will eventually replace *Name and *PkgName
within the AST for representing uses of declared names. (Originally, I
intended to call it "IdentExpr", but neither go/ast nor
cmd/compile/internal/syntax include the "Expr" suffix for their
respective types.)

To start, this CL converts two uses of *Name to *Ident: the tag
identifier in a TypeSwitchGuard (which doesn't actually declare a
variable by itself), and the not-yet-known placeholder ONONAME
returned by oldname to stand-in for identifiers that might be declared
later in the package.

The TypeSwitchGuard's Name's Used flag was previously used for
detecting whether none of the per-clause variables were used. To avoid
bloating all Idents for this rare use, a "Used" bool is added to
TypeSwitchGuard instead. Eventually it could maybe be packed into
miniNode.bits, but for now this is good enough.

Passes buildall w/ toolstash -cmp.

Change-Id: I393284d86757cbbebd26e1320c7354e2bdcb30b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/276113
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2020-12-09 17:17:53 +00:00
Matthew Dempsky
eae8fd519b [dev.regabi] cmd/compile: iexport debug crumbs for toolstash
Prints offsets for declarations, inline bodies, and strings when -v is
used. Still not much, but hopefully useful for narrowing down the
cause of export data differences.

Change-Id: I9b2e4a3d55b92823fa45a39923e8c4b25303693c
Reviewed-on: https://go-review.googlesource.com/c/go/+/276112
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2020-12-09 17:17:31 +00:00
Russ Cox
837b35cc55 [dev.regabi] cmd/compile: adjust IR representations
Based on actually using the IR when prototyping adding
type assertions, a few changes to improve it:

- Merge DeferStmt and GoStmt, since they are variants of one thing.
- Introduce LogicalExpr for && and ||, since they (alone) need an init list before Y.
- Add an explicit op to various constructors to make them easier to use.
- Add separate StructKeyExpr - it stores Value in a different abstract location (Left) than KeyExpr (Right).
- Export all fields for use by rewrites (and later reflection).

Passes buildall w/ toolstash -cmp.

Change-Id: Iefbff2386d2bb9ef511ce53b7f92ff6c709dc991
Reviewed-on: https://go-review.googlesource.com/c/go/+/275883
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-09 17:05:32 +00:00