1
0
mirror of https://github.com/golang/go synced 2024-09-24 15:20:16 -06:00
Commit Graph

2273 Commits

Author SHA1 Message Date
Didier Spezia
70da2d0a2a cmd/compile/internal/gc: fix internal compiler error on invalid declaration
Following an empty import, a declaration involving a ? symbol
generates an internal compiler error when the name of the
symbol (in newname function).

package a
import""
var?

go.go:2: import path is empty
go.go:3: internal compiler error: newname nil

Make sure dclname is not called when the symbol is nil.
The error message is now:

go.go:2: import path is empty
go.go:3: invalid declaration
go.go:4: syntax error: unexpected EOF

This CL was initially meant to be applied to the old parser,
and has been updated to apply to the new parser.

Fixes #11610

Change-Id: I75e07622fb3af1d104e3a38c89d9e128e3b94522
Reviewed-on: https://go-review.googlesource.com/15268
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-07 20:21:21 +00:00
Robert Griesemer
715f63778d cmd/compile: avoid converting huge floats to integers
Fixes #13471.

Change-Id: I232ad1729343d020254e313cfff182695ad6fc54
Reviewed-on: https://go-review.googlesource.com/17401
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-07 20:20:56 +00:00
Didier Spezia
7ebb96a489 cmd/compile/internal/gc: fix panic in Type Stringer
The following code:

func n() {(interface{int})}

generates:

3: interface contains embedded non-interface int
3: type %!v(PANIC=runtime error: invalid memory address or nil pointer dereference) is not an expression

It is because the corresponding symbol (Sym field in Type object)
is nil, resulting in a panic in typefmt.

Just skip the symbol if it is nil, so that the error message becomes:

3: interface contains embedded non-interface int
3: type interface { int } is not an expression

Fixes #11614

Change-Id: I219ae7eb01edca264fad1d4a1bd261d026294b00
Reviewed-on: https://go-review.googlesource.com/14015
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-12-07 20:18:03 +00:00
Russ Cox
05390a0793 misc/cgo/stdio: reenable tests
The build tags are necessary to keep "go build" in that directory
building only stdio.go, but we have to arrange for test/run.go to
treat them as satisfied.

Fixes #12625.

Change-Id: Iec0cb2fdc2c9b24a4e0530be25e940aa0cc9552e
Reviewed-on: https://go-review.googlesource.com/17454
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-05 21:24:30 +00:00
Matthew Dempsky
336c998291 cmd/compile: reject slice/map/func comparisons against converted nil
Fixes #13480.

Change-Id: Icbf4f83e965e84f7020f56c3f346193f8b91e7bf
Reviewed-on: https://go-review.googlesource.com/17461
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-05 05:46:48 +00:00
Håvard Haugen
8a34cf7ee0 cmd/compile: don't allow blank method declarations on builtins
Move test for isblank into addmethod so that most of the type checking
for methods is also performed for blank methods.

Fixes #11366.

Change-Id: I13d554723bf96d906d0b3ff390d7b7c87c1a5020
Reviewed-on: https://go-review.googlesource.com/16866
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-12-02 18:26:38 +00:00
Robert Griesemer
e18cd34c76 cmd/compile: use correct line number for := (LCOLAS)
- use same local variable name (lno) for line number for LCOLAS everywhere
- remove now unneeded assignment of line number to yylval.i in lexer

Fix per suggestion of mdempsky.

Fixes #13415.

Change-Id: Ie3c7f5681615042a12b81b26724b3a5d8a979c25
Reviewed-on: https://go-review.googlesource.com/17248
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-28 03:36:00 +00:00
Robert Griesemer
c7a3403140 cmd/compile: clearer error for invalid array/slice literal elements
Fixes #13365.

Change-Id: I5a447ff806dbbb11c8c75e2b5cfa7fd4a845fb92
Reviewed-on: https://go-review.googlesource.com/17206
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-25 19:49:38 +00:00
Michael Hudson-Doyle
0ae57c3b0b test: add ability to run tests with dynamic linking
This is a bit ugly but it's a useful test. Run go install -buildmode=shared std
and then go run run.go -linkshared (it passes on linux/amd64).

Change-Id: I5684c79cd03817fa1fc399788b7320f8535c08da
Reviewed-on: https://go-review.googlesource.com/16343
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-24 17:15:43 +00:00
Robert Griesemer
c28a8e4553 test: add test case for issue 13268
See https://go-review.googlesource.com/#/c/17047/ for the bug fix.

Change-Id: Id5b0a37439d0f8f1e668f7c2ac84335b37f3a300
Reviewed-on: https://go-review.googlesource.com/17177
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-24 04:14:39 +00:00
Caleb Spare
9216d3e344 test: remove dead branch from run.go
It relates to an obsolete notion of 'skipped-but-okay' tests.

Fixes #12394

Change-Id: Ib7e6444dc8565e1390bd42d65d30fac136593f78
Reviewed-on: https://go-review.googlesource.com/17000
Run-TryBot: Caleb Spare <cespare@gmail.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <shurcool@gmail.com>
2015-11-24 03:20:56 +00:00
Robert Griesemer
aad18b849b cmd/compile: address several more 1.6 TODOs in parser
- fix/check location of popdcl calls where questioned
- remove unnecessary handling of ... (LDDD) in ntype (couldn't be reached)
- inlined and fnret_type and simplified fnres as a consequence
- leave handling of ... (LDDD) in arg_list alone (remove TODO)
- verify that parser requires a ';' after last statement in a case/default
  (added test case)

Fixes #13243.

Change-Id: Iad94b498591a5e85f4cb15bbc01e8e101415560d
Reviewed-on: https://go-review.googlesource.com/17155
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-21 07:21:23 +00:00
Robert Griesemer
64cd86798b cmd/compile: better syntax error recovery
Use a combination of follow- and stop-token lists and nesting levels
to better synchronize parser after a syntax error.

Fixes #13319.

Change-Id: I9592e0b5b3ba782fb9f9315fea16163328e204f7
Reviewed-on: https://go-review.googlesource.com/17080
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-20 19:56:27 +00:00
Robert Griesemer
7218b79f23 cmd/compile: match markdcl and popdcl even in case of errors
Change-Id: I22a8a233bc157fa09cd0283fcd4bc14d90faed70
Reviewed-on: https://go-review.googlesource.com/17066
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-20 19:56:11 +00:00
Ian Lance Taylor
f4ccddddae test: add another test that gccgo failed to compile
Change-Id: Ife9e019063473bb0a976cfef4b6e78d951fcb09e
Reviewed-on: https://go-review.googlesource.com/17081
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-20 13:31:30 +00:00
Robert Griesemer
fe762b6466 cmd/compile/internal/gc: better error message for parenthesized go/defer exprs
Change-Id: Ie24d56422ae2196198a6c306716fa867c1442d6e
Reviewed-on: https://go-review.googlesource.com/17043
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:26:07 +00:00
Robert Griesemer
5500d46914 cmd/compile/internal/gc: fix incorrect parsing of &(T{}) when followed by {
Handling of &(T{}) assumed that the parser would not introduce ()'s.

Also: Better comments around handling of OPAREN syntax tree optimization.

Fixes #13261.

Change-Id: Ifc5047a0448f5e7d74cd42f6608b87dcc9c2f2fb
Reviewed-on: https://go-review.googlesource.com/17040
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:25:48 +00:00
Robert Griesemer
1a111ea2c7 cmd/compile/internal/gc: fix parsing of <-x (recv op vs recv-only chan)
Also:
- better error messages in some cases
- factored out function to produce syntax error at given line number

Fixes #13273.

Change-Id: I0192a94731cc23444680a26bd0656ef663e6da0b
Reviewed-on: https://go-review.googlesource.com/16992
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:22:56 +00:00
Russ Cox
918a2644f2 cmd/compile: fix Val vs Opt collision
Fixes #12686.

Change-Id: I7a9f49dbd1f60b1d0240de57787753b425f9548c
Reviewed-on: https://go-review.googlesource.com/17031
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 18:31:27 +00:00
Robert Griesemer
48a14663f8 test: add test case for issue #13248
Issue #13248 was fixed by https://go-review.googlesource.com/#/c/16930/.
This is the corresponding test case (original offending program).

Change-Id: I7c99783db74a5422704409cea7e5073094beadd3
Reviewed-on: https://go-review.googlesource.com/16973
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-17 01:05:51 +00:00
Robert Griesemer
0133d24c94 cmd/compile/internal/gc: don't ignore EOF in new parser
Fixes #13274.
Fixes #13272.

Change-Id: Ie67a2c4671ee2b49831898fff7677cd65d780942
Reviewed-on: https://go-review.googlesource.com/16972
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-17 01:05:39 +00:00
Robert Griesemer
a20556bf56 cmd/compile/internal/gc: correctly use internal call to error reporting
Fixes #13266.

Change-Id: I31da922e0599989e52acf346374c2077b157ebb7
Reviewed-on: https://go-review.googlesource.com/16971
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-17 01:05:07 +00:00
Robert Griesemer
fbe855ba29 test: fix test case
Issue introduced by https://go-review.googlesource.com/#/c/16920/ .

TBR=rsc

Change-Id: I2a0e0c81f641f869568230837c566913f6538f37
Reviewed-on: https://go-review.googlesource.com/16990
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-11-16 23:49:54 +00:00
Russ Cox
2c11164db5 cmd/compile: fix value range check for complex constants
Fixes #11590.

Change-Id: I4144107334604a2cc98c7984df3b5d4cde3d30af
Reviewed-on: https://go-review.googlesource.com/16920
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:48:47 +00:00
Russ Cox
292ad59291 cmd/compile: do not emit args_stackmap for func _
Fixes #11699.

Change-Id: I01bf506d76260bcdf828bbde52791e328aa441a5
Reviewed-on: https://go-review.googlesource.com/16921
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:38:52 +00:00
Russ Cox
247959d9b8 cmd/compile: reject identifiers beginning with non-ASCII digit
Fixes #11359.

Change-Id: I0fdfa410939f7e42020cbb19d74a67e1cc3cd610
Reviewed-on: https://go-review.googlesource.com/16919
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:38:42 +00:00
Robert Griesemer
b569b87ca1 cmd/compile/internal/gc: recursive-descent parser
This is a translation of the yacc-based parser with adjustements
to make the grammar work for a recursive-descent parser followed
by cleanups and simplifications.

The yacc actions were mostly literally copied for correctness
with better temporary names.

A few of the syntax tests were adjusted for slightly different
error messages (it is very difficult to match the yacc-based
error messages in all cases, and sometimes the new parser could
produce better errors).

The new parser is enabled by default.
To switch back to the yacc-based parser, set -oldparser.
To hardwire the switch back, uncomment "oldparser = 1" in lex.go.

- passes all.bash
- ~18% reduced parse time per file on average for make.bash
- ~3% reduced compile time for building cmd/compile

Change-Id: Icb5651bb9d8b9f66261762d2c94a03793050d4ce
Reviewed-on: https://go-review.googlesource.com/16665
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-13 14:53:57 +00:00
Michael Hudson-Doyle
c1b6e392f5 cmd/internal/obj, cmd/link, runtime: increase stack limit to accommodate larger frames on ppc64x
Larger stack frames mean nosplit functions use more stack and so the limit
needs to increase.

The change to test/nosplit.go is a bit ugly but I can't really think of a
way to make it nicer.

Change-Id: I2616b58015f0b62abbd62951575fcd0d2d8643c2
Reviewed-on: https://go-review.googlesource.com/16504
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 22:32:16 +00:00
Austin Clements
a9ca2137aa test: really force heap profile update in heapsampling.go
The heap profile is only guaranteed to be up-to-date after two GC
cycles, so force two GCs instead of just one.

Updates #13098.

Change-Id: I4fb9287b698f4a3b90b8af9fc6a2efb3b082bfe5
Reviewed-on: https://go-review.googlesource.com/16848
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-11-12 18:32:13 +00:00
Austin Clements
b5a0c67fcc test: force heap profile update in heapsampling.go test
The heapsampling.go test occasionally fails on some architectures
because it finds zero heap samples in main.alloc. This happens because
the byte and object counts are only updated at a GC. Hence, if a GC
happens part way through allocInterleaved, but then doesn't happen
after we start calling main.alloc, checkAllocations will see buckets
for the lines in main.alloc (which are created eagerly), but the
object and byte counts will be zero.

Fix this by forcing a GC to update the profile before we collect it.

Fixes #13098.

Change-Id: Ia7a9918eea6399307f10499dd7abefd4f6d13cf6
Reviewed-on: https://go-review.googlesource.com/16846
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-11-12 16:58:52 +00:00
Yao Zhang
15676b51a5 test: fix nosplit.go, fixedbugs/issue11656.go and skip two tests for mips64{,le}
Skip fixedbugs/issue10607.go because external linking is not supported
yet.

Skip nilptr3.go because of issue #9058 (same as ppc64).

Change-Id: Ib3dfbd9a03ee4052871cf57c74b3cc5e745e1f80
Reviewed-on: https://go-review.googlesource.com/14461
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-12 04:52:31 +00:00
Keith Randall
e410a527b2 runtime: simplify chan ops, take 2
This change is the same as CL #9345 which was reverted,
except for a small bug fix.

The only change is to the body of sendDirect and its callsite.
Also added a test.

The problem was during a channel send operation.  The target
of the send was a sleeping goroutine waiting to receive.  We
basically do:
1) Read the destination pointer out of the sudog structure
2) Copy the value we're sending to that destination pointer
Unfortunately, the previous change had a goroutine suspend
point between 1 & 2 (the call to sendDirect).  At that point
the destination goroutine's stack could be copied (shrunk).
The pointer we read in step 1 is no longer valid for step 2.

Fixed by not allowing any suspension points between 1 & 2.
I suspect the old code worked correctly basically by accident.

Fixes #13169

The original 9345:

This change removes the retry mechanism we use for buffered channels.
Instead, any sender waking up a receiver or vice versa completes the
full protocol with its counterpart.  This means the counterpart does
not need to relock the channel when it wakes up.  (Currently
buffered channels need to relock on wakeup.)

For sends on a channel with waiting receivers, this change replaces
two copies (sender->queue, queue->receiver) with one (sender->receiver).
For receives on channels with a waiting sender, two copies are still required.

This change unifies to a large degree the algorithm for buffered
and unbuffered channels, simplifying the overall implementation.

Fixes #11506

Change-Id: I57dfa3fc219cffa4d48301ee15fe5479299efa09
Reviewed-on: https://go-review.googlesource.com/16740
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-08 23:20:25 +00:00
Keith Randall
4b7d5f0b94 runtime: memmove/memclr pointers atomically
Make sure that we're moving or zeroing pointers atomically.
Anything that is a multiple of pointer size and at least
pointer aligned might have pointers in it.  All the code looks
ok except for the 1-pointer-sized moves.

Fixes #13160
Update #12552

Change-Id: Ib97d9b918fa9f4cc5c56c67ed90255b7fdfb7b45
Reviewed-on: https://go-review.googlesource.com/16668
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-07 02:42:12 +00:00
Keith Randall
ffb20631fc runtime: teach peephole optimizer that duffcopy clobbers X0
Duffcopy now uses X0, as of 5cf281a.  Teach the peephole
optimizer that duffcopy clobbers X0 so that it does not
rename registers use X0 across the duffcopy instruction.

Fixes #13171

Change-Id: I389cbf1982cb6eb2f51e6152ac96736a8589f085
Reviewed-on: https://go-review.googlesource.com/16715
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
2015-11-06 15:11:42 +00:00
Michael Hudson-Doyle
10c0753761 cmd/internal/obj/ppc64: fix assembly of SRADCC with immediate
sradi and sradi. hide the top bit of their immediate argument apart from the
rest of it, but the code only handled the sradi case.

I'm pretty sure this is the only instruction missing (a couple of the rotate
instructions encode their immediate the same way but their handling looks OK).

This fixes the failure of "GOARCH=amd64 ~/go/bin/go install -v runtime" as
reported in the bug.

Fixes #11987

Change-Id: I0cdefcd7a04e0e8fce45827e7054ffde9a83f589
Reviewed-on: https://go-review.googlesource.com/16710
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-05 22:54:21 +00:00
Dmitry Vyukov
bf606094ee runtime: fix finalization and profiling of tiny allocations
Handling of special records for tiny allocations has two problems:
1. Once we queue a finalizer we mark the object. As the result any
   subsequent finalizers for the same object will not be queued
   during this GC cycle. If we have 16 finalizers setup (the worst case),
   finalization will take 16 GC cycles. This is what caused misbehave
   of tinyfin.go. The actual flakiness was caused by the fact that fing
   is asynchronous and don't always run before the check.
2. If a tiny block has both finalizer and profile specials,
   it is possible that we both queue finalizer, preserve the object live
   and free the profile record. As the result heap profile can be skewed.

Fix both issues by analyzing all special records for a single object at once.

Also, make tinyfin test stricter and remove reliance on real time.

Also, add a test for the problem 2. Currently heap profile missed about
a half of live memory.

Fixes #13100

Change-Id: I9ae4dc1c44893724138a4565ca5cae29f2e97544
Reviewed-on: https://go-review.googlesource.com/16591
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
2015-11-03 18:57:18 +00:00
Todd Neal
e3e0122ae2 test: use go:noinline consistently
Replace various implementations of inlining prevention with
"go:noinline"

Change-Id: Iac90895c3a62d6f4b7a6c72e11e165d15a0abfa4
Reviewed-on: https://go-review.googlesource.com/16510
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-03 02:01:34 +00:00
Brad Fitzpatrick
d2fa937a21 test: update tinyfin test
* use new(int32) to be pedantic about documented SetFinalizer rules:
  "The argument x must be a pointer to an object allocated by calling
  new or by taking the address of a composite literal"

* remove the amd64-only restriction. The GC is fully precise everywhere
  now, even on 32-bit. (keep the gccgo restriction, though)

* remove a data race (perhaps the actual bug) and use atomic.LoadInt32
  for the final check. The race detector is now happy, too.

Updates #13100

Change-Id: I8d05c0ac4f046af9ba05701ad709c57984b34893
Reviewed-on: https://go-review.googlesource.com/16535
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-02 16:08:33 +00:00
Ian Lance Taylor
a4fb8c13db test: add gcc6798, valid code that caused gccgo to crash
Change-Id: I288bd3091ea81db7b616747cbec8958a31d98b7e
Reviewed-on: https://go-review.googlesource.com/16532
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-01 21:17:01 +00:00
Brad Fitzpatrick
7c167f2708 test: disable flaky heapsampling test for now
Flaky tests do more harm than good.

Updates #13098

Change-Id: I179ed810b49bbb96c8df462bfa20b70231b26772
Reviewed-on: https://go-review.googlesource.com/16521
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-30 20:48:03 +00:00
Todd Neal
a92543e1a1 cmd/compile: add support for a go:noinline directive
Some tests need to disable inlining of a function.  It's currently done
in one of a few ways (adding a function call, an empty switch, or a
defer).  Add support for a less fragile 'go:noinline' directive that
prevents inlining.

Fixes #12312

Change-Id: Ife444e13361b4a927709d81aa41e448f32eec8d4
Reviewed-on: https://go-review.googlesource.com/13911
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-10-29 23:16:27 +00:00
acanino
b60c8203ea cmd/compile: "invalid variable name x in type switch", where x is a name of a constant
Small fix: looks like a short variable declaration with a type switch
checks to make sure the variable used had valid shape (ONAME, OTYPE, or
ONONAME) and rejects everything else. Then a new variable is declared.
If the symbol contained in the declaration was a named OLITERAL (still a
valid identifier obviously) it would be rejected, even though a new
variable would have been declared.

Fix adds this case to the check.

Added a test case from issue12413.

Fixes #12413

Change-Id: I150dadafa8ee5612c867d58031027f2dca8c6ebc
Reviewed-on: https://go-review.googlesource.com/15760
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-21 04:21:16 +00:00
Robert Griesemer
76285213b8 cmd/compile/internal/gc: there are no -0 floating-point constants
Fixes #12577.

Change-Id: Id469cd92f5f9436b0ef948ee1a252ed1842bc7aa
Reviewed-on: https://go-review.googlesource.com/16133
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-20 22:11:11 +00:00
Matthew Dempsky
67722fea50 cmd/compile/internal/gc: reject invalid unsafe.Sizeof([0]byte{}[0])
Apply static bounds checking logic during type checking even to
zero-element arrays, but skip synthesized OINDEX nodes that the
compiler has asserted are within bounds (such as the ones generated
while desugaring ORANGE nodes).  This matches the logic in walkexpr
that also skips static bounds checking when Bounded is true.

Passes toolstash/buildall.

Fixes #12944.

Change-Id: I14ba03d71c002bf969d69783bec8d1a8e10e7d75
Reviewed-on: https://go-review.googlesource.com/15902
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-15 20:56:58 +00:00
Didier Spezia
cb0e98b833 cmd/compile: fix some C to Go translation leftovers
Following the C to Go translation, some useless variables
were left in the code. In fmt.go, this was harmless.
In lex.go, it broke the error message related to
non-canonical import paths.

Fix it, and remove the useless variables.

The added test case is ignored in the go/types tests, since
the behavior of the non-canonical import path check seems
to be different.

Fixes #11362

Change-Id: Ic9129139ede90357dc79ebf167af638cf44536fa
Reviewed-on: https://go-review.googlesource.com/15580
Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com>
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-08 01:51:24 +00:00
Ian Lance Taylor
449cc06e98 test: adjust gccgo expected import errors
Update two tests for the recently submitted gccgo change
https://golang.org/cl/14259.

Change-Id: Ib18bc87ea512074aa91fd4096d0874b72e2243e5
Reviewed-on: https://go-review.googlesource.com/15493
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-10-07 14:37:44 +00:00
Shenghou Ma
48b1e6bc97 test: gofmt fixedbugs/issue10975.go
Change-Id: I772d1bc3e394cdd707f210f2aaff77100d299e24
Reviewed-on: https://go-review.googlesource.com/15380
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-06 06:56:11 +00:00
Michael Hudson-Doyle
710b9ad617 cmd/compile/internal/ppc64: fix the epilogue for non-leaf generated methods
This lets us re-enable duffzero.

Fixes #12108

Change-Id: Iefd24d26eaa56067caa2c29ff99cd20a42d8714a
Reviewed-on: https://go-review.googlesource.com/14937
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-06 03:34:13 +00:00
Raul Silvera
27ee719fb3 pprof: improve sampling for heap profiling
The current heap sampling introduces some bias that interferes
with unsampling, producing unexpected heap profiles.
The solution is to use a Poisson process to generate the
sampling points, using the formulas described at
https://en.wikipedia.org/wiki/Poisson_process

This fixes #12620

Change-Id: If2400809ed3c41de504dd6cff06be14e476ff96c
Reviewed-on: https://go-review.googlesource.com/14590
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-05 08:15:09 +00:00
David Chase
f7a39a54e9 cmd/compile: escape analysis, don't always escape variadic args
Turns out the summary information for the ... args was
already correctly computed, all that lacked was to make
use of it and correct tests that documented our prior
deficiencies.

Fixes #12006

Change-Id: Ie8adfab7547f179391d470679598f0904aabf9f7
Reviewed-on: https://go-review.googlesource.com/15200
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-10-04 20:45:35 +00:00