1
0
mirror of https://github.com/golang/go synced 2024-10-03 12:41:21 -06:00
Commit Graph

1633 Commits

Author SHA1 Message Date
Rémy Oudompheng
eb4f4d16ae cmd/5g, cmd/6g: pass the full torture test.
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
2012-11-12 23:56:11 +01:00
Ian Lance Taylor
3e50372f1f test: change index.go to test size of int, not GOARCH == "amd64"
Fixes the test to work correctly on other platforms with
64-bit ints, like Alpha.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6822099
2012-11-08 15:43:28 -08:00
Russ Cox
761830f481 cmd/gc: fix export of inlined function body with type guard
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
2012-11-08 16:07:05 -05:00
Ian Lance Taylor
6694f14b67 test: run some more tests by default
R=golang-dev, remyoudompheng, iant, rsc
CC=golang-dev
https://golang.org/cl/6833043
2012-11-08 09:04:27 -08:00
Rémy Oudompheng
c208a3a263 cmd/gc: fix internal compiler error with broken structs.
Fixes #4359.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6834043
2012-11-07 23:09:01 +01:00
Rémy Oudompheng
7c0cbbfa18 cmd/6g, cmd/8g: mark used registers in indirect addressing.
Fixes #4094.
Fixes #4353.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6810090
2012-11-07 21:36:15 +01:00
Ian Lance Taylor
e08008e8c5 test: run index test by default
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
2012-11-07 12:33:54 -08:00
Russ Cox
71282131a1 cmd/gc: fix escape analysis bug
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
2012-11-07 15:15:21 -05:00
Ian Lance Taylor
f8614a6645 reflect: fix test of whether structs are identical
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
2012-11-07 11:55:35 -08:00
Russ Cox
cb856adea9 cmd/gc: annotate local variables with unique ids for inlining
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
2012-11-07 09:59:19 -05:00
Rémy Oudompheng
1e233ad075 cmd/6g: fix use of large integers as indexes or array sizes.
A check for smallintconst was missing before generating the
comparisons.

Fixes #4348.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6815088
2012-11-06 22:53:57 +01:00
Ian Lance Taylor
433b2f17ee test: fix index.go to pass with recent index checks
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
2012-11-06 11:38:16 -08:00
Rémy Oudompheng
0b2353edcb cmd/5g, cmd/6g: fix out of registers with array indexing.
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
2012-11-02 07:50:59 +01:00
Rémy Oudompheng
8d95245d0d cmd/gc: fix incomplete export data when inlining with local variables.
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
2012-11-01 19:06:52 +01:00
Rémy Oudompheng
76500b14a1 cmd/gc: fix inlining bug with local variables.
Fixes #4323.

R=rsc, lvd, golang-dev
CC=golang-dev
https://golang.org/cl/6815061
2012-11-01 18:59:32 +01:00
Ian Lance Taylor
7dc1182c27 test: match gccgo error messages for bug358.go
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
2012-10-30 20:56:32 -07:00
Luuk van Dijk
507fcf37d2 cmd/gc: escape analysis to track flow of in to out parameters.
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
2012-10-29 13:38:21 +01:00
Rémy Oudompheng
335eef85c3 cmd/6g: fix crash in cgen_bmul.
Used to print:
../test/torture.go:116: internal compiler error: bad width: 0463 (../test/torture.go:116) MOVB    ,BX (0, 8)

R=nigeltao, rsc
CC=golang-dev
https://golang.org/cl/6736068
2012-10-26 00:29:44 +02:00
Daniel Morsing
48af64b295 cmd/gc: Mark use of builtin functions as calls.
Fixes #4097.

R=rsc
CC=golang-dev, gri
https://golang.org/cl/6749059
2012-10-22 19:14:30 +02:00
Rémy Oudompheng
319131f295 cmd/gc: fix inlining bug for composite literals in if statements.
Fixes #4230.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6640056
2012-10-22 08:38:23 +02:00
Daniel Morsing
d7a3407e3d cmd/gc: fix confusing error when using variable as type.
Fixes #3783.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6737053
2012-10-21 20:50:31 +02:00
Daniel Morsing
a7a3fe7238 cmd/gc: Friendlier errors on oversized arrays.
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
2012-10-21 19:22:51 +02:00
Rémy Oudompheng
a4682348c2 cmd/gc: don't squash complex literals when inlining.
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
2012-10-17 20:33:44 +02:00
Rémy Oudompheng
7e144bcab0 cmd/5g, cmd/6g, cmd/8g: fix out of registers.
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
2012-10-16 07:22:33 +02:00
Rémy Oudompheng
dda1b560ec test: convert tests to run.go whenever possible.
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
2012-10-10 22:35:27 +02:00
David Symonds
f8b5838123 testing: change -test.benchtime to a flag.Duration.
Fixes #3902.

R=golang-dev, minux.ma, rsc, r
CC=golang-dev
https://golang.org/cl/6611059
2012-10-09 08:57:29 +11:00
Daniel Morsing
c81293ada7 test: Make run.go's errorcheck behave like testlib.
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
2012-10-08 16:36:45 +02:00
Rémy Oudompheng
46bce2ac27 test: convert more tests to rundir/compiledir conventions
Update #4139.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6609051
2012-10-07 23:22:01 +02:00
Rémy Oudompheng
5497787d35 test/testlib: don't forget stderr for rundircmpout.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6620071
2012-10-07 23:14:20 +02:00
Rémy Oudompheng
9844e4cd7c test: correct type in declbad.go
The test is not about type mismatches and it causes
an extra error to appear.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6614062
2012-10-07 21:52:57 +02:00
Russ Cox
c4c4b3b467 test/bench/shootout: match gcc architecture to GOARCH
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
2012-10-07 15:49:56 -04:00
Shenghou Ma
e824656907 test/run.go: use correct executable filename on Windows, fix build
R=golang-dev, daniel.morsing
CC=golang-dev
https://golang.org/cl/6624060
2012-10-08 01:54:56 +08:00
Rémy Oudompheng
d9953c9dde test: use rundir and errorcheckdir for a few more tests.
Update #4139.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6620070
2012-10-07 18:37:05 +02:00
Rémy Oudompheng
892fa3ae6c cmd/gc: replace "typechecking loop" by nicer errors in some cases.
For issue 3757:
BEFORE:  test/fixedbugs/bug463.go:12: typechecking loop involving a
             test/fixedbugs/bug463.go:12 a
             test/fixedbugs/bug463.go:12 <node DCLCONST>
AFTER:   test/fixedbugs/bug463.go:12: constant definition loop
             test/fixedbugs/bug463.go:12: a uses a

For issue 3937:
BEFORE: test/fixedbugs/bug464.go:12: typechecking loop involving foo
            test/fixedbugs/bug464.go:12 <T>
            test/fixedbugs/bug464.go:12 foo
            test/fixedbugs/bug464.go:12 <node DCLFUNC>
AFTER:  test/fixedbugs/bug464.go:12: foo is not a type

Fixes #3757.
Fixes #3937.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6614058
2012-10-07 17:35:21 +02:00
Daniel Morsing
87c35d8df1 cmd/gc: Don't accept qualified names as literal keys
Fixes #4067.

R=golang-dev, minux.ma, dave, rsc
CC=golang-dev
https://golang.org/cl/6622056
2012-10-07 16:47:53 +02:00
Akshat Kumar
51e8fe5b1b cmd/gc: don't dereference a nil Type pointer in widstruct
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
2012-10-07 14:11:59 +08:00
Daniel Morsing
a45777fe99 cmd/gc: Don't export embedded builtins
Fixes #4124.

R=golang-dev, dave, minux.ma, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6543057
2012-10-07 06:53:57 +02:00
Rémy Oudompheng
0b2ca9e62f cmd/gc: avoid clobbering the AST in cgen_callmeth.
It confused the detection of init loops when involving
method calls.

Fixes #3890.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6620067
2012-10-07 00:52:40 +02:00
Rémy Oudompheng
46fcfdaa7d cmd/6g: fix out of registers when chaining integer divisions.
Fixes #4201.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6622055
2012-10-07 00:30:29 +02:00
Rémy Oudompheng
94acfde22e cmd/gc: make rnd() more 64-bit-friendly.
Fixes #4200.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6619057
2012-10-07 00:29:55 +02:00
Rémy Oudompheng
782464aea5 runtime: fix a panic when growing zero-width-element slices.
Fixes #4197.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6611056
2012-10-06 12:05:52 +02:00
Daniel Morsing
ebb0e5db75 test: Add rundir, rundircmpout and errorcheckdir commands to testlib and run.go
rundir will compile each file in the directory in lexicographic order, link the last file as the main package and run the resulting program. rundircmpout is an related command, that will compare the output of the program to an corresponding .out file

errorcheckdir will compile each file in a directory in lexicographic order, running errorcheck on each file as it compiles. All compilations are assumed to be successful except for the last file. However, If a -0 flag is present on the command, the last compilation will also be assumed successful

This CL also includes a small refactoring of run.go. It was getting unwieldy and the meaning of the run commands was hidden behind argument line formatting.

Fixes #4058.

R=rsc, minux.ma, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/6554071
2012-10-06 09:23:31 +02:00
Rémy Oudompheng
3a4e156ae1 cmd/5g: fix out of registers in nested calls, add compiler torture test.
R=golang-dev, dave, daniel.morsing, rsc
CC=golang-dev, remy
https://golang.org/cl/6586072
2012-10-05 23:30:49 +02:00
Rémy Oudompheng
4bb75cd9ad test/fixedbugs: forgotten test cases for issues 3907 and 4156.
Update #3907.
Update #4156.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/6595044
2012-09-30 10:35:09 +02:00
Shenghou Ma
9a3bc51c81 test/fixedbugs/bug454.go: add a test for CL 6564052
Also mention that ignoring second blank identifier of range is required by the spec in the code.

   Fixes #4173.

R=daniel.morsing, remyoudompheng, r
CC=golang-dev
https://golang.org/cl/6594043
2012-09-29 23:23:56 +08:00
Ian Lance Taylor
6ed800c01d test: match gccgo error messages
const1.go:31:12: error: integer constant overflow
const1.go:31:12: error: integer constant overflow
const1.go:33:12: error: integer constant overflow
const1.go:33:12: error: integer constant overflow
const1.go:34:14: error: integer constant overflow
const1.go:35:17: error: integer constant overflow
const1.go:35:17: error: integer constant overflow
const1.go:35:17: error: integer constant overflow
const1.go:35:17: error: integer constant overflow
const1.go:35:17: error: integer constant overflow
const1.go:36:19: error: integer constant overflow
const1.go:37:15: error: integer constant overflow
const1.go:37:15: error: integer constant overflow
const1.go:37:24: error: integer constant overflow
const1.go:37:15: error: integer constant overflow
const1.go:37:15: error: integer constant overflow
const1.go:37:15: error: integer constant overflow
const1.go:37:24: error: integer constant overflow
const1.go:37:15: error: integer constant overflow
const1.go:38:12: error: integer constant overflow
const1.go:38:12: error: integer constant overflow
const1.go:38:12: error: integer constant overflow
const1.go:38:12: error: integer constant overflow
const1.go:41:20: error: integer constant overflow
const1.go:41:20: error: integer constant overflow
const1.go:42:20: error: integer constant overflow
const1.go:42:20: error: integer constant overflow
const1.go:44:28: error: integer constant overflow
const1.go:44:28: error: integer constant overflow
const1.go:45:14: error: integer constant overflow
const1.go:49:14: error: integer constant overflow
const1.go:50:14: error: integer constant overflow
const1.go:51:14: error: integer constant overflow
const1.go:54:23: error: integer constant overflow
const1.go:54:23: error: integer constant overflow
const1.go:54:23: error: integer constant overflow
const1.go:54:23: error: integer constant overflow
const1.go:56:14: error: integer constant overflow
const1.go:57:24: error: integer constant overflow
const1.go:57:24: error: integer constant overflow
const1.go:58:24: error: integer constant overflow
const1.go:58:24: error: integer constant overflow
const1.go:59:22: error: integer constant overflow
const1.go:59:22: error: integer constant overflow
const1.go:61:24: error: integer constant overflow
const1.go:62:20: error: division by zero
const1.go:65:19: error: floating point constant overflow
const1.go:65:19: error: floating point constant overflow
const1.go:66:28: error: floating point constant overflow
const1.go:66:28: error: floating point constant overflow
const1.go:67:19: error: floating point constant overflow
const1.go:67:19: error: floating point constant overflow
const1.go:68:19: error: division by zero
const1.go:33:14: error: integer constant overflow
const1.go:35:19: error: integer constant overflow
const1.go:42:22: error: integer constant overflow
const1.go:53:17: error: integer constant overflow
const1.go:55:14: error: integer constant overflow
const1.go:59:24: error: integer constant overflow
const1.go:69:20: error: expected integer type
const1.go:75:4: error: argument 1 has incompatible type (cannot use type int8 as type int)
const1.go:76:4: error: argument 1 has incompatible type (cannot use type int8 as type int)
const1.go:77:4: error: argument 1 has incompatible type (cannot use type uint8 as type int)
const1.go:79:4: error: argument 1 has incompatible type (cannot use type float32 as type int)
const1.go:80:4: error: argument 1 has incompatible type (cannot use type float64 as type int)
const1.go:81:4: error: floating point constant truncated to integer
const1.go:83:4: error: argument 1 has incompatible type (cannot use type float64 as type int)
const1.go:84:4: error: argument 1 has incompatible type (cannot use type string as type int)
const1.go:85:4: error: argument 1 has incompatible type (cannot use type bool as type int)
const1.go:88:7: error: const initializer cannot be nil

const2.go:14:8: error: expected ‘=’

const5.go:27:7: error: expression is not constant
const5.go:28:7: error: expression is not constant
const5.go:30:7: error: expression is not constant
const5.go:31:7: error: expression is not constant

ddd1.go:57:23: error: invalid use of ‘...’ in type conversion
ddd1.go:59:6: error: invalid use of ‘...’ in type conversion
ddd1.go:60:12: error: use of ‘[...]’ outside of array literal
ddd1.go:21:15: error: argument 1 has incompatible type
ddd1.go:22:10: error: argument 1 has incompatible type
ddd1.go:30:6: error: invalid use of ‘...’ with non-slice
ddd1.go:30:6: error: invalid use of ‘...’ with non-slice
ddd1.go:46:2: error: invalid use of %<...%> with builtin function
ddd1.go:47:2: error: invalid use of %<...%> with builtin function
ddd1.go:49:2: error: invalid use of %<...%> with builtin function
ddd1.go:50:6: error: invalid use of %<...%> with builtin function
ddd1.go:51:6: error: invalid use of %<...%> with builtin function
ddd1.go:53:6: error: invalid use of %<...%> with builtin function
ddd1.go:58:13: error: invalid use of %<...%> with builtin function
ddd1.go:20:10: error: floating point constant truncated to integer
ddd1.go:32:6: error: invalid use of ‘...’ calling non-variadic function

declbad.go:20:3: error: variables redeclared but no variable is new
declbad.go:38:3: error: variables redeclared but no variable is new
declbad.go:44:3: error: variables redeclared but no variable is new
declbad.go:51:3: error: variables redeclared but no variable is new
declbad.go:57:3: error: variables redeclared but no variable is new
declbad.go:63:3: error: variables redeclared but no variable is new
declbad.go:26:3: error: incompatible types in assignment (cannot use type float32 as type int)
declbad.go:32:3: error: incompatible types in assignment (cannot use type int as type float32)
declbad.go:44:3: error: incompatible types in assignment (different number of results)

fixedbugs/bug223.go:21:5: error: initialization expression for ‘m’ depends upon itself

fixedbugs/bug412.go:10:2: error: duplicate field name ‘x’

fixedbugs/bug413.go:11:5: error: initialization expression for ‘i’ depends upon itself

fixedbugs/bug416.go:13:1: error: method ‘X’ redeclares struct field name

fixedbugs/bug435.go:15:49: error: missing ‘)’
fixedbugs/bug435.go:15:2: error: reference to undefined name ‘bar’

fixedbugs/bug451.go:9:9: error: expected package

typeswitch3.go:39:9: error: no new variables on left side of ‘:=’
typeswitch3.go:24:2: error: impossible type switch case (type has no methods)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6560063
2012-09-28 08:30:30 -07:00
Rob Pike
4391abfb1d test/bench/shootout: new data after 64-bit ints for amd64
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6564046
2012-09-25 14:14:26 +10:00
Russ Cox
10ea6519e4 build: make int 64 bits on amd64
The assembly offsets were converted mechanically using
code.google.com/p/rsc/cmd/asmlint. The instruction
changes were done by hand.

Fixes #2188.

R=iant, r, bradfitz, remyoudompheng
CC=golang-dev
https://golang.org/cl/6550058
2012-09-24 20:57:01 -04:00
Russ Cox
54af752865 cmd/gc: fix escape analysis bug
Was not handling &x.y[0] and &x.y.z correctly where
y is an array or struct-valued field (not a pointer).

R=ken2
CC=golang-dev
https://golang.org/cl/6551059
2012-09-24 15:53:12 -04:00
Russ Cox
0d82e69811 test: prepare for 64-bit ints
Minor tweaks to avoid assuming that int is always 32 bits.

Update #2188.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6553062
2012-09-24 00:06:41 -04:00