aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2015-09-01 22:25:21 +0000
committerandroid-build-merger <android-build-merger@google.com>2015-09-01 22:25:21 +0000
commit98b7ff4bbcbd93974360f750198a7ae90666d16d (patch)
tree616757caff63572e274a5700233fb6b80afbce2f
parentc17fdf129a9579156775bf2389f7273c26c5fa29 (diff)
parent436a79e5dd4cbda2129930db3a660c99276d7357 (diff)
downloadtools-98b7ff4bbcbd93974360f750198a7ae90666d16d.tar.gz
go/types: fix internal inInteger operand predicate
automerge: 436a79e * commit '436a79e5dd4cbda2129930db3a660c99276d7357': go/types: fix internal inInteger operand predicate
-rw-r--r--go/types/operand.go5
-rw-r--r--go/types/testdata/decls0.src1
-rw-r--r--go/types/testdata/shifts.src8
3 files changed, 12 insertions, 2 deletions
diff --git a/go/types/operand.go b/go/types/operand.go
index 0ac6767..d52b30e 100644
--- a/go/types/operand.go
+++ b/go/types/operand.go
@@ -279,9 +279,10 @@ func (x *operand) assignableTo(conf *Config, T Type) bool {
return false
}
-// isInteger reports whether x is a (typed or untyped) integer value.
+// isInteger reports whether x is a value of integer type
+// or an untyped constant representable as an integer.
func (x *operand) isInteger() bool {
return x.mode == invalid ||
isInteger(x.typ) ||
- x.mode == constant && representableConst(x.val, nil, UntypedInt, nil) // no *Config required for UntypedInt
+ isUntyped(x.typ) && x.mode == constant && representableConst(x.val, nil, UntypedInt, nil) // no *Config required for UntypedInt
}
diff --git a/go/types/testdata/decls0.src b/go/types/testdata/decls0.src
index f1df3ea..21baafe 100644
--- a/go/types/testdata/decls0.src
+++ b/go/types/testdata/decls0.src
@@ -53,6 +53,7 @@ type (
iA1 [1 /* ERROR "invalid array length" */ <<100]int
iA2 [- /* ERROR "invalid array length" */ 1]complex128
iA3 ["foo" /* ERROR "must be integer" */ ]string
+ iA4 [float64 /* ERROR "must be integer" */ (0)]int
)
diff --git a/go/types/testdata/shifts.src b/go/types/testdata/shifts.src
index 2df2ccd..fa4de9e 100644
--- a/go/types/testdata/shifts.src
+++ b/go/types/testdata/shifts.src
@@ -331,3 +331,11 @@ func issue11325() {
_ = 1. >> 1.
_ = 1.1 /* ERROR "must be integer" */ >> 1
}
+
+func issue11594() {
+ var _ = complex64 /* ERROR "must be integer" */ (1) << 2 // example from issue 11594
+ _ = float32 /* ERROR "must be integer" */ (0) << 1
+ _ = float64 /* ERROR "must be integer" */ (0) >> 2
+ _ = complex64 /* ERROR "must be integer" */ (0) << 3
+ _ = complex64 /* ERROR "must be integer" */ (0) >> 4
+}