1
0
mirror of https://github.com/golang/go synced 2024-10-05 07:11:22 -06:00
go/src/cmd
Matthew Dempsky 27691fa467 cmd/compile: recognize !typedbool is typed
Adding the evconst(n) call for OANDAND and OOROR in
golang.org/cl/18262 was originally just to parallel the above iscmp
branch, but upon further inspection it seemed odd that removing it
caused test/fixedbugs/issue6671.go's

    var b mybool
    // ...
    b = bool(true) && true // ERROR "cannot use"

to start failing (i.e., by not emitting the expected "cannot use"
error).

The problem is that evconst(n)'s settrue and setfalse paths always
reset n.Type to idealbool, even for logical operators where n.Type
should preserve the operand type.  Adding the evconst(n) call for
OANDAND/OOROR inadvertantly worked around this by turning the later
evconst(n) call at line 2167 into a noop, so the "n.Type = t"
assignment at line 739 would preserve the operand type.

However, that means evconst(n) was still clobbering n.Type for ONOT,
so declarations like:

    const _ bool = !mybool(true)

were erroneously accepted.

Update #13821.

Change-Id: I18e37287f05398fdaeecc0f0d23984e244f025da
Reviewed-on: https://go-review.googlesource.com/18362
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-07 21:43:47 +00:00
..
addr2line cmd/addr2line: simplify windows test 2015-06-17 14:23:20 +00:00
api api: create go1.6.txt 2015-12-17 22:45:50 +00:00
asm cmd/internal/obj/x86: add support for TSX instructions 2015-11-26 16:39:00 +00:00
cgo cmd/cgo: gccgo support for cgoCheckPointer 2015-12-17 03:01:38 +00:00
compile cmd/compile: recognize !typedbool is typed 2016-01-07 21:43:47 +00:00
cover cmd/cover: allow part selection to be retained across page refreshes 2015-11-27 06:13:12 +00:00
dist cmd/dist: improve isGitRepo to handle git "worktree"s 2016-01-07 01:23:05 +00:00
doc cmd/doc: search the tree in breadth-first order 2015-12-10 18:08:16 +00:00
fix cmd/fix: add gotypes module 2015-07-17 01:47:14 +00:00
go cmd/go: for go get -insecure, skip TLS certificate checking 2016-01-07 01:22:59 +00:00
gofmt go/parser, go/types: report invalid else branch in if statements 2015-12-07 21:36:31 +00:00
internal cmd/compile: suppress export of Note field within exported bodies 2016-01-05 15:42:12 +00:00
link runtime: increase assumed stack size in externalthreadhandler 2016-01-07 19:40:32 +00:00
newlink cmd/internal/obj/mips: added support for GOARCH=mips64{,le} 2015-11-12 04:42:44 +00:00
nm all: extract "can I exec?" check from tests into internal/testenv 2015-06-16 18:07:36 +00:00
objdump cmd/objdump: skip TestDisasm* for mips64{,le} 2015-09-10 18:27:09 +00:00
pack all: extract "can I exec?" check from tests into internal/testenv 2015-06-16 18:07:36 +00:00
pprof cmd/pprof: fix scaling of "gigabyte" unit 2015-12-17 16:38:28 +00:00
trace cmd/trace: don't fail when no browser is available 2015-08-21 20:02:23 +00:00
vendor cmd/vendor/golang.org/x/arch: import arm/armasm and x86/x86asm 2015-08-28 16:34:30 +00:00
vet cmd/vet: add some checks for invalid pointer passing using cgo 2015-12-18 00:31:21 +00:00
yacc cmd/yacc: memory allocation improvements 2015-11-26 17:42:14 +00:00