]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: don't convert non-Go-constants to OLITERALs
authorKeith Randall <khr@google.com>
Mon, 26 Nov 2018 23:58:03 +0000 (15:58 -0800)
committerKeith Randall <khr@golang.org>
Tue, 27 Nov 2018 01:21:41 +0000 (01:21 +0000)
commiteb6c433eb38d9a0e9ecfcc1604f9ff8e035768f6
tree97e1a0e57abe40a2afecdc27ab1e0d89058b523d
parent3f9efe750058308bc499c5eb22bc84193fedb6b3
cmd/compile: don't convert non-Go-constants to OLITERALs

Don't convert values that aren't Go constants, like
uintptr(unsafe.Pointer(nil)), to a literal constant. This avoids
assuming they are constants for things like indexing, array sizes,
case duplication, etc.

Also, nil is an allowed duplicate in switches. CTNILs aren't Go constants.

Fixes #28078
Fixes #28079

Change-Id: I9ab8af47098651ea09ef10481787eae2ae2fb445
Reviewed-on: https://go-review.googlesource.com/c/151320
Run-TryBot: Keith Randall <khr@golang.org>
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/swt.go
src/cmd/compile/internal/gc/typecheck.go
test/fixedbugs/issue28078.go [new file with mode: 0644]
test/fixedbugs/issue28079a.go [new file with mode: 0644]
test/fixedbugs/issue28079b.go [new file with mode: 0644]
test/fixedbugs/issue28079c.go [new file with mode: 0644]