}
func (g *irgen) typeDecl(out *ir.Nodes, decl *syntax.TypeDecl) {
+ // Set the position for any error messages we might print (e.g. too large types).
+ base.Pos = g.pos(decl)
assert(g.curDecl == "")
// Set g.curDecl to the type name, as context for the type params declared
// during types2-to-types1 translation if this is a generic type.
func (g *irgen) varDecl(out *ir.Nodes, decl *syntax.VarDecl) {
pos := g.pos(decl)
+ // Set the position for any error messages we might print (e.g. too large types).
+ base.Pos = pos
names := make([]*ir.Name, len(decl.NameList))
for i, name := range decl.NameList {
names[i], _ = g.def(name)
CheckSize(t.Elem())
- // make fake type to check later to
- // trigger channel argument check.
+ // Make fake type to trigger channel element size check after
+ // any top-level recursive type has been completed.
t1 := NewChanArgs(t)
CheckSize(t1)
case TCHANARGS:
t1 := t.ChanArgs()
CalcSize(t1) // just in case
+ // Make sure size of t1.Elem() is calculated at this point. We can
+ // use CalcSize() here rather than CheckSize(), because the top-level
+ // (possibly recursive) type will have been calculated before the fake
+ // chanargs is handled.
+ CalcSize(t1.Elem())
if t1.Elem().width >= 1<<16 {
- base.ErrorfAt(typePos(t1), "channel element type too large (>64kB)")
+ base.Errorf("channel element type too large (>64kB)")
}
w = 1 // anything will do
if t.Elem().width != 0 {
cap := (uint64(MaxWidth) - 1) / uint64(t.Elem().width)
if uint64(t.NumElem()) > cap {
- base.ErrorfAt(typePos(t), "type %L larger than address space", t)
+ base.Errorf("type %L larger than address space", t)
}
}
w = t.NumElem() * t.Elem().width
}
if PtrSize == 4 && w != int64(int32(w)) {
- base.ErrorfAt(typePos(t), "type %v too large", t)
+ base.Errorf("type %v too large", t)
}
t.width = w
"issue42058b.go", // types2 does not have constraints on channel element size
"issue48097.go", // go/types doesn't check validity of //go:xxx directives, and non-init bodyless function
"issue48230.go", // go/types doesn't check validity of //go:xxx directives
+ "issue49767.go", // go/types does not have constraints on channel element size
+ "issue49814.go", // go/types does not have constraints on array size
)
}
"issue42058b.go", // go/types does not have constraints on channel element size
"issue48097.go", // go/types doesn't check validity of //go:xxx directives, and non-init bodyless function
"issue48230.go", // go/types doesn't check validity of //go:xxx directives
+ "issue49767.go", // go/types does not have constraints on channel element size
+ "issue49814.go", // go/types does not have constraints on array size
)
}
--- /dev/null
+// errorcheck
+
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+func main() {
+ ch := make(chan struct{ v [65536]byte }) // ERROR "channel element type too large"
+ close(ch)
+}
--- /dev/null
+// errorcheck -G=3
+
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+// "must be integer" error is for 32-bit architectures
+type V [1 << 50]byte // ERROR "larger than address space|must be integer"
+
+var X [1 << 50]byte // ERROR "larger than address space|must be integer"
+
+func main() {}
"fixedbugs/issue28268.go", // types2 reports follow-on errors
"fixedbugs/issue31053.go", // types2 reports "unknown field" instead of "cannot refer to unexported field"
"fixedbugs/issue33460.go", // types2 reports alternative positions in separate error
- "fixedbugs/issue42058a.go", // types2 doesn't report "channel element type too large"
- "fixedbugs/issue42058b.go", // types2 doesn't report "channel element type too large"
"fixedbugs/issue4232.go", // types2 reports (correct) extra errors
"fixedbugs/issue4452.go", // types2 reports (correct) extra errors
"fixedbugs/issue4510.go", // types2 reports different (but ok) line numbers
"printbig.go", // large untyped int passed to print (32-bit)
"fixedbugs/bug114.go", // large untyped int passed to println (32-bit)
"fixedbugs/issue23305.go", // large untyped int passed to println (32-bit)
- "fixedbugs/bug385_32.go", // types2 doesn't produce missing error "type .* too large" (32-bit specific)
)
var g3Failures = setOf(
"escape4.go", // unified IR can inline f5 and f6; test doesn't expect this
"inline.go", // unified IR reports function literal diagnostics on different lines than -d=inlfuncswithclosures
- "fixedbugs/issue42284.go", // prints "T(0) does not escape", but test expects "a.I(a.T(0)) does not escape"
- "fixedbugs/issue7921.go", // prints "… escapes to heap", but test expects "string(…) escapes to heap"
- "typeparam/issue48538.go", // assertion failure, interprets struct key as closure variable
- "typeparam/issue47631.go", // unified IR can handle local type declarations
+ "fixedbugs/issue42284.go", // prints "T(0) does not escape", but test expects "a.I(a.T(0)) does not escape"
+ "fixedbugs/issue7921.go", // prints "… escapes to heap", but test expects "string(…) escapes to heap"
+ "typeparam/issue48538.go", // assertion failure, interprets struct key as closure variable
+ "typeparam/issue47631.go", // unified IR can handle local type declarations
+ "fixedbugs/issue42058a.go", // unified IR doesn't report channel element too large
+ "fixedbugs/issue42058b.go", // unified IR doesn't report channel element too large
+ "fixedbugs/issue49767.go", // unified IR doesn't report channel element too large
+ "fixedbugs/issue49814.go", // unified IR doesn't report array type too large
)
func setOf(keys ...string) map[string]bool {