]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: lvalues are only required for == when calling runtime fns
authorJosh Bleecher Snyder <josharian@gmail.com>
Sun, 15 Jan 2017 05:40:16 +0000 (21:40 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 16 Jan 2017 05:40:45 +0000 (05:40 +0000)
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>
src/cmd/compile/internal/gc/walk.go
test/fixedbugs/issue18661.go [new file with mode: 0644]

index efe2016e46ca2c8be566259520d458881d03fb70..7c2e2ab442886c4f511300a77075ad968ec16fec 100644 (file)
@@ -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 (file)
index 0000000..8c83775
--- /dev/null
@@ -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 }{} {
+       }
+}