]> Cypherpunks repositories - gostls13.git/log
gostls13.git
6 years agocrypto/x509: remove redundant check for nil in tests
Marat Khabibullin [Wed, 13 Feb 2019 19:18:25 +0000 (19:18 +0000)]
crypto/x509: remove redundant check for nil in tests

Comparing err variable to be not nil is redundant in this case.
The code above ensures that it is always not nil.

Updates #30208

Change-Id: I0a41601273de36a05d22270a743c0bdedeb1d0bf
GitHub-Last-Rev: 372e0fd48f90f33e266fbcdf2ccf87b9f1311c4f
GitHub-Pull-Request: golang/go#30213
Reviewed-on: https://go-review.googlesource.com/c/162439
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/compile: confusing error if composite literal field is a method
Michael Fraenkel [Wed, 23 Jan 2019 00:10:29 +0000 (19:10 -0500)]
cmd/compile: confusing error if composite literal field is a method

When looking for the field specified in a composite literal, check that
the specified name is actually a field and not a method.

Fixes #29855.

Change-Id: Id77666e846f925907b1eec64213b1d25af8a2466
Reviewed-on: https://go-review.googlesource.com/c/158938
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agonet/textproto: prevent test from failing with nil pointer dereference
Marat Khabibullin [Wed, 13 Feb 2019 19:19:33 +0000 (19:19 +0000)]
net/textproto: prevent test from failing with nil pointer dereference

The variable err could have nil value when we call err.Error(),
because after we check it for nil above we continue the test
(t.Errorf doesn't stop the test execution).

Updates #30208

Change-Id: Ibcf38698326c69c06068989510311e37806995c6
GitHub-Last-Rev: 3ab20f6d7fe34ed9b777e0894b57166d173de8ca
GitHub-Pull-Request: golang/go#30214
Reviewed-on: https://go-review.googlesource.com/c/162457
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocrypto/tls: remove superfluous for label
Filippo Valsorda [Tue, 22 Jan 2019 21:21:32 +0000 (16:21 -0500)]
crypto/tls: remove superfluous for label

Change-Id: I8ea3043fcbaf7a5f73b2a796171a7f1cb3cb3693
Reviewed-on: https://go-review.googlesource.com/c/158818
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: cull dead code
Josh Bleecher Snyder [Sat, 10 Nov 2018 14:58:36 +0000 (06:58 -0800)]
cmd/compile: cull dead code

The special case for ODOTPTR to handle zero-width fields is unneeded.
It is an artifact of the old backend, from which time this code dates.
The Node to SSA converter is careful to insert a nil check.
This is tested in test/nilptr2.go, among other places.

Passes toolstash-check.

Change-Id: I6c1d99f7ff5abdae9aa08ee047dc088a3fe8dc3c
Reviewed-on: https://go-review.googlesource.com/c/148828
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
6 years agocmd/dist: skip Fortran tests on Android
Elias Naur [Tue, 26 Feb 2019 18:01:47 +0000 (19:01 +0100)]
cmd/dist: skip Fortran tests on Android

They don't work on Android but will be run if the host has gfortran
installed.

Change-Id: I983c5695a9e963def90e4f8264fb00077a0c5e53
Reviewed-on: https://go-review.googlesource.com/c/163838
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoencoding/json: add example for json.HTMLEscape
Ketan Parmar [Thu, 31 Jan 2019 01:58:15 +0000 (07:28 +0530)]
encoding/json: add example for json.HTMLEscape

Change-Id: Ib00fcfd46eae27eea0a3d4cab4406f4c461fb57b
Reviewed-on: https://go-review.googlesource.com/c/160517
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agotext/template: error on method calls on nil interfaces
Daniel Martí [Sat, 9 Feb 2019 17:50:02 +0000 (17:50 +0000)]
text/template: error on method calls on nil interfaces

Trying to call a method on a nil interface is a panic in Go. For
example:

var stringer fmt.Stringer
println(stringer.String()) // nil pointer dereference

In https://golang.org/cl/143097 we started recovering panics encountered
during function and method calls. However, we didn't handle this case,
as text/template panics before evalCall is ever run.

In particular, reflect's MethodByName will panic if the receiver is of
interface kind and nil:

panic: reflect: Method on nil interface value

Simply add a check for that edge case, and have Template.Execute return
a helpful error. Note that Execute shouldn't just error if the interface
contains a typed nil, since we're able to find a method to call in that
case.

Finally, add regression tests for both the nil and typed nil interface
cases.

Fixes #30143.

Change-Id: Iffb21b40e14ba5fea0fcdd179cd80d1f23cabbab
Reviewed-on: https://go-review.googlesource.com/c/161761
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
6 years agocmd/compile: remove unused func eqtypenoname
Daniel Martí [Tue, 22 Jan 2019 21:27:43 +0000 (21:27 +0000)]
cmd/compile: remove unused func eqtypenoname

Its only use was removed in golang.org/cl/114797, committed in October
2018.

Change-Id: I6560ccfb10d7c763f6470b20c853716779c18cee
Reviewed-on: https://go-review.googlesource.com/c/158897
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
6 years agomisc/android: copy testdata directories to device before running
Elias Naur [Mon, 25 Feb 2019 10:18:03 +0000 (11:18 +0100)]
misc/android: copy testdata directories to device before running

We've got away with not copying the testdata directories for the
standard library because the exec wrapper also pushes almost the
entire $GOROOT tree to the device, including testdata directories.

Similar to what the iOS exec wrapper does.

Change-Id: I91ef63ef84a658fc8843002890132c64b7c1d20e
Reviewed-on: https://go-review.googlesource.com/c/163626
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agomisc/android: serialize adb commands on android emulators
Elias Naur [Mon, 25 Feb 2019 09:52:42 +0000 (10:52 +0100)]
misc/android: serialize adb commands on android emulators

Android emulator builders are soon to join the trybot set. To avoid
flaky runs, work around a longstanding adb bug where concurrent adb
commands sometimes fail.

I haven't seen the problem on actual devices until recently. It seems
that the recently added "adb wait-for-device" can introduce flakyness
with errors such as:

adb: error: failed to get feature set: protocol fault (couldn't read status): Connection reset by peer

Instead of working around that, give up and serialize use of adb
everywhere.

Fixes #23795
Updates #23824

Change-Id: If347c9981fa32ff8a1e14b7454f122ef682450a6
Reviewed-on: https://go-review.googlesource.com/c/163625
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agomisc/android,cmd/dist: move $GOROOT copying to the exec wrapper
Elias Naur [Sun, 24 Feb 2019 14:18:02 +0000 (15:18 +0100)]
misc/android,cmd/dist: move $GOROOT copying to the exec wrapper

To run the standard library tests on Android, the androidtest.bash
script copies GOROOT to the device. Move that logic to the android
exec wrapper, thereby making androidtest.bash obsolete.

Apart from making Android less special, the sharded builder
infrastructure should now be able to run (emulated) Android builders
and trybots without special treatment.

Updates #23824

Change-Id: I41591fea9a15b38c6dcf84046ea57f1e9165eaa5
Reviewed-on: https://go-review.googlesource.com/c/163619
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/vendor/golang.org/x/sys: re-vendor
Elias Naur [Mon, 25 Feb 2019 08:30:01 +0000 (09:30 +0100)]
cmd/vendor/golang.org/x/sys: re-vendor

Fixes #29423

Change-Id: I376d0776c3810c2273d1ea234ebe681d5fd2ae64
Reviewed-on: https://go-review.googlesource.com/c/163623
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
6 years agocmd/dist: build exec wrappers during bootstrap
Elias Naur [Sun, 24 Feb 2019 12:18:13 +0000 (13:18 +0100)]
cmd/dist: build exec wrappers during bootstrap

The androidtest.bash script encodes the additional steps to build
Go and run tests on Android. In order to add sharded builders and
trybots, Android needs to fit into the usual make.bash + cmd/dist test
pattern.

This change moves building the exec wrapper into cmd/dist bootstrap.

Do the same for iOS while we're here.

Updates #23824

Change-Id: I58a1b0679c3a6c92fdc7fff464b469641f1fee74
Reviewed-on: https://go-review.googlesource.com/c/163618
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agomath/bits: optimize Reverse32 and Reverse64
Michael Munday [Thu, 24 Jan 2019 17:27:23 +0000 (17:27 +0000)]
math/bits: optimize Reverse32 and Reverse64

Use ReverseBytes32 and ReverseBytes64 to speed up these functions.
The byte reversal functions are intrinsics on most platforms and
generally compile to a single instruction.

name       old time/op  new time/op  delta
Reverse32  2.41ns ± 1%  1.94ns ± 3%  -19.60%  (p=0.000 n=20+19)
Reverse64  3.85ns ± 1%  2.56ns ± 1%  -33.32%  (p=0.000 n=17+19)

Change-Id: I160bf59a0c7bd5db94114803ec5a59fae448f096
Reviewed-on: https://go-review.googlesource.com/c/159358
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agonet/rpc: fix args order in strings.Contains call
Iskander Sharipov [Tue, 5 Feb 2019 10:29:29 +0000 (13:29 +0300)]
net/rpc: fix args order in strings.Contains call

The old code looks suspicious and is fragile.
It would fail if error messages were not totally the same.
Swapped the arguments order to fix that.

Change-Id: Id5df7242fb9224d0090245286ef8986ebb15e921
Reviewed-on: https://go-review.googlesource.com/c/161157
Run-TryBot: Iskander Sharipov <quasilyte@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
6 years agotext/template: improve nil errors in evalField
Daniel Martí [Sun, 9 Dec 2018 17:35:21 +0000 (17:35 +0000)]
text/template: improve nil errors in evalField

If we're accessing a field on a nil struct pointer, and that field is
present in the type, we should print a "nil pointer evaluating X.Y" error
instead of the broader "can't evaluate field Y in X". The latter error
should still be used for the cases where the field is simply missing.

While at it, remove the isNil checks in the struct and map cases. The
indirect func will only return a true isNil when returning a pointer or
interface reflect.Value, so it's impossible for either of these checks
to be useful.

Finally, extend the test suite to test a handful of these edge cases,
including the one shown in the original issue.

Fixes #29137.

Change-Id: I53408ced8a7b53807a0a8461b6baef1cd01d25ae
Reviewed-on: https://go-review.googlesource.com/c/153341
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agocmd/compile: don't crash on -d=ssa/
Daniel Martí [Sun, 16 Dec 2018 17:44:31 +0000 (18:44 +0100)]
cmd/compile: don't crash on -d=ssa/

I forgot how to pull up the ssa debug options help, so instead of
writing -d=ssa/help, I just wrote -d=ssa/. Much to my amusement, the
compiler just crashed, as shown below. Fix that.

panic: runtime error: index out of range

goroutine 1 [running]:
cmd/compile/internal/ssa.PhaseOption(0x7ffc375d2b70, 0x0, 0xdbff91, 0x5, 0x1, 0x0, 0x0, 0x1, 0x1)
    /home/mvdan/tip/src/cmd/compile/internal/ssa/compile.go:327 +0x1876
cmd/compile/internal/gc.Main(0xde7bd8)
    /home/mvdan/tip/src/cmd/compile/internal/gc/main.go:411 +0x41d0
main.main()
    /home/mvdan/tip/src/cmd/compile/main.go:51 +0xab

Change-Id: Ia2ad394382ddf8f4498b16b5cfb49be0317fc1aa
Reviewed-on: https://go-review.googlesource.com/c/154421
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agodoc: add 1.12 to the project history
Alberto Donizetti [Tue, 26 Feb 2019 17:18:44 +0000 (18:18 +0100)]
doc: add 1.12 to the project history

Go 1.12 is released, but it's currently not listed in the
https://golang.org/project page.

Change-Id: Ib5820f74245e4c986014c64eb40fa2911473e64b
Reviewed-on: https://go-review.googlesource.com/c/163837
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agotime: parse 1us in Nanoseconds example
Alberto Donizetti [Sun, 24 Feb 2019 21:48:46 +0000 (22:48 +0100)]
time: parse 1us in Nanoseconds example

The example for Nanoseconds() currently reads:

  ns, _ := time.ParseDuration("1000ns")
  fmt.Printf("one microsecond has %d nanoseconds.", ns.Nanoseconds())

which is not terribly interesting: it seems obvious that parsing
"1000ns" and then calling Nanoseconds() will print 1000. The mention
of microseconds in the text suggests that the author's intention was,
instead, to write something like this:

  u, _ := time.ParseDuration("1us")

i.e. build a time value by parsing 1 microsecond, and then print the
value in nanoseconds. Change the example to do this.

Change-Id: I4ddb123f0935a12cda3b5d6f1ca919bfcd6383d6
Reviewed-on: https://go-review.googlesource.com/c/163622
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agomisc/cgo: skip cgotest.TestCrossPackageTests on iOS and set PWD
Bryan C. Mills [Tue, 26 Feb 2019 03:09:46 +0000 (22:09 -0500)]
misc/cgo: skip cgotest.TestCrossPackageTests on iOS and set PWD

I hope that this will fix the tests on iOS, but 'gomote create' isn't
giving me an instance I can test with. (Please patch and test before
approving.)

Updates #15919
Updates #30228

Change-Id: I1b7cd30d5b127a1ad3243b329fa005d229f69a24
Reviewed-on: https://go-review.googlesource.com/c/163726
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Elias Naur <mail@eliasnaur.com>
6 years agotext/template: accept new number syntax
Russ Cox [Wed, 30 Jan 2019 04:21:29 +0000 (23:21 -0500)]
text/template: accept new number syntax

This CL updates text/template's scanner to accept the
new number syntaxes:

 - Hexadecimal floating-point values.
 - Digit-separating underscores.
 - Leading 0b and 0o prefixes.

See golang.org/design/19308-number-literals for background.

For #12711.
For #19308.
For #28493.
For #29008.

Change-Id: I68c16ea35c3f506701063781388de72bafee6b8d
Reviewed-on: https://go-review.googlesource.com/c/160248
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agofmt: scan new number syntax
Russ Cox [Wed, 30 Jan 2019 04:06:06 +0000 (23:06 -0500)]
fmt: scan new number syntax

This CL updates fmt's scanner to accept the new number syntaxes:

 - Hexadecimal floating-point values.
 - Digit-separating underscores.
 - Leading 0b and 0o prefixes.

See golang.org/design/19308-number-literals for background.

For #12711.
For #19308.
For #28493.
For #29008.

Change-Id: I5582af5c94059c781e6cf4e862441d3df3006adf
Reviewed-on: https://go-review.googlesource.com/c/160247
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agofmt: format 0b, 0o prefixes in %#b and %O
Russ Cox [Wed, 30 Jan 2019 03:24:36 +0000 (22:24 -0500)]
fmt: format 0b, 0o prefixes in %#b and %O

This CL modifies fmt's printer to implement %#b and %O
to emit leading 0b and 0o prefixes on binary and octal.
(%#o is already taken and emits "0377"; %O emits "0o377".)

See golang.org/design/19308-number-literals for background.

For #19308.
For #12711.
Vet update is #29986.

Change-Id: I7c38a4484c48a03abe9f6d45c7d981c7c314f583
Reviewed-on: https://go-review.googlesource.com/c/160246
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agofmt: format hex floats and complexes
Russ Cox [Wed, 30 Jan 2019 03:13:54 +0000 (22:13 -0500)]
fmt: format hex floats and complexes

This CL modifies fmt's printer to implement %x and %X
for formatting floating-point data (floats and complexes)
in standard hexadecimal notation.

See golang.org/design/19308-number-literals for background.

For #29008.
Vet update is #29986.

Change-Id: If2842a11631bc393a1ebcf6914ed07658652af5a
Reviewed-on: https://go-review.googlesource.com/c/160245
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agocmd/go: allow "stdout" and "stderr" as inputs to script_test "cp" command
Bryan C. Mills [Wed, 20 Feb 2019 23:11:11 +0000 (18:11 -0500)]
cmd/go: allow "stdout" and "stderr" as inputs to script_test "cp" command

Updates #30241

Change-Id: I543d8914faf810835d3327baa3c84b3dff124156
Reviewed-on: https://go-review.googlesource.com/c/163519
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agotest: add a go.mod file in the working directory of nosplit.go
Bryan C. Mills [Fri, 22 Feb 2019 20:58:15 +0000 (15:58 -0500)]
test: add a go.mod file in the working directory of nosplit.go

Updates #30228

Change-Id: I41bbedf15fa51242f69a3b1ecafd0d3191271799
Reviewed-on: https://go-review.googlesource.com/c/163518
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agomisc/cgo/testgodefs: move source files into testdata
Bryan C. Mills [Thu, 21 Feb 2019 20:11:16 +0000 (15:11 -0500)]
misc/cgo/testgodefs: move source files into testdata

These source files fail to build with 'go test ./...'.
Move them into testdata so that only test.bash will see them.

Updates #30228

Change-Id: I3673f3cb64b0c128a2bca5fee7679b672fe90770
Reviewed-on: https://go-review.googlesource.com/c/163212
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agomisc/cgo/testso{,var}: fix tests in module mode
Bryan C. Mills [Fri, 22 Feb 2019 15:50:47 +0000 (10:50 -0500)]
misc/cgo/testso{,var}: fix tests in module mode

Add _test.go files in the individal directories to invoke 'go build'
with appropriate arguments.

Move the test driver out of cmd/dist so that it's easier to invoke the
test separately (using 'go test .').

Updates #30228
Updates #28387

Change-Id: Ibc4a024a52c12a274058298b41cc90709f7f56c8
Reviewed-on: https://go-review.googlesource.com/c/163420
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc: document Go 1.12
Andrew [Mon, 25 Feb 2019 21:33:12 +0000 (21:33 +0000)]
doc: document Go 1.12

Change-Id: I845375d2b3824211b80885228ba5b45503cba1a6
Reviewed-on: https://go-review.googlesource.com/c/163722
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc/go1.12: remove draft notice
Andrew [Mon, 25 Feb 2019 20:02:00 +0000 (20:02 +0000)]
doc/go1.12: remove draft notice

Change-Id: Ib6a0f5c35b1efc3f3c8e7ca2a5c4f35bf8bf5e5d
Reviewed-on: https://go-review.googlesource.com/c/163720
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc/go1.12: change go install to go get
Andrew [Mon, 25 Feb 2019 19:13:57 +0000 (19:13 +0000)]
doc/go1.12: change go install to go get

Using go get prevents the failure case of when the
user doesn't have the repo on their machine.

Change-Id: I9c1174087728b5b06b578b0d52df6eeb7e8c7a3c
Reviewed-on: https://go-review.googlesource.com/c/163718
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: call ginsnop, not ginsnop2 on ppc64le for mid-stack inlining tracebacks
Lynn Boger [Thu, 21 Feb 2019 19:48:52 +0000 (14:48 -0500)]
cmd/compile: call ginsnop, not ginsnop2 on ppc64le for mid-stack inlining tracebacks

A recent change to fix stacktraces for inlined functions
introduced a regression on ppc64le when compiling position
independent code. That happened because ginsnop2 was called for
the purpose of inserting a NOP to identify the location of
the inlined function, when ginsnop should have been used.
ginsnop2 is intended to be used before deferreturn to ensure
r2 is properly restored when compiling position independent code.
In some cases the location where r2 is loaded from might not be
initialized. If that happens and r2 is used to generate an address,
the result is likely a SEGV.

This fixes that problem.

Fixes #30283

Change-Id: If70ef27fc65ef31969712422306ac3a57adbd5b6
Reviewed-on: https://go-review.googlesource.com/c/163337
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agomisc: wait for device readyness in the exec wrapper
Elias Naur [Sun, 24 Feb 2019 15:46:23 +0000 (16:46 +0100)]
misc: wait for device readyness in the exec wrapper

Updates #23824

Change-Id: I5472a05eb2cf571ccc84c76c6f592bf4dd2e3cb4
Reviewed-on: https://go-review.googlesource.com/c/163621
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoRevert "androidtest.bash: wait for device to be ready before using it"
Elias Naur [Sun, 24 Feb 2019 15:51:48 +0000 (15:51 +0000)]
Revert "androidtest.bash: wait for device to be ready before using it"

This reverts commit 27b9571de800c05a41081ea80cd934e48e0a8f70.

Reason for revert: broke the multi-device Android builder. And the wait logic is moving to the exec wrapper anyway.

Change-Id: I3e429106bbe70b3a12286f8f229a2b558279eec4
Reviewed-on: https://go-review.googlesource.com/c/163620
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agomisc/cgo/life: fix tests in module mode
Bryan C. Mills [Fri, 22 Feb 2019 17:22:10 +0000 (12:22 -0500)]
misc/cgo/life: fix tests in module mode

Updates #30228

Change-Id: Ie972694254d2195ca9760ea7ffb6073e01c52488
Reviewed-on: https://go-review.googlesource.com/c/163422
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agomisc/cgo/stdio: fix tests in module mode
Bryan C. Mills [Fri, 22 Feb 2019 17:14:23 +0000 (12:14 -0500)]
misc/cgo/stdio: fix tests in module mode

Updates #30228

Change-Id: I4d213c6fe68c47ccb877f13b55128e035f76a26b
Reviewed-on: https://go-review.googlesource.com/c/163421
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agomisc/cgo/testplugin: convert test.bash to Go and fix in module mode
Bryan C. Mills [Thu, 21 Feb 2019 22:38:53 +0000 (17:38 -0500)]
misc/cgo/testplugin: convert test.bash to Go and fix in module mode

Updates #30228
Updates #28387

Change-Id: Iad7d960b70221f90ccc2372bb1d4d41cec3926e4
Reviewed-on: https://go-review.googlesource.com/c/163214
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agomisc/cgo/test: fix tests in module mode
Bryan C. Mills [Fri, 22 Feb 2019 15:17:22 +0000 (10:17 -0500)]
misc/cgo/test: fix tests in module mode

This change preserves the ability to test misc/cgo/test in GOPATH
mode, at the cost of indirection through a 'go test' subprocess.

Updates #30228

Change-Id: I08de855e62278d30fa622b2f7478e43dd2ab0e96
Reviewed-on: https://go-review.googlesource.com/c/163418
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go/internal/imports: use the full path to resolve symlinks
Bryan C. Mills [Thu, 21 Feb 2019 17:00:12 +0000 (12:00 -0500)]
cmd/go/internal/imports: use the full path to resolve symlinks

info.Name returns a name relative to the directory, so we need to
prefix that directory in the Stat call.

(This was missed in CL 141097 due to the fact that the test only
happened to check symlinks in the current directory.)

This allows the misc/ tests to work in module mode on platforms that
support symlinks.

Updates #30228
Updates #28107

Change-Id: Ie31836382df0cbd7d203b7a8b637c4743d68b6f3
Reviewed-on: https://go-review.googlesource.com/c/163517
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agomisc/cgo/testsanitizers: move test source files into testdata directory
Bryan C. Mills [Fri, 22 Feb 2019 13:36:41 +0000 (08:36 -0500)]
misc/cgo/testsanitizers: move test source files into testdata directory

If we run 'go test ./...' in the misc module, we don't want to see
errors for these standalone files.

We could instead add +ignore tags to each file individually, but this
is exactly what a testdata directory is for.

Updates #30228

Change-Id: I7047ad888dd6aff701f5982d58b6a79f6a487c58
Reviewed-on: https://go-review.googlesource.com/c/163417
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agomisc/cgo/testcshared: fix tests in module mode
Bryan C. Mills [Thu, 21 Feb 2019 21:18:28 +0000 (16:18 -0500)]
misc/cgo/testcshared: fix tests in module mode

Updates #30228

Change-Id: Ie9dca7c64be8dff729be98cb6190236287afd23e
Reviewed-on: https://go-review.googlesource.com/c/163213
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agomisc/cgo/testshared: fix tests in module mode
Bryan C. Mills [Thu, 21 Feb 2019 19:17:19 +0000 (14:17 -0500)]
misc/cgo/testshared: fix tests in module mode

Updates #30228

Change-Id: I5cc739eb9fdfb648ec45e350d43d4cb02e450553
Reviewed-on: https://go-review.googlesource.com/c/163211
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agomisc/cgo/testcarchive: fix tests in module mode
Bryan C. Mills [Thu, 21 Feb 2019 17:34:27 +0000 (12:34 -0500)]
misc/cgo/testcarchive: fix tests in module mode

Updates #30228

Change-Id: I830e3c83416b2e5744f30d1a903a74c50462716b
Reviewed-on: https://go-review.googlesource.com/c/163210
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agoandroidtest.bash: wait for device to be ready before using it
Elias Naur [Fri, 22 Feb 2019 17:35:58 +0000 (18:35 +0100)]
androidtest.bash: wait for device to be ready before using it

Updates #23824

Change-Id: I265e3f40192a0a4bf54f608d9408ba0cfef2b69c
Reviewed-on: https://go-review.googlesource.com/c/163457
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agomisc/cgo/errors: fix tests in module mode
Bryan C. Mills [Thu, 21 Feb 2019 14:06:09 +0000 (09:06 -0500)]
misc/cgo/errors: fix tests in module mode

Updates #30228

Change-Id: I84bc705591bdb3da0106404b24353251939355b8
Reviewed-on: https://go-review.googlesource.com/c/163209
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agocrypto/rc4: remove false guarantees from Reset docs and deprecate it
Filippo Valsorda [Wed, 13 Feb 2019 08:37:57 +0000 (03:37 -0500)]
crypto/rc4: remove false guarantees from Reset docs and deprecate it

Nothing in Go can truly guarantee a key will be gone from memory (see
#21865), so remove that claim. That makes Reset useless, because
unlike most Reset methods it doesn't restore the original value state,
so deprecate it.

Change-Id: I6bb0f7f94c7e6dd4c5ac19761bc8e5df1f9ec618
Reviewed-on: https://go-review.googlesource.com/c/162297
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agomisc/android: add build constraints on files intended to be built by filename only
Bryan C. Mills [Thu, 21 Feb 2019 14:20:42 +0000 (09:20 -0500)]
misc/android: add build constraints on files intended to be built by filename only

Updates #30228

Change-Id: I91a763d94de935d9102d927b5cefee564bbf049b
Reviewed-on: https://go-review.googlesource.com/c/163208
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/internal/obj/arm64: fix the bug assembling TSTW
fanzha02 [Thu, 21 Feb 2019 07:53:15 +0000 (07:53 +0000)]
cmd/internal/obj/arm64: fix the bug assembling TSTW

Current assembler reports error when it assembles
"TSTW $1689262177517664, R3", but go1.11 was building
fine.

Fixes #30334

Change-Id: I9c16d36717cd05df2134e8eb5b17edc385aff0a9
Reviewed-on: https://go-review.googlesource.com/c/163259
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ben Shi <powerman1st@163.com>
6 years agocmd/compile: flow interface data to heap if CONVIFACE of a non-direct interface escapes
Cherry Zhang [Mon, 18 Feb 2019 04:12:55 +0000 (23:12 -0500)]
cmd/compile: flow interface data to heap if CONVIFACE of a non-direct interface escapes

Consider the following code:

func f(x []*T) interface{} {
return x
}

It returns an interface that holds a heap copy of x (by calling
convT2I or friend), therefore x escape to heap. The current
escape analysis only recognizes that x flows to the result. This
is not sufficient, since if the result does not escape, x's
content may be stack allocated and this will result a
heap-to-stack pointer, which is bad.

Fix this by realizing that if a CONVIFACE escapes and we're
converting from a non-direct interface type, the data needs to
escape to heap.

Running "toolstash -cmp" on std & cmd, the generated machine code
are identical for all packages. However, the export data (escape
tags) differ in the following packages. It looks to me that all
are similar to the "f" above, where the parameter should escape
to heap.

io/ioutil/ioutil.go:118
old: leaking param: r to result ~r1 level=0
new: leaking param: r

image/image.go:943
old: leaking param: p to result ~r0 level=1
new: leaking param content: p

net/url/url.go:200
old: leaking param: s to result ~r2 level=0
new: leaking param: s

(as a consequence)
net/url/url.go:183
old: leaking param: s to result ~r1 level=0
new: leaking param: s

net/url/url.go:194
old: leaking param: s to result ~r1 level=0
new: leaking param: s

net/url/url.go:699
old: leaking param: u to result ~r0 level=1
new: leaking param: u

net/url/url.go:775
old: (*URL).String u does not escape
new: leaking param content: u

net/url/url.go:1038
old: leaking param: u to result ~r0 level=1
new: leaking param: u

net/url/url.go:1099
old: (*URL).MarshalBinary u does not escape
new: leaking param content: u

flag/flag.go:235
old: leaking param: s to result ~r0 level=1
new: leaking param content: s

go/scanner/errors.go:105
old: leaking param: p to result ~r0 level=0
new: leaking param: p

database/sql/sql.go:204
old: leaking param: ns to result ~r0 level=0
new: leaking param: ns

go/constant/value.go:303
old: leaking param: re to result ~r2 level=0, leaking param: im to result ~r2 level=0
new: leaking param: re, leaking param: im

go/constant/value.go:846
old: leaking param: x to result ~r1 level=0
new: leaking param: x

encoding/xml/xml.go:518
old: leaking param: d to result ~r1 level=2
new: leaking param content: d

encoding/xml/xml.go:122
old: leaking param: leaking param: t to result ~r1 level=0
new: leaking param: t

crypto/x509/verify.go:506
old: leaking param: c to result ~r8 level=0
new: leaking param: c

crypto/x509/verify.go:563
old: leaking param: c to result ~r3 level=0, leaking param content: c
new: leaking param: c

crypto/x509/verify.go:615
old: (nothing)
new: leaking closure reference c

crypto/x509/verify.go:996
old: leaking param: c to result ~r1 level=0, leaking param content: c
new: leaking param: c

net/http/filetransport.go:30
old: leaking param: fs to result ~r1 level=0
new: leaking param: fs

net/http/h2_bundle.go:2684
old: leaking param: mh to result ~r0 level=2
new: leaking param content: mh

net/http/h2_bundle.go:7352
old: http2checkConnHeaders req does not escape
new: leaking param content: req

net/http/pprof/pprof.go:221
old: leaking param: name to result ~r1 level=0
new: leaking param: name

cmd/internal/bio/must.go:21
old: leaking param: w to result ~r1 level=0
new: leaking param: w

Fixes #29353.

Change-Id: I7e7798ae773728028b0dcae5bccb3ada51189c68
Reviewed-on: https://go-review.googlesource.com/c/162829
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
6 years agogo/build: add go1.13 release tag
Herbie Ong [Wed, 20 Feb 2019 19:30:14 +0000 (11:30 -0800)]
go/build: add go1.13 release tag

Adding this early in the cycle to start regression testing in the master
toolchain.

Change-Id: Ia151429c4f94efbac0aa41ab6bc16e7462b0e303
Reviewed-on: https://go-review.googlesource.com/c/163082
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agotext/scanner: don't liberally consume (invalid) floats or underbars
Robert Griesemer [Wed, 20 Feb 2019 18:44:52 +0000 (10:44 -0800)]
text/scanner: don't liberally consume (invalid) floats or underbars

This is a follow-up on https://golang.org/cl/161199 which introduced
the new Go 2 number literals to text/scanner.

That change introduced a bug by allowing decimal and hexadecimal floats
to be consumed even if the scanner was not configured to accept floats.

This CL changes the code to not consume a radix dot '.' or exponent
unless the scanner is configured to accept floats.

This CL also introduces a new mode "AllowNumberbars" which controls
whether underbars '_' are permitted as digit separators in numbers
or not.

There is a possibility that we may need to refine text/scanner
further (e.g., the Float mode now includes hexadecimal floats
which it didn't recognize before). We're very early in the cycle,
so let's see how it goes.

RELNOTE=yes

Updates #12711.
Updates #19308.
Updates #28493.
Updates #29008.

Fixes #30320.

Change-Id: I6481d314f0384e09ef6803ffad38dc529b1e89a3
Reviewed-on: https://go-review.googlesource.com/c/163079
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agopath/filepath: revert "fix Windows-specific Clean bug"
Ian Lance Taylor [Wed, 20 Feb 2019 02:12:13 +0000 (18:12 -0800)]
path/filepath: revert "fix Windows-specific Clean bug"

Revert CL 137055, which changed Clean("\\somepath\dir\") to return
"\\somepath\dir" on Windows. It's not entirely clear this is correct,
as this path is really "\\server\share\", and as such the trailing
slash may be the path on that share, much like "C:\". In any case, the
change broke existing code, so roll it back for now and rethink for 1.13.

Updates #27791
Fixes #30307

Change-Id: I69200b1efe38bdb6d452b744582a2bfbb3acbcec
Reviewed-on: https://go-review.googlesource.com/c/163077
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
6 years agocmd/vet: make vet_test module-agnostic
Bryan C. Mills [Tue, 19 Feb 2019 19:53:26 +0000 (14:53 -0500)]
cmd/vet: make vet_test module-agnostic

vet_test currently uses a custom GOPATH for each test, but it turns
out not to be necessary.

Updates #30228

Change-Id: Id7a7bf6d759bd94adccf44e197be1728c2f23575
Reviewed-on: https://go-review.googlesource.com/c/163038
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
6 years agocmd/link/internal/ld: make dwarf_test and associated testdata module-agnostic
Bryan C. Mills [Tue, 19 Feb 2019 18:48:15 +0000 (13:48 -0500)]
cmd/link/internal/ld: make dwarf_test and associated testdata module-agnostic

Updates #30228

Change-Id: I31aac4cb113c0c88a54329181ad27aee3d8acc71
Reviewed-on: https://go-review.googlesource.com/c/162835
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
6 years agocmd/cover: fix TestHtmlUnformatted in module mode
Bryan C. Mills [Fri, 15 Feb 2019 22:58:21 +0000 (17:58 -0500)]
cmd/cover: fix TestHtmlUnformatted in module mode

Updates #30228

Change-Id: Id9dffa6c805ac630945bac8febe342ce633626c6
Reviewed-on: https://go-review.googlesource.com/c/162830
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agocmd/link: fix TestUnresolved in module mode
Bryan C. Mills [Fri, 15 Feb 2019 23:12:28 +0000 (18:12 -0500)]
cmd/link: fix TestUnresolved in module mode

Updates #30228

Change-Id: I9f0e7e59922bd56b17889f72124b7d14b2433218
Reviewed-on: https://go-review.googlesource.com/c/162833
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agocmd/internal/goobj: make the buildGoobj test helper work in module mode
Bryan C. Mills [Fri, 15 Feb 2019 23:04:32 +0000 (18:04 -0500)]
cmd/internal/goobj: make the buildGoobj test helper work in module mode

Updates #30228

Change-Id: I8dd4a1f94dfd3be324a4f213941a20fa1b8b1215
Reviewed-on: https://go-review.googlesource.com/c/162832
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agocmd/compile: accept 'i' suffix orthogonally on all numbers
Robert Griesemer [Fri, 15 Feb 2019 01:34:29 +0000 (17:34 -0800)]
cmd/compile: accept 'i' suffix orthogonally on all numbers

This change accepts the 'i' suffix on binary and octal integer
literals as well as hexadecimal floats. The suffix was already
accepted on decimal integers and floats.

Note that 0123i == 123i for backward-compatibility (and 09i is
valid).

See also the respective language in the spec change:
https://golang.org/cl/161098

Change-Id: I9d2d755cba36a3fa7b9e24308c73754d4568daaf
Reviewed-on: https://go-review.googlesource.com/c/162878
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agogo/scanner: accept 'i' suffix orthogonally on all numbers
Robert Griesemer [Fri, 15 Feb 2019 01:53:14 +0000 (17:53 -0800)]
go/scanner: accept 'i' suffix orthogonally on all numbers

This change accepts the 'i' suffix on binary and octal integer
literals as well as hexadecimal floats. The suffix was already
accepted on decimal integers and floats.

See also the respective language in the spec change:
https://golang.org/cl/161098

Change-Id: I0c182bdf58f8fd1f70090e581b3ccb2f5e2e4e79
Reviewed-on: https://go-review.googlesource.com/c/162880
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: don't mix internal float/complex constants of different precision
Robert Griesemer [Sun, 17 Feb 2019 23:35:52 +0000 (15:35 -0800)]
cmd/compile: don't mix internal float/complex constants of different precision

There are several places where a new (internal) complex constant is allocated
via new(Mpcplx) rather than newMpcmplx(). The problem with using new() is that
the Mpcplx data structure's Real and Imag components don't get initialized with
an Mpflt of the correct precision (they have precision 0, which may be adjusted
later).

In all cases but one, the components of those complex constants are set using
a Set operation which "inherits" the correct precision from the value that is
being set.

But when creating a complex value for an imaginary literal, the imaginary
component is set via SetString which assumes 64bits of precision by default.
As a result, the internal representation of 0.01i and complex(0, 0.01) was
not correct.

Replaced all used of new(Mpcplx) with newMpcmplx() and added a new test.

Fixes #30243.

Change-Id: Ife7fd6ccd42bf887a55c6ce91727754657e6cb2d
Reviewed-on: https://go-review.googlesource.com/c/163000
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
6 years agocmd/vet: do not write test vet binary to GOROOT
Bryan C. Mills [Tue, 19 Feb 2019 19:43:52 +0000 (14:43 -0500)]
cmd/vet: do not write test vet binary to GOROOT

Updates #28387

Change-Id: Ie5a5f1f798eb5900f9c7bdef165abcca02dd0dde
Reviewed-on: https://go-review.googlesource.com/c/163037
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/nm: fix testGoLib helper to be module-agnostic
Bryan C. Mills [Tue, 19 Feb 2019 18:53:39 +0000 (13:53 -0500)]
cmd/nm: fix testGoLib helper to be module-agnostic

Updates #30228

Change-Id: I3c7864e6725312df5ec978cdc130ccfe8fc2e738
Reviewed-on: https://go-review.googlesource.com/c/162836
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/internal/obj/x86: fix issue19518_test in module mode
Bryan C. Mills [Fri, 15 Feb 2019 23:07:49 +0000 (18:07 -0500)]
cmd/internal/obj/x86: fix issue19518_test in module mode

Updates #30228

Change-Id: I6a38269f322d906702921b3879ff48c8a96ab511
Reviewed-on: https://go-review.googlesource.com/c/162831
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agosrc, misc: apply gofmt
Robert Griesemer [Thu, 14 Feb 2019 01:00:36 +0000 (17:00 -0800)]
src, misc: apply gofmt

This applies the new gofmt literal normalizations to the library.

Change-Id: I8c1e8ef62eb556fc568872c9f77a31ef236348e7
Reviewed-on: https://go-review.googlesource.com/c/162539
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/gofmt: normalize integer imaginary literals starting with 0
Robert Griesemer [Thu, 14 Feb 2019 00:38:01 +0000 (16:38 -0800)]
cmd/gofmt: normalize integer imaginary literals starting with 0

An 'i' suffix on an integer literal marks the integer literal as
a decimal integer imaginary value, even if the literal without the
suffix starts with a 0 and thus looks like an octal value:

0123i == 123i // != 0123 * 1i

This is at best confusing, and at worst a potential source of bugs.
It is always safe to rewrite such literals into the equivalent
literal without the leading 0.

This CL implements this normalization.

Change-Id: Ib77ad535f98b5be912ecbdec20ca1b472c1b4973
Reviewed-on: https://go-review.googlesource.com/c/162538
Run-TryBot: Robert Griesemer <gri@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go: set GO111MODULE=off explicitly in tests that assume GOPATH mode
Bryan C. Mills [Wed, 13 Feb 2019 20:06:46 +0000 (15:06 -0500)]
cmd/go: set GO111MODULE=off explicitly in tests that assume GOPATH mode

We will soon switch GO111MODULE to 'on' by default, and when that
happens these tests will otherwise break.

Updates #30228

Change-Id: I1016d429b1dfb889d1aae8bc86fb2567cf0fc56f
Reviewed-on: https://go-review.googlesource.com/c/162697
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agoruntime: make tests that invoke 'go build' module-agnostic
Bryan C. Mills [Thu, 14 Feb 2019 22:38:36 +0000 (17:38 -0500)]
runtime: make tests that invoke 'go build' module-agnostic

In module mode, building the current directory requires a go.mod file
(in order to determine the import path of the package).

Change the tests to pass explicit file arguments instead, since those
can be built in module mode without defining a module.

Updates #30228

Change-Id: I680c658d1f79645f73ad4d1e88189ea50a4852e9
Reviewed-on: https://go-review.googlesource.com/c/162837
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
6 years agospec: document signed integer shift counts
Robert Griesemer [Tue, 5 Feb 2019 22:33:24 +0000 (14:33 -0800)]
spec: document signed integer shift counts

Updates #19113.

Change-Id: I4726f51c5061c33979cdd061f6d4616fa97edb9a
Reviewed-on: https://go-review.googlesource.com/c/161201
Reviewed-by: Rob Pike <r@golang.org>
6 years agogo/types: include test/fixedbugs/bug073.go again in test
Robert Griesemer [Thu, 24 Jan 2019 04:47:44 +0000 (20:47 -0800)]
go/types: include test/fixedbugs/bug073.go again in test

This test was excluded from the go/types std lib test
because it tested old behavior (shift count must be
an unsigned int). With the compiler changes made and
the test adjusted accordingly, we can include it again.

Updates #19113.

Change-Id: If9b6b83505d2bd2b426fcefa225986d73658a229
Reviewed-on: https://go-review.googlesource.com/c/159319
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
6 years agocmd/compile: guard against loads with negative offset from readonly constants
Cherry Zhang [Fri, 15 Feb 2019 20:01:29 +0000 (15:01 -0500)]
cmd/compile: guard against loads with negative offset from readonly constants

CL 154057 adds guards agaist out-of-bound reads from readonly
constants. It turns out that in dead code, the offset can also
be negative. Guard against negative offset as well.

Fixes #30257.

Change-Id: I47c2a2e434dd466c08ae6f50f213999a358c796e
Reviewed-on: https://go-review.googlesource.com/c/162819
Reviewed-by: Keith Randall <khr@golang.org>
6 years agodoc/go1.12: document net/url.Parse now rejecting ASCII CTLs
Brad Fitzpatrick [Fri, 15 Feb 2019 23:42:32 +0000 (23:42 +0000)]
doc/go1.12: document net/url.Parse now rejecting ASCII CTLs

Updates #27302
Updates #22907

Change-Id: Iac6957f3517265dfb9c662efb7af31192e3bfd6c
Reviewed-on: https://go-review.googlesource.com/c/162960
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: implement shifts by signed amounts
Keith Randall [Sun, 20 Jan 2019 18:52:11 +0000 (10:52 -0800)]
cmd/compile: implement shifts by signed amounts

Allow shifts by signed amounts. Panic if the shift amount is negative.

TODO: We end up doing two compares per shift, see Ian's comment
https://github.com/golang/go/issues/19113#issuecomment-443241799 that
we could do it with a single comparison in the normal case.

The prove pass mostly handles this code well. For instance, it removes the
<0 check for cases like this:
    if s >= 0 { _ = x << s }
    _ = x << len(a)

This case isn't handled well yet:
    _ = x << (y & 0xf)
I'll do followon CLs for unhandled cases as needed.

Update #19113

R=go1.13

Change-Id: I839a5933d94b54ab04deb9dd5149f32c51c90fa1
Reviewed-on: https://go-review.googlesource.com/c/158719
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
6 years agocmd/go: add newline after module-requires-version message
Ian Lance Taylor [Fri, 15 Feb 2019 21:00:03 +0000 (13:00 -0800)]
cmd/go: add newline after module-requires-version message

Fixes #30263

Change-Id: Iefb3d8baf815c19eaf915a59048e1da799ca0cdf
Reviewed-on: https://go-review.googlesource.com/c/162957
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agosyscall: skip TestSyscallNoError when temp dir is mounted nosuid
Brad Fitzpatrick [Fri, 15 Feb 2019 18:55:45 +0000 (18:55 +0000)]
syscall: skip TestSyscallNoError when temp dir is mounted nosuid

Fixes #30258

Change-Id: I73b63eb9d3aca00f562fdc3af010e96269bb6b9c
Reviewed-on: https://go-review.googlesource.com/c/162891
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
6 years agocmd/go: only generate a go.mod file during 'go mod init'
Bryan C. Mills [Wed, 13 Feb 2019 22:37:50 +0000 (17:37 -0500)]
cmd/go: only generate a go.mod file during 'go mod init'

In the general case, we do not know the correct module path for a new
module unless we have checked its VCS tags for a major version. If we
do not know the correct path, then we should not synthesize a go.mod
file automatically from it.

On the other hand, we don't want to run VCS commands in the working
directory without an explicit request by the user to do so: 'go mod
init' can reasonably invoke a VCS command, but 'go build' should not.

Therefore, we should only create a go.mod file during 'go mod init'.

This change removes the previous behavior of synthesizing a file
automatically, and instead suggests a command that the user can opt to
run explicitly.

Updates #29433
Updates #27009
Updates #30228

Change-Id: I8c4554969db17156e97428df220b129a4d361040
Reviewed-on: https://go-review.googlesource.com/c/162699
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agodatabase/sql/driver: fix typo
Zhou Peng [Fri, 15 Feb 2019 08:41:33 +0000 (16:41 +0800)]
database/sql/driver: fix typo

Change-Id: I6e7035db4b3e2a09e5655eb7646eea9d99fb7118
Reviewed-on: https://go-review.googlesource.com/c/162917
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc/go1.12: note that Go 1.12 is the last release to include godoc
Brad Fitzpatrick [Wed, 13 Feb 2019 19:07:40 +0000 (19:07 +0000)]
doc/go1.12: note that Go 1.12 is the last release to include godoc

Updates #30029

Change-Id: I88e09035d675e7a6855ada0262eb42636c9822cc
Reviewed-on: https://go-review.googlesource.com/c/162417
Reviewed-by: Andrew Bonventre <andybons@golang.org>
6 years agocrypto/tls, runtime: document GODEBUG TLS 1.3 option
Brad Fitzpatrick [Wed, 13 Feb 2019 16:15:09 +0000 (16:15 +0000)]
crypto/tls, runtime: document GODEBUG TLS 1.3 option

Change-Id: I6801676335924414ce50249df2b7bea08886b203
Reviewed-on: https://go-review.googlesource.com/c/162360
Reviewed-by: Filippo Valsorda <filippo@golang.org>
6 years agonet/http/httputil: make TestDumpRequest idempotent
Emmanuel T Odeke [Sun, 9 Dec 2018 07:32:15 +0000 (23:32 -0800)]
net/http/httputil: make TestDumpRequest idempotent

TestDumpRequest was failing with -count=2 or more
because for test cases that involved mustReadRequest,
the body was created as a *bufio.Reader. DumpRequest
and DumpRequestOut would then read the body until EOF
and would close it after use.
However, on re-runs of the test, the body would
be terminally exhausted and result in an unexpected
error "http: invalid Read on closed Body".

The update to the test cases adds an extra field "GetReq"
which allows us to construct requests per run of the tests
and hence make the test indefinitely re-runnable/idempotent.
"Req" or "GetReq" are mutually exclusive: either one of them
can be set or nil, but not both.

Fixes #26858

Change-Id: Ice3083dac1aa3249da4afc7075cd984eb159530d
Reviewed-on: https://go-review.googlesource.com/c/153377
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoruntime: scan gp._panic in stack scan
Cherry Zhang [Sun, 10 Feb 2019 04:31:59 +0000 (23:31 -0500)]
runtime: scan gp._panic in stack scan

In runtime.gopanic, the _panic object p is stack allocated and
referenced from gp._panic. With stack objects, p on stack is dead
at the point preprintpanics runs. gp._panic points to p, but
stack scan doesn't look at gp. Heap scan of gp does look at
gp._panic, but it stops and ignores the pointer as it points to
the stack. So whatever p points to may be collected and clobbered.
We need to scan gp._panic explicitly during stack scan.

To test it reliably, we introduce a GODEBUG mode "clobberfree",
which clobbers the memory content when the GC frees an object.

Fixes #30150.

Change-Id: I11128298f03a89f817faa221421a9d332b41dced
Reviewed-on: https://go-review.googlesource.com/c/161778
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
6 years agodoc: don't use "go tool vet" as an example
Ian Lance Taylor [Wed, 13 Feb 2019 04:45:45 +0000 (20:45 -0800)]
doc: don't use "go tool vet" as an example

Fixes #30199

Change-Id: Ib4586e3facb8c0985c8882482d94843b648b9d2f
Reviewed-on: https://go-review.googlesource.com/c/162257
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc/go1.12: soften, expand crypto/rc4 assembly removal text
Brad Fitzpatrick [Tue, 12 Feb 2019 18:33:24 +0000 (18:33 +0000)]
doc/go1.12: soften, expand crypto/rc4 assembly removal text

Change-Id: I46fa43f6c5ac49386f4622e1363d8976f49c0894
Reviewed-on: https://go-review.googlesource.com/c/162019
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoos: don't return ENOENT if directory removed before Fstatat
Ian Lance Taylor [Tue, 12 Feb 2019 18:20:28 +0000 (10:20 -0800)]
os: don't return ENOENT if directory removed before Fstatat

Fixes #30197

Change-Id: I08b592fbd477d6879eb5d3b7fcbbc8322ea90103
Reviewed-on: https://go-review.googlesource.com/c/162078
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agostrconv: add 0b, 0o integer prefixes in ParseInt, ParseUint
Russ Cox [Wed, 30 Jan 2019 02:21:38 +0000 (21:21 -0500)]
strconv: add 0b, 0o integer prefixes in ParseInt, ParseUint

This CL modifies ParseInt and ParseUint to recognize
0b and 0o as binary and octal base prefixes when base == 0.

See golang.org/design/19308-number-literals for background.

For #19308.
For #12711.

Change-Id: I8efe067f415aa517bdefbff7e230d3fa1694d530
Reviewed-on: https://go-review.googlesource.com/c/160244
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agostrconv: accept underscores in ParseInt, ParseUint, ParseFloat
Russ Cox [Wed, 30 Jan 2019 01:59:33 +0000 (20:59 -0500)]
strconv: accept underscores in ParseInt, ParseUint, ParseFloat

This CL modifies ParseInt, ParseUint, and ParseFloat
to accept digit-separating underscores in their arguments.
For ParseInt and ParseUint, the underscores are only
allowed when base == 0.

See golang.org/design/19308-number-literals for background.

For #28493.

Change-Id: I057ca2539d89314643f591ba8144c3ea7126651c
Reviewed-on: https://go-review.googlesource.com/c/160243
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agostrconv: format hex floats
Russ Cox [Wed, 30 Jan 2019 01:16:59 +0000 (20:16 -0500)]
strconv: format hex floats

This CL updates FormatFloat to format
standard hexadecimal floating-point constants,
using the 'x' and 'X' verbs.

See golang.org/design/19308-number-literals for background.

For #29008.

Change-Id: I540b8f71d492cfdb7c58af533d357a564591f28b
Reviewed-on: https://go-review.googlesource.com/c/160242
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agostrconv: parse hex floats
Russ Cox [Tue, 29 Jan 2019 21:25:54 +0000 (16:25 -0500)]
strconv: parse hex floats

This CL updates ParseFloat to recognize
standard hexadecimal floating-point constants.
See golang.org/design/19308-number-literals for background.

For #29008.

Change-Id: I45f3b0c36b5d92c0e8a4b35c05443a83d7a6d4b3
Reviewed-on: https://go-review.googlesource.com/c/160241
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agonet/http/httptrace: fix typo
berkant ipek [Tue, 12 Feb 2019 14:45:12 +0000 (14:45 +0000)]
net/http/httptrace: fix typo

Change-Id: I15279e4aa9306bde925929907a7b5e7ef5d8b642
GitHub-Last-Rev: 6bc2d66aecd424b322ec0c23b280e74cb22e08c3
GitHub-Pull-Request: golang/go#30193
Reviewed-on: https://go-review.googlesource.com/c/162018
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: update compiler's format test (fix long test)
Robert Griesemer [Tue, 12 Feb 2019 00:43:09 +0000 (16:43 -0800)]
cmd/compile: update compiler's format test (fix long test)

Change-Id: Ia546d3f0a12a3c3c291f7b6d5291193fdd47d7dd
Reviewed-on: https://go-review.googlesource.com/c/161966
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agogo/types: permit signed integer shift count
Robert Griesemer [Thu, 24 Jan 2019 02:10:54 +0000 (18:10 -0800)]
go/types: permit signed integer shift count

Permit shifts by non-constant signed integer shift counts.
Share logic for constant shift counts in non-constant
shifts and improve error messages a little bit.

R=Go1.13

Updates #19113.

Change-Id: Ia01d83ca8aa60a6a3f4c49f026e0c46396f852be
Reviewed-on: https://go-review.googlesource.com/c/159317
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
6 years agotext/scanner: accept new Go2 number literals
Robert Griesemer [Tue, 5 Feb 2019 20:42:46 +0000 (12:42 -0800)]
text/scanner: accept new Go2 number literals

This CL introduces text/scanner support for the new binary and octal integer
literals, hexadecimal floats, and digit separators for all number literals.
The new code is closely mirroring the respective code for number literals in
cmd/compile/internal/syntax/scanner.go.

Uniformly use the term "invalid" rather than "illegal" in error messages
to match the respective error messages in the other scanners directly.

R=Go1.13

Updates #12711.
Updates #19308.
Updates #28493.
Updates #29008.

Change-Id: I2f291de13ba5afc0e530cd8326e6bf4c3858ebac
Reviewed-on: https://go-review.googlesource.com/c/161199
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: do not export float or complex constants with -asmhdr
Robert Griesemer [Mon, 11 Feb 2019 22:27:43 +0000 (14:27 -0800)]
cmd/compile: do not export float or complex constants with -asmhdr

The -asmhdr flag is used to generate header files for assembly code
such that that code has access to compile-time constants. During
the build these constants end up in the (ephemeral) file go_asm.h.

For historical reasons, floating-point and complex constants are
printed with a 'p' exponent but with decimal mantissa; also, because
of the compiler-internal precision of 512 bits, the mantissae are quite
large (and conversions are comparatively slow).

With the changes to the new Go 2 number literals, the respective
upcoming changes to text/scanner (which in turn is used by the assembler)
will make text/scanner newly accept hexadecimal floats; but also decimal
floats using the incorrect 'p' exponent and report an error in that case.

As a consequence, the assembler will report an error when trying to parse
the before-mentioned decimal floating-point values which are using 'p'
exponents. Since these constants are never needed in the assembly code,
do not emit them in the first place.

Change-Id: I06c7c96b04e8d062441120107992472f87a651b2
Reviewed-on: https://go-review.googlesource.com/c/161904
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agotext/scanner: don't crash when calling TokenText in error handler
Robert Griesemer [Mon, 14 Jan 2019 21:34:42 +0000 (13:34 -0800)]
text/scanner: don't crash when calling TokenText in error handler

Make sure Scanner.tokEnd is set before we call Scanner.Error
and update documentation accordingly.
(Until now tokEnd was only set before returning from Scan,
so a call to TokenText during error handling may have crashed.)

While at it, tighten a check in Scanner.TokenText to ensure
Scanner.tokEnd >= Scanner.tokPos if we have a token.

Also, silence error messages to Stderr in unrelated TestIllegalExponent.

Fixes #29723.

Change-Id: Ia97beeae91eaf9e0ed3dada0a806f1f7122461cc
Reviewed-on: https://go-review.googlesource.com/c/157819
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
6 years agocmd/gofmt: normalize number prefixes and exponents
Robert Griesemer [Wed, 30 Jan 2019 06:12:13 +0000 (22:12 -0800)]
cmd/gofmt: normalize number prefixes and exponents

Rewrite non-decimal number prefixes to always use a lower-case base
("0X" -> "0x", etc.), and rewrite exponents to use a lower-case 'e'
or 'p'. Leave hexadecimal digits and 0-octals alone.

Comparing the best time of 3 runs of `time go test -run All` with
the time for a gofmt that doesn't do the rewrite shows no increase
in runtime for this bulk gofmt application (in fact on my machine
I see a small decline, probably due to cache effects).

R=Go1.13

Updates #12711.
Updates #19308.
Updates #29008.

Change-Id: I9c6ebed2ffa0a6a001c59412a73382090955f5a9
Reviewed-on: https://go-review.googlesource.com/c/160184
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agogo/types: add tests for new Go 2 number literals
Robert Griesemer [Wed, 30 Jan 2019 00:00:45 +0000 (16:00 -0800)]
go/types: add tests for new Go 2 number literals

This CL ensures that go/types can now handle the new
Go 2 number literals. The relevant changes enabling
them in go/types were made in go/constant in the CL
https://golang.org/cl/160239.

R=Go1.13

Updates #12711.
Updates #19308.
Updates #28493.
Updates #29008.

Change-Id: I45c1387198fac94769ac59c5301d86b4e1a1ff98
Reviewed-on: https://go-review.googlesource.com/c/160240
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agogo/constant: accept new Go2 number literals
Robert Griesemer [Tue, 29 Jan 2019 23:41:50 +0000 (15:41 -0800)]
go/constant: accept new Go2 number literals

This CL introduces go/constant support for the new binary and octal integer
literals, hexadecimal floats, and digit separators for all number literals.

R=Go1.13

Updates #12711.
Updates #19308.
Updates #28493.
Updates #29008.

Change-Id: I7a55f91b8b6373ae6d98ba923b626d33c5552946
Reviewed-on: https://go-review.googlesource.com/c/160239
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/gofmt: test that Go 2 number literals can be formatted
Robert Griesemer [Tue, 29 Jan 2019 00:33:49 +0000 (16:33 -0800)]
cmd/gofmt: test that Go 2 number literals can be formatted

R=Go1.13

Updates #12711.
Updates #19308.
Updates #28493.
Updates #29008.

Change-Id: Icd25aa7f6e18ed671ea6cf2b1b292899daf4b1a5
Reviewed-on: https://go-review.googlesource.com/c/160018
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agogo/scanner: accept new Go2 number literals
Robert Griesemer [Mon, 28 Jan 2019 23:29:23 +0000 (15:29 -0800)]
go/scanner: accept new Go2 number literals

This CL introduces go/scanner support for the new binary and octal integer
literals, hexadecimal floats, and digit separators for all number literals.
The new code is closely mirroring the respective code for number literals in
cmd/compile/internal/syntax/scanner.go.

R=Go1.13

Updates #12711.
Updates #19308.
Updates #28493.
Updates #29008.

Change-Id: I5315c6aaa7cfc41a618296be20e3acd5114d6b3c
Reviewed-on: https://go-review.googlesource.com/c/159997
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/compile: accept new Go2 number literals
Robert Griesemer [Sun, 13 Jan 2019 04:33:58 +0000 (20:33 -0800)]
cmd/compile: accept new Go2 number literals

This CL introduces compiler support for the new binary and octal integer
literals, hexadecimal floats, and digit separators for all number literals.

The new Go 2 number literal scanner accepts the following liberal format:

number   = [ prefix ] digits [ "." digits ] [ exponent ] [ "i" ] .
prefix   = "0" [ "b" |"B" | "o" | "O" | "x" | "X" ] .
digits   = { digit | "_" } .
exponent = ( "e" | "E" | "p" | "P" ) [ "+" | "-" ] digits .

If the number starts with "0x" or "0X", digit is any hexadecimal digit;
otherwise, digit is any decimal digit. If the accepted number is not valid,
errors are reported accordingly.

See the new test cases in scanner_test.go for a selection of valid and
invalid numbers and the respective error messages.

R=Go1.13

Updates #12711.
Updates #19308.
Updates #28493.
Updates #29008.

Change-Id: Ic8febc7bd4dc5186b16a8c8897691e81125cf0ca
Reviewed-on: https://go-review.googlesource.com/c/157677
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>