mirror of
https://github.com/golang/go
synced 2024-11-22 01:04:40 -07:00
cmd/gc: mark broken type declarations as broken.
This fixes a spurious 'invalid recursive type' error, and stops the compiler from emitting errors on uses of the invalid type. Fixes #3766. R=golang-dev, dave, minux.ma, rsc CC=golang-dev https://golang.org/cl/6443100
This commit is contained in:
parent
e29659b3c3
commit
85ce3c7241
@ -2715,6 +2715,7 @@ typecheckdeftype(Node *n)
|
|||||||
typecheck(&n->ntype, Etype);
|
typecheck(&n->ntype, Etype);
|
||||||
if((t = n->ntype->type) == T) {
|
if((t = n->ntype->type) == T) {
|
||||||
n->diag = 1;
|
n->diag = 1;
|
||||||
|
n->type = T;
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
if(n->type == T) {
|
if(n->type == T) {
|
||||||
|
@ -1,38 +1,11 @@
|
|||||||
// run
|
// errorcheck
|
||||||
|
|
||||||
// Copyright 2012 The Go Authors. All rights reserved.
|
// Copyright 2012 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Issue 3835: 8g tries to optimize arithmetic involving integer
|
|
||||||
// constants, but can run out of registers in the process.
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G int
|
type T x.T // ERROR "undefined"
|
||||||
|
|
||||||
func foo() int {
|
// bogus "invalid recursive type"
|
||||||
return a + 1 + b + 2 + c + 3 + d + 4 + e + 5 + f + 6 + g + 7 + h + 8 + i + 9 + j + 10 +
|
|
||||||
k + 1 + l + 2 + m + 3 + n + 4 + o + 5 + p + 6 + q + 7 + r + 8 + s + 9 + t + 10 +
|
|
||||||
u + 1 + v + 2 + w + 3 + x + 4 + y + 5 + z + 6 + A + 7 + B + 8 + C + 9 + D + 10 +
|
|
||||||
E + 1 + F + 2 + G + 3
|
|
||||||
}
|
|
||||||
|
|
||||||
func bar() int8 {
|
|
||||||
var (
|
|
||||||
W int16
|
|
||||||
X int32
|
|
||||||
Y int32
|
|
||||||
Z int32
|
|
||||||
)
|
|
||||||
return int8(W+int16(X+3)+3) * int8(Y+3+Z*3)
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
if foo() == 0 {
|
|
||||||
panic("foo")
|
|
||||||
}
|
|
||||||
if bar() == 0 {
|
|
||||||
panic("bar")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user