diff options
author | Dan Scales <danscales@google.com> | 2021-08-24 15:34:52 -0700 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2021-08-25 15:30:19 +0000 |
commit | 099b819085e12ca45ac184cab5afb82538bec472 (patch) | |
tree | b580d10b26a2e3060acc4c5572756e036022f92a /test | |
parent | e1fcf8857e1b3e076cc3a6fad1860afe0d6c2ca6 (diff) | |
download | go-099b819085e12ca45ac184cab5afb82538bec472.tar.gz go-099b819085e12ca45ac184cab5afb82538bec472.zip |
cmd/compile: fix CheckSize() calculation for -G=3 and stencils
Because the Align/Width of pointer types are always set when created,
CalcSize() never descends past a pointer. Therefore, we need to do
CheckSize() at every level when creating type. We need to do this for
types creates by types2-to-types1 conversion and also by type
substitution (mostly for stenciling). We also need to do
Defer/ResumeCheckSize() at the top level in each of these cases to deal
with potentially recursive types.
These changes fix issue #47929 and also allow us to remove the
special-case CheckSize() call that causes the problem for issue #47901.
Fixes #47901
Fixes #47929
Change-Id: Icd8192431c145009cd6df2f4ade6db7da0f4dd3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/344829
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/typeparam/issue47901.go | 21 | ||||
-rw-r--r-- | test/typeparam/issue47929.go | 29 |
2 files changed, 50 insertions, 0 deletions
diff --git a/test/typeparam/issue47901.go b/test/typeparam/issue47901.go new file mode 100644 index 0000000000..cd07973011 --- /dev/null +++ b/test/typeparam/issue47901.go @@ -0,0 +1,21 @@ +// run -gcflags=-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 + +type Chan[T any] chan Chan[T] + +func (ch Chan[T]) recv() Chan[T] { + return <-ch +} + +func main() { + ch := Chan[int](make(chan Chan[int])) + go func() { + ch <- make(Chan[int]) + }() + ch.recv() +} diff --git a/test/typeparam/issue47929.go b/test/typeparam/issue47929.go new file mode 100644 index 0000000000..a5636f2c7b --- /dev/null +++ b/test/typeparam/issue47929.go @@ -0,0 +1,29 @@ +// compile -G=3 -p=p + +// 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 v4 + +var sink interface{} + +//go:noinline +func Do(result, body interface{}) { + sink = &result +} + +func DataAction(result DataActionResponse, body DataActionRequest) { + Do(&result, body) +} + +type DataActionRequest struct { + Action *interface{} +} + +type DataActionResponse struct { + ValidationErrors *ValidationError +} + +type ValidationError struct { +} |