aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2017-01-14 21:40:16 -0800
committerJosh Bleecher Snyder <josharian@gmail.com>2017-01-16 05:40:45 +0000
commit5b708a6b6a57fb8022da58cd4c521d0ba77126fd (patch)
tree37b23316ef9ec985112cb6ff4f73d174a0b6c432
parente83d5067147ca6e82c1dc178eaeaf175c9f9db8e (diff)
downloadgo-5b708a6b6a57fb8022da58cd4c521d0ba77126fd.tar.gz
go-5b708a6b6a57fb8022da58cd4c521d0ba77126fd.zip
cmd/compile: lvalues are only required for == when calling runtime fns
Fixes #18661. Change-Id: I865802a9b88ab22560c9914a70901d1924242bdc Reviewed-on: https://go-review.googlesource.com/35236 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
-rw-r--r--src/cmd/compile/internal/gc/walk.go8
-rw-r--r--test/fixedbugs/issue18661.go18
2 files changed, 22 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go
index efe2016e46..7c2e2ab442 100644
--- a/src/cmd/compile/internal/gc/walk.go
+++ b/src/cmd/compile/internal/gc/walk.go
@@ -3117,12 +3117,12 @@ func walkcompare(n *Node, init *Nodes) *Node {
cmpr = cmpr.Left
}
- if !islvalue(cmpl) || !islvalue(cmpr) {
- Fatalf("arguments of comparison must be lvalues - %v %v", cmpl, cmpr)
- }
-
// Chose not to inline. Call equality function directly.
if !inline {
+ if !islvalue(cmpl) || !islvalue(cmpr) {
+ Fatalf("arguments of comparison must be lvalues - %v %v", cmpl, cmpr)
+ }
+
// eq algs take pointers
pl := temp(ptrto(t))
al := nod(OAS, pl, nod(OADDR, cmpl, nil))
diff --git a/test/fixedbugs/issue18661.go b/test/fixedbugs/issue18661.go
new file mode 100644
index 0000000000..8c83775200
--- /dev/null
+++ b/test/fixedbugs/issue18661.go
@@ -0,0 +1,18 @@
+// compile
+
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+var (
+ e interface{}
+ s = struct{ a *int }{}
+ b = e == s
+)
+
+func test(obj interface{}) {
+ if obj != struct{ a *string }{} {
+ }
+}