The compiler was confused when inlining a T.Method(f()) call
where f returns multiple values: support for this was marked
as TODO.
Variadic calls are not supported but are not inlined either.
Add a test preventively for that case.
Fixes#4167.
R=golang-dev, rsc, lvd
CC=golang-dev
https://golang.org/cl/6871043
Bools from comparisons can be assigned to all bool types, but this idealness would propagate through logical operators when the result should have been lowered to a non-ideal form.
Fixes#3924.
R=golang-dev, remyoudompheng, r, rsc, mtj
CC=golang-dev
https://golang.org/cl/6855061
The stack overflow checker in the linker uses the spadj field
to determine whether stack space will be large enough or not.
When spadj=0, the checker treats the function as a nosplit
and emits an error although the program is correct.
Also enable the stack checker in 8l.
Fixes#4316.
R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/6855088
The patch adds more cases to agenr to allocate registers later,
and makes 6g generate addresses for sgen in something else than
SI and DI. It avoids a complex save/restore sequence that
amounts to allocate a register before descending in subtrees.
Fixes#4207.
R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6817080
When exporting a body containing
x, ok := v.(Type)
the definition for Type was not being included, so when the body
was actually used, it would cause an "unknown type" compiler error.
Fixes#4370.
R=ken2
CC=golang-dev
https://golang.org/cl/6827064
Running this test via "bash run" uncovered three different
bugs (4344, 4348, 4353). We need to run it by default.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6832043
The code assumed that the only choices were EscNone, EscScope, and EscHeap,
so that it makes sense to set EscScope only if the current setting is EscNone.
Now that we have the many variants of EscReturn, this logic is false, and it was
causing important EscScopes to be ignored in favor of EscReturn.
Fixes#4360.
R=ken2
CC=golang-dev, lvd
https://golang.org/cl/6816103
The old code worked with gc, I assume because the linker
unified identical strings, but it failed with gccgo.
R=rsc
CC=gobot, golang-dev
https://golang.org/cl/6826063
Avoids problems with local declarations shadowing other names.
We write a more explicit form than the incoming program, so there
may be additional type annotations. For example:
int := "hello"
j := 2
would normally turn into
var int string = "hello"
var j int = 2
but the int variable shadows the int type in the second line.
This CL marks all local variables with a per-function sequence number,
so that this would instead be:
var int·1 string = "hello"
var j·2 int = 2
Fixes#4326.
R=ken2
CC=golang-dev
https://golang.org/cl/6816100
The compiler now gives an error for out of bounds constant
indexes for arrays, and for negative constant indexes for both
arrays and slices.
With this change the index.go test passes if CLs 6815085,
6815088, and 6812089 are committed.
R=golang-dev, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6810085
Compiling expressions like:
s[s[s[s[s[s[s[s[s[s[s[s[i]]]]]]]]]]]]
make 5g and 6g run out of registers. Such expressions can arise
if a slice is used to represent a permutation and the user wants
to iterate it.
This is due to the usual problem of allocating registers before
going down the expression tree, instead of allocating them in a
postfix way.
The functions cgenr and agenr (that generate a value to a newly
allocated register instead of an existing location), are either
introduced or modified when they already existed to allocate
the new register as late as possible, and sudoaddable is disabled
for OINDEX nodes so that igen/agenr is used instead.
Update #4207.
R=dave, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6733055
When local declarations needed unexported types, these could
be missing in the export data.
Fixes build with -gcflags -lll, except for exp/gotype.
R=golang-dev, rsc, lvd
CC=golang-dev
https://golang.org/cl/6813067
I fixed a bug in gccgo that was causing it to only give an
error for the first package that was imported and not used.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6813058
includes step 0: synthesize outparams, from 6600044
includes step 1,2: give outparams loopdepth 0 and verify unchanged results
generate esc:$mask tags, but still tie to sink if a param has mask != 0
from 6610054
adds final steps:
- have esccall generate n->escretval, a list of nodes the function results flow to
- use these in esccall and ORETURN/OAS2FUNC/and f(g())
- only tie parameters to sink if tag is absent, otherwise according to mask, tie them to escretval
R=rsc, bradfitz
CC=dave, gobot, golang-dev, iant, rsc
https://golang.org/cl/6741044
Someone new to the language may not know the connection between ints and arrays, which was the only thing that the previous error told you anything about.
Fixes#4256.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6739048
Since this patch changes the way complex literals are written
in export data, there are a few other glitches.
Fixes#4159.
R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6674047
This patch is enough to fix compilation of
exp/types tests but only passes a stripped down
version of the appripriate torture test.
Update #4207.
R=dave, nigeltao, rsc, golang-dev
CC=golang-dev
https://golang.org/cl/6621061
The other tests either need a complex procedure
or are architecture- or OS-dependent.
Update #4139.
R=golang-dev, daniel.morsing, iant
CC=golang-dev
https://golang.org/cl/6618062
testlib will complain about any unmatched errors left in errorchecks while run.go will not.
Fixes#4141.
R=golang-dev, minux.ma, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6614060
If we're benchmarking 8g, use gcc -m32.
If we're benchmarking 6g, use gcc -m64.
R=golang-dev, bradfitz, minux.ma, remyoudompheng
CC=golang-dev
https://golang.org/cl/6625061
The nil dereference in the next few lines doesn't seem
to cause a segmentation fault on Unix, but does seem
to halt the Go compiler.
The following is a test case:
>>>
package main
func mine(int b) int {
return b + 2
}
func main() {
mine()
c = mine()
}
<<<
Without this change only the following is caught:
typecheck.go:3: undefined: b
typecheck.go:4: undefined: b
with it, we catch all the errors:
typecheck.go:3: undefined: b
typecheck.go:4: undefined: b
typecheck.go:10: undefined: c
typecheck.go:10: cannot assign to c .
R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6542060