]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
5 years agotime: read 64-bit data if available
Ian Lance Taylor [Wed, 6 Feb 2019 06:52:03 +0000 (22:52 -0800)]
time: read 64-bit data if available

Also store 64-bit data in lib/time/zoneinfo.zip.

The comments argue that we don't need the 64-bit data until 2037 or
2106, but that turns out not to be the case. We also need them for
dates before December 13, 1901, which is time.Unix(-0x80000000, 0).

Fixes #30099

Change-Id: Ib8c9efb29b7b3c08531ae69912c588209d6320e9
Reviewed-on: https://go-review.googlesource.com/c/161202
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/compile: don't generate newobject call for 0-sized types
Iskander Sharipov [Fri, 28 Dec 2018 18:40:04 +0000 (21:40 +0300)]
cmd/compile: don't generate newobject call for 0-sized types

Emit &runtime.zerobase instead of a call to newobject for
allocations of zero sized objects in walk.go.

Fixes #29446

Change-Id: I11b67981d55009726a17c2e582c12ce0c258682e
Reviewed-on: https://go-review.googlesource.com/c/155840
Run-TryBot: Iskander Sharipov <quasilyte@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agofmt: fix an error in documentation for fmt
Bryan Heden [Thu, 14 Feb 2019 02:35:00 +0000 (02:35 +0000)]
fmt: fix an error in documentation for fmt

Original Printf("%d", hi) obviously doesn't produce
%!d(string=hi) unless somewhere before this code
block you have hi := "hi" somewhere, also this change
maintains consistency with the rest of it

Change-Id: I40d8cca623176dcad66374ba74e3a1f8f975ac9e
GitHub-Last-Rev: 242e9ee6afba7ab22ed2967b0ba01ef18db01ca9
GitHub-Pull-Request: golang/go#30223
Reviewed-on: https://go-review.googlesource.com/c/162541
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agonet/http: add godoc for Dir.Open function
Dmitry Mottl [Fri, 22 Feb 2019 16:50:54 +0000 (16:50 +0000)]
net/http: add godoc for Dir.Open function

This commit adds godoc for Dir.Open function.

Change-Id: Ibc3b22f38660a082802e1f868c5cf9d880fc2801
GitHub-Last-Rev: 774cfd7d8cc61989179956e47d51451135b6c203
GitHub-Pull-Request: golang/go#30353
Reviewed-on: https://go-review.googlesource.com/c/163437
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agotest: add test case that caused a gccgo compiler crash
Ian Lance Taylor [Thu, 14 Feb 2019 05:45:58 +0000 (21:45 -0800)]
test: add test case that caused a gccgo compiler crash

Change-Id: Icdc980e0dcb5639c49aba5f4f252f33bd207e4fa
Reviewed-on: https://go-review.googlesource.com/c/162617
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocompress/gzip: clarify that Multistream gzip requires a ByteReader
Jeremy Jay [Mon, 18 Feb 2019 03:33:28 +0000 (03:33 +0000)]
compress/gzip: clarify that Multistream gzip requires a ByteReader

Change-Id: Ib24778f3172c011e6a39ee65dce8764f3cc911ea
GitHub-Last-Rev: 9c617c1e60ac48db67e26e64ce240d3845c0e6ac
GitHub-Pull-Request: golang/go#30284
Reviewed-on: https://go-review.googlesource.com/c/162999
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agoall: fix typos as reported by 'misspell'
Leon Klingele [Fri, 22 Feb 2019 15:53:52 +0000 (15:53 +0000)]
all: fix typos as reported by 'misspell'

Change-Id: I904b8655f21743189814bccf24073b6fbb9fc56d
GitHub-Last-Rev: b032c14394c949f9ad7b18d019a3979d38d4e1fb
GitHub-Pull-Request: golang/go#29997
Reviewed-on: https://go-review.googlesource.com/c/160421
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agoio: align style of test comments in multi_test.go
Derek Phan [Sun, 13 Jan 2019 06:07:33 +0000 (06:07 +0000)]
io: align style of test comments in multi_test.go

Change-Id: Ic93a084311de46461ed3b30f4ac2fe11311e74d7
GitHub-Last-Rev: 32fbd63b10d0fa489406333ff6f8b6708974a73c
GitHub-Pull-Request: golang/go#29705
Reviewed-on: https://go-review.googlesource.com/c/157642
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
5 years agocmd/compile: avoid collisions between statictmps and user vars
Alessandro Arzilli [Tue, 16 Oct 2018 14:11:59 +0000 (16:11 +0200)]
cmd/compile: avoid collisions between statictmps and user vars

Avoid name collisions between autogenerated statictmp variables and
user defined global variables.

Fixes #25113

Change-Id: I023eb42a5c2bd2f5352b046d33363faed87084dc
Reviewed-on: https://go-review.googlesource.com/c/142497
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/link: delete stale deadcode reference
Austin Clements [Sat, 3 Nov 2018 21:23:30 +0000 (17:23 -0400)]
cmd/link: delete stale deadcode reference

Back when the linker did code generation after dead code elimination,
it had to know that references to runtime.read_tls_fallback could be
generated at code generation time (and never appear before that). Now
that code generation is done by the compiler, the references to
runtime.read_tls_fallback are obvious in the relocations, so the
linker no longer needs special knowledge of this symbol.

Change-Id: I9813a8478e85a6a13470b2d0528db53fd33fcfdf
Reviewed-on: https://go-review.googlesource.com/c/154601
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agobytes: hoist error creation out of function
Marcel van Lohuizen [Fri, 8 Feb 2019 16:57:46 +0000 (17:57 +0100)]
bytes: hoist error creation out of function

generating frame information in errors will cause this
function to no longer be inlined.

Updates #29934.

Change-Id: I1d7bc11707f1872d7315f627bfb9a12afa41e358
Reviewed-on: https://go-review.googlesource.com/c/161760
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agoruntime: use hw.ncpuonline sysctl in getncpu on openbsd
Tobias Klauser [Fri, 8 Feb 2019 08:25:05 +0000 (09:25 +0100)]
runtime: use hw.ncpuonline sysctl in getncpu on openbsd

The number of CPUs reported by the hw.ncpu sysctl is twice as high as
the actual number of CPUs running on OpenBSD 6.4. with hyperthreading
disabled (hw.smt=0). Try hw.cpuonline first and fall back to hw.ncpu
in case it fails (which is the case on older OpenBSD before 6.4).

Fixes #30127

Change-Id: Id091234b8038cc9f7c40519d039fc1a05437c40d
Reviewed-on: https://go-review.googlesource.com/c/161757
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
5 years agonet/http: clean the path of the stripped URL by StripPrefix
Ggicci [Mon, 11 Feb 2019 10:00:02 +0000 (18:00 +0800)]
net/http: clean the path of the stripped URL by StripPrefix

The path of the new stripped URL should also be cleaned. Since an empty path
may cause unexpected errors in some HTTP handlers, e.g. http.ServeFile.

Fixes #30165

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

5 years agocrypto/tls: fix typo
Yasser Abdolmaleki [Mon, 11 Feb 2019 01:55:27 +0000 (17:55 -0800)]
crypto/tls: fix typo

Change-Id: If9332bae87449c94fc14710133614fcd84d2815c
Reviewed-on: https://go-review.googlesource.com/c/161726
Reviewed-by: Filippo Valsorda <filippo@golang.org>
5 years agosyscall: add empty line before marker comments in zsyscall_darwin_*.go
Tobias Klauser [Tue, 18 Dec 2018 14:59:47 +0000 (15:59 +0100)]
syscall: add empty line before marker comments in zsyscall_darwin_*.go

This was spotted during the review of the corresponding CL 154179 for
x/sys/unix. Let's change it in syscall as well to be consistent.

Change-Id: I33f25db1f6ba941b694c2aa276336448cc2b9b51
Reviewed-on: https://go-review.googlesource.com/c/154719
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/internal/src: fix typo in pos.go
Tooru Takahashi [Fri, 11 Jan 2019 14:08:37 +0000 (14:08 +0000)]
cmd/internal/src: fix typo in pos.go

Change-Id: I31ac8845e72c3027c9a463b1f691f4d2b7913ec0
GitHub-Last-Rev: a6b185cc41d649141e6034b77bcfe53525498ea6
GitHub-Pull-Request: golang/go#29682
Reviewed-on: https://go-review.googlesource.com/c/157518
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>

5 years agocmd/compile: don't bother compiling functions named "_"
Keith Randall [Tue, 22 Jan 2019 18:08:10 +0000 (10:08 -0800)]
cmd/compile: don't bother compiling functions named "_"

They can't be used, so we don't need code generated for them. We just
need to report errors in their bodies.

The compiler currently has a bunch of special cases sprinkled about
for "_" functions, because we never generate a linker symbol for them.
Instead, abort compilation earlier so we never reach any of that
special-case code.

Fixes #29870

Change-Id: I3530c9c353deabcf75ce9072c0b740e992349ee5
Reviewed-on: https://go-review.googlesource.com/c/158845
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
5 years agocmd/compile: treat slice pointers as non-nil
Keith Randall [Mon, 25 Feb 2019 22:51:58 +0000 (14:51 -0800)]
cmd/compile: treat slice pointers as non-nil

var a []int = ...
p := &a[0]
_ = *p

We don't need to nil check on the 3rd line. If the bounds check on the 2nd
line passes, we know p is non-nil.

We rely on the fact that any cap>0 slice has a non-nil pointer as its
pointer to the backing array. This is true for all safely-constructed slices,
and I don't see any reason why someone would violate this rule using unsafe.

R=go1.13

Fixes #30366

Change-Id: I3ed764fcb72cfe1fbf963d8c1a82e24e3b6dead7
Reviewed-on: https://go-review.googlesource.com/c/163740
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
5 years agocmd/compile: update comment about x86 nop instruction generator
Keith Randall [Tue, 15 Jan 2019 23:00:43 +0000 (15:00 -0800)]
cmd/compile: update comment about x86 nop instruction generator

The comment about losing the high bits is incorrect.  We now use these
nops in places where they really need to be a nop.  (Before inline
marks, we used them just before deferreturn calls, so they could
clobber any caller-saved values.)

Change-Id: I433d1ec455aa37dab8fef6eb7d407f3737dbb97f
Reviewed-on: https://go-review.googlesource.com/c/158057
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
5 years agoruntime: fix syscall.NewCallback to return all bits for uintptr values
Alex Brainman [Fri, 25 Jan 2019 07:56:22 +0000 (18:56 +1100)]
runtime: fix syscall.NewCallback to return all bits for uintptr values

syscall.NewCallback mistakenly used MOVL even for windows/amd64,
which only returned the lower 32 bits regardless of the architecture.
This was due to a copy and paste after porting from windows/386.
The code now uses MOVQ, which will return all the available bits.

Also adjust TestReturnAfterStackGrowInCallback to ensure we never
regress.

Fixes #29331

Change-Id: I4f5c8021c33f234c2bb7baa9ef7a6b4870172509
Reviewed-on: https://go-review.googlesource.com/c/159579
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agohtml/template: use strings.Builder
Josh Bleecher Snyder [Fri, 28 Dec 2018 19:32:09 +0000 (09:32 -1000)]
html/template: use strings.Builder

...and size initial buffers more accurately.

Easy pickings only. More might remain.

name                             old time/op    new time/op    delta
CSSEscaper-8                       1.17µs ± 1%    0.80µs ± 2%  -31.55%  (p=0.000 n=44+48)
CSSEscaperNoSpecials-8              205ns ± 2%     204ns ± 3%   -0.73%  (p=0.014 n=46+49)
DecodeCSS-8                         438ns ± 2%     436ns ± 2%     ~     (p=0.099 n=48+47)
DecodeCSSNoSpecials-8              6.11ns ± 3%    5.93ns ± 3%   -2.85%  (p=0.000 n=50+48)
CSSValueFilter-8                    149ns ± 0%     145ns ± 0%   -2.68%  (p=0.000 n=32+35)
CSSValueFilterOk-8                  238ns ± 2%     234ns ± 2%   -1.40%  (p=0.000 n=49+47)
EscapedExecute-8                   2.53µs ± 2%    2.55µs ± 1%   +0.87%  (p=0.000 n=48+49)
HTMLNospaceEscaper-8               1.35µs ± 2%    0.92µs ± 1%  -31.74%  (p=0.000 n=48+48)
HTMLNospaceEscaperNoSpecials-8      278ns ± 2%     263ns ± 2%   -5.17%  (p=0.000 n=47+49)
StripTags-8                         778ns ± 2%     786ns ± 1%   +0.96%  (p=0.000 n=46+47)
StripTagsNoSpecials-8              84.2ns ± 1%    84.1ns ± 1%     ~     (p=0.300 n=48+48)
JSValEscaperWithNum-8               506ns ± 2%     486ns ± 3%   -3.82%  (p=0.000 n=47+45)
JSValEscaperWithStr-8              1.61µs ± 1%    1.64µs ± 1%   +1.75%  (p=0.000 n=44+49)
JSValEscaperWithStrNoSpecials-8     548ns ± 2%     552ns ± 2%   +0.78%  (p=0.000 n=48+46)
JSValEscaperWithObj-8              1.91µs ± 2%    1.87µs ± 1%   -2.08%  (p=0.000 n=49+47)
JSValEscaperWithObjNoSpecials-8     735ns ± 2%     742ns ± 2%   +1.01%  (p=0.000 n=47+49)
JSStrEscaperNoSpecials-8            228ns ± 4%     211ns ± 3%   -7.53%  (p=0.000 n=50+49)
JSStrEscaper-8                     1.11µs ± 1%    0.78µs ± 1%  -29.94%  (p=0.000 n=48+48)
JSRegexpEscaperNoSpecials-8         214ns ± 2%     212ns ± 3%   -1.12%  (p=0.000 n=50+49)
JSRegexpEscaper-8                  1.17µs ± 0%    0.79µs ± 1%  -31.92%  (p=0.000 n=48+47)
TemplateSpecialTags-8               172µs ± 1%     172µs ± 1%     ~     (p=0.976 n=48+47)
URLEscaper-8                       1.88µs ± 2%    1.87µs ± 2%   -0.56%  (p=0.001 n=49+49)
URLEscaperNoSpecials-8              162ns ± 1%     169ns ± 1%   +3.76%  (p=0.000 n=49+50)
URLNormalizer-8                    1.29µs ± 3%    1.29µs ± 2%   -0.37%  (p=0.041 n=48+48)
URLNormalizerNoSpecials-8           185ns ± 1%     186ns ± 1%   +0.15%  (p=0.013 n=49+49)
SrcsetFilter-8                      616ns ± 1%     618ns ± 1%   +0.36%  (p=0.000 n=46+46)
SrcsetFilterNoSpecials-8            359ns ± 0%     352ns ± 0%   -1.93%  (p=0.000 n=40+43)
[Geo mean]                          560ns          525ns        -6.17%

name                             old alloc/op   new alloc/op   delta
CSSEscaper-8                         672B ± 0%      336B ± 0%  -50.00%  (p=0.000 n=50+50)
CSSEscaperNoSpecials-8              0.00B          0.00B          ~     (all equal)
DecodeCSS-8                          160B ± 0%      160B ± 0%     ~     (all equal)
DecodeCSSNoSpecials-8               0.00B          0.00B          ~     (all equal)
CSSValueFilter-8                    96.0B ± 0%     96.0B ± 0%     ~     (all equal)
CSSValueFilterOk-8                  48.0B ± 0%     48.0B ± 0%     ~     (all equal)
EscapedExecute-8                     688B ± 0%      624B ± 0%   -9.30%  (p=0.000 n=50+50)
HTMLNospaceEscaper-8                 752B ± 0%      368B ± 0%  -51.06%  (p=0.000 n=50+50)
HTMLNospaceEscaperNoSpecials-8      48.0B ± 0%     32.0B ± 0%  -33.33%  (p=0.000 n=50+50)
StripTags-8                          224B ± 0%      224B ± 0%     ~     (all equal)
StripTagsNoSpecials-8                112B ± 0%      112B ± 0%     ~     (all equal)
JSValEscaperWithNum-8               96.0B ± 0%     40.0B ± 0%  -58.33%  (p=0.000 n=50+50)
JSValEscaperWithStr-8                384B ± 0%      384B ± 0%     ~     (all equal)
JSValEscaperWithStrNoSpecials-8     96.0B ± 0%     96.0B ± 0%     ~     (all equal)
JSValEscaperWithObj-8                448B ± 0%      448B ± 0%     ~     (all equal)
JSValEscaperWithObjNoSpecials-8      160B ± 0%      160B ± 0%     ~     (all equal)
JSStrEscaperNoSpecials-8            0.00B          0.00B          ~     (all equal)
JSStrEscaper-8                       672B ± 0%      336B ± 0%  -50.00%  (p=0.000 n=50+50)
JSRegexpEscaperNoSpecials-8         0.00B          0.00B          ~     (all equal)
JSRegexpEscaper-8                    672B ± 0%      336B ± 0%  -50.00%  (p=0.000 n=50+50)
TemplateSpecialTags-8              48.0kB ± 0%    47.9kB ± 0%   -0.13%  (p=0.000 n=50+48)
URLEscaper-8                         336B ± 0%      336B ± 0%     ~     (all equal)
URLEscaperNoSpecials-8               112B ± 0%      112B ± 0%     ~     (all equal)
URLNormalizer-8                      176B ± 0%      176B ± 0%     ~     (all equal)
URLNormalizerNoSpecials-8            112B ± 0%      112B ± 0%     ~     (all equal)
SrcsetFilter-8                       160B ± 0%      160B ± 0%     ~     (all equal)
SrcsetFilterNoSpecials-8             160B ± 0%      160B ± 0%     ~     (all equal)
[Geo mean]                           259B           216B       -16.60%

name                             old allocs/op  new allocs/op  delta
CSSEscaper-8                         4.00 ± 0%      2.00 ± 0%  -50.00%  (p=0.000 n=50+50)
CSSEscaperNoSpecials-8               0.00           0.00          ~     (all equal)
DecodeCSS-8                          1.00 ± 0%      1.00 ± 0%     ~     (all equal)
DecodeCSSNoSpecials-8                0.00           0.00          ~     (all equal)
CSSValueFilter-8                     2.00 ± 0%      2.00 ± 0%     ~     (all equal)
CSSValueFilterOk-8                   3.00 ± 0%      3.00 ± 0%     ~     (all equal)
EscapedExecute-8                     18.0 ± 0%      18.0 ± 0%     ~     (all equal)
HTMLNospaceEscaper-8                 5.00 ± 0%      3.00 ± 0%  -40.00%  (p=0.000 n=50+50)
HTMLNospaceEscaperNoSpecials-8       1.00 ± 0%      1.00 ± 0%     ~     (all equal)
StripTags-8                          3.00 ± 0%      3.00 ± 0%     ~     (all equal)
StripTagsNoSpecials-8                2.00 ± 0%      2.00 ± 0%     ~     (all equal)
JSValEscaperWithNum-8                3.00 ± 0%      3.00 ± 0%     ~     (all equal)
JSValEscaperWithStr-8                2.00 ± 0%      2.00 ± 0%     ~     (all equal)
JSValEscaperWithStrNoSpecials-8      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
JSValEscaperWithObj-8                3.00 ± 0%      3.00 ± 0%     ~     (all equal)
JSValEscaperWithObjNoSpecials-8      3.00 ± 0%      3.00 ± 0%     ~     (all equal)
JSStrEscaperNoSpecials-8             0.00           0.00          ~     (all equal)
JSStrEscaper-8                       4.00 ± 0%      2.00 ± 0%  -50.00%  (p=0.000 n=50+50)
JSRegexpEscaperNoSpecials-8          0.00           0.00          ~     (all equal)
JSRegexpEscaper-8                    4.00 ± 0%      2.00 ± 0%  -50.00%  (p=0.000 n=50+50)
TemplateSpecialTags-8                 185 ± 0%       185 ± 0%     ~     (all equal)
URLEscaper-8                         4.00 ± 0%      4.00 ± 0%     ~     (all equal)
URLEscaperNoSpecials-8               2.00 ± 0%      2.00 ± 0%     ~     (all equal)
URLNormalizer-8                      3.00 ± 0%      3.00 ± 0%     ~     (all equal)
URLNormalizerNoSpecials-8            2.00 ± 0%      2.00 ± 0%     ~     (all equal)
SrcsetFilter-8                       3.00 ± 0%      3.00 ± 0%     ~     (all equal)
SrcsetFilterNoSpecials-8             3.00 ± 0%      3.00 ± 0%     ~     (all equal)
[Geo mean]                           3.41           3.05       -10.65%

Change-Id: I809ea56495ce1881656af7e24621448ab64b449a
Reviewed-on: https://go-review.googlesource.com/c/155919
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/compile: remove badgerbadgerbadger optimization
Josh Bleecher Snyder [Tue, 26 Feb 2019 19:56:19 +0000 (11:56 -0800)]
cmd/compile: remove badgerbadgerbadger optimization

As discussed in #29242, this optimization is for a bash-ism.
No one writes Go code like this.

In this repo, it triggers only in test/fixedbugs/bug425.go
and that appears to be accidental.

Fixes #29242

Change-Id: I257e6ecc73f24680f7282c6ab28729de4e8b27af
Reviewed-on: https://go-review.googlesource.com/c/163728
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agomath/big: add %#b and %O integer formats
Russ Cox [Wed, 30 Jan 2019 05:55:38 +0000 (00:55 -0500)]
math/big: add %#b and %O integer formats

Matching fmt, %#b now prints an 0b prefix,
and %O prints octal with an 0o prefix.

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

For #19308.
For #12711.

Change-Id: I139c5a9a1dfae15415621601edfa13c6a5f19cfc
Reviewed-on: https://go-review.googlesource.com/c/160250
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agomath/big: add %x float format
Russ Cox [Wed, 30 Jan 2019 05:49:33 +0000 (00:49 -0500)]
math/big: add %x float format

big.Float already had %p for printing hex format,
but that format normalizes differently from fmt's %x
and ignores precision entirely.

This CL adds %x to big.Float, matching fmt's behavior:
the verb is spelled 'x' not 'p', the mantissa is normalized
to [1, 2), and precision is respected.

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

For #29008.

Change-Id: I9c1b9612107094856797e5b0b584c556c1914895
Reviewed-on: https://go-review.googlesource.com/c/160249
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agocmd/compile: inline checknil
Josh Bleecher Snyder [Sat, 10 Nov 2018 15:00:32 +0000 (07:00 -0800)]
cmd/compile: inline checknil

Now that checknil has only a single caller, inline it.

Passes toolstash-check.

Change-Id: I5b13596bef84dd9a3e7f4bff8560903f1e54acfb
Reviewed-on: https://go-review.googlesource.com/c/148829
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agoencoding/base32: simplify and speed up decoder
Daniel Martí [Sun, 16 Dec 2018 18:11:28 +0000 (19:11 +0100)]
encoding/base32: simplify and speed up decoder

First, we can lift the enc.decodeMap nil check out of the loop.

Second, we can make it clear to the compiler that 'in := src[0]' doesn't
need a bounds check, by making len(src)==0 a single if check that always
stops the loop. This is by far the largest speed-up.

Third, we can use a dst slice index instead of reslicing dst, which
removes work from the loop body.

While at it, we can merge the two 'switch dlen' pieces of code, which
simplifies the code and doesn't affect performance.

name            old time/op    new time/op    delta
DecodeString-8    80.2µs ± 0%    67.5µs ± 0%  -15.81%  (p=0.002 n=6+6)

name            old speed      new speed      delta
DecodeString-8   163MB/s ± 0%   194MB/s ± 0%  +18.78%  (p=0.002 n=6+6)

Change-Id: Iefeaae94c03453f8760452b1da706a77b3522718
Reviewed-on: https://go-review.googlesource.com/c/154422
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agogo/doc: skip escaping comments in pre-formatted blocks
Agniva De Sarker [Mon, 18 Feb 2019 09:13:06 +0000 (14:43 +0530)]
go/doc: skip escaping comments in pre-formatted blocks

CL 150377 made the change of converting smart quotes to their html escaped entities
for ToHTML, and to unicode quotes for ToText. But for ToText, the change
converted the quotes in pre-formatted text too.

This fixes that behavior to not touch any text in pre-formatted blocks, which also
makes the behavior consistent with ToHTML.

Fixes #29730

Change-Id: I58e0216cbdbe189d06d82147e5a02b620af14734
Reviewed-on: https://go-review.googlesource.com/c/162922
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agocmd/compile: fix a typo in assignment mismatch error
Agniva De Sarker [Thu, 7 Feb 2019 07:41:12 +0000 (13:11 +0530)]
cmd/compile: fix a typo in assignment mismatch error

Fixes #30087

Change-Id: Ic6d80f8e6e1831886af8613420b1bd129a1b4850
Reviewed-on: https://go-review.googlesource.com/c/161577
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 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>

5 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>
5 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>

5 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>
5 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>
5 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>

5 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>

5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>

5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>

5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>