]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: make bad Ctypes be only 0
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 10 Oct 2017 16:36:03 +0000 (17:36 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 10 Oct 2017 17:06:53 +0000 (17:06 +0000)
commitf14f7b31416ee655dc588eb3a1772a7a4be2a61c
treebb17c395fa509a66517b22152c2dab6152937992
parentd5a2925b7d8fd947c174967abdd5b5405cc2d53d
cmd/compile: make bad Ctypes be only 0

Before, -1 meant a node being nil or not an OLITERAL, and 0 meant an
OLITERAL missing a Val.

However, the use of this value was confusing and led to some issues,
such as swt.go checking for < 0 instead of <= 0, causing panics.

We never need to differentiate these two cases, so collapse both into 0.
To make it clear that negative values can no longer happen, make Ctype
an uint8.

With this change, we can now get rid of the two n.Type == nil checks
in swt.go added to fix a couple of these panics.

Thanks to Matthew Dempsky for spotting this inconsistency.

Fixes #22001.

Change-Id: I51c65a76f38a3e16788b6a3b57932dad3436dc7e
Reviewed-on: https://go-review.googlesource.com/69510
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/compile/internal/gc/const.go
src/cmd/compile/internal/gc/order.go
src/cmd/compile/internal/gc/swt.go