aboutsummaryrefslogtreecommitdiff
path: root/src/go
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-11-29 11:45:17 -0800
committerDan Scales <danscales@google.com>2021-12-02 20:49:56 +0000
commitbbe1be5c19f04816f5f9162c2be75351480c92a0 (patch)
tree77a06a421b902c83aa2bd920dc7169e437a0635d /src/go
parent3c6295d272d09e6c7be912510e4b62afc0ef8ffc (diff)
downloadgo-bbe1be5c19f04816f5f9162c2be75351480c92a0.tar.gz
go-bbe1be5c19f04816f5f9162c2be75351480c92a0.zip
cmd/compile: report channel size errors correctly for -G=3
First, we need to set base.Pos in varDecl() and typeDecl(), so it will be correct if we need to report type size errors while converting types. Changed error calls in types/sizes.go to use Errorf, not ErrorfAt, since we want to use base.Pos (which will set from t.Pos(), if that is available). Second, we need to add an extra call CalcSize(t1.Elem()) in the TCHANARGS case of CalcSize(). We can use CalcSize() rather than CheckSize(), since we know the top-level recursive type will have been calculated by the time we process the fake TCHANARGS type. In -G=0 mode, the size of the channel element has often been calculated because of some other processing (but not in the case of #49767). But in -G=3 mode, we just calculate sizes during the single noder2 pass, so we are more likely to have not gotten to calculating the size of the element yet, depending on the order of processing of the deferredTypeStack. Fixes the tests fixedbugs/issue{42058a,42058b}.go that were disabled for -G=3 mode. Had to add exceptions in stdlib_test.go for go/types and types2, because the types2 typechecker does not know about type size limits. Fixes #49814 Fixes #49771 Updates #49767 Change-Id: I77d058e8ceff68a58c4c386a8cf46799c54b04c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/367955 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/go')
-rw-r--r--src/go/types/stdlib_test.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/go/types/stdlib_test.go b/src/go/types/stdlib_test.go
index b0d7fdd3d9..c56e0ba428 100644
--- a/src/go/types/stdlib_test.go
+++ b/src/go/types/stdlib_test.go
@@ -196,6 +196,8 @@ func TestStdFixed(t *testing.T) {
"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
)
}