]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: add Type.WidthCalculated
authorJosh Bleecher Snyder <josharian@gmail.com>
Thu, 23 Mar 2017 18:29:37 +0000 (11:29 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 28 Mar 2017 18:06:09 +0000 (18:06 +0000)
commit8dafdb1be147f0cd5a2811c69ce6e27769f5e5f1
tree0fb91a02a6851e702ba4b11294352586ceb9f21b
parentf5c1926e93d4f383ee36d4c0351f2348440cbbe8
cmd/compile: add Type.WidthCalculated

Prior to this CL, Type.Width != 0 was the mark
of a Type whose Width had been calculated.
As a result, dowidth always recalculated
the width of struct{}.
This, combined with the prohibition on calculating
the width of a FuncArgsStruct and the use of
struct{} as a function argument,
meant that there were circumstances in which
it was forbidden to call dowidth on a type.
This inhibits refactoring to call dowidth automatically,
rather than explicitly.
Instead add a helper method, Type.WidthCalculated,
and implement as Type.Align > 0.
Type.Width is not a good candidate for tracking
whether the width has been calculated;
0 is a value type width, and Width is subject to
too much magic value game-playing.

For good measure, add a test for #11354.

Change-Id: Ie9a9fb5d924e7a2010c1904ae5e38ed4a38eaeb2
Reviewed-on: https://go-review.googlesource.com/38468
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/align.go
src/cmd/compile/internal/gc/type.go
test/fixedbugs/issue11354.go [new file with mode: 0644]