]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix static-initialization compilation failure
authorMatthew Dempsky <mdempsky@google.com>
Mon, 5 Dec 2016 23:57:45 +0000 (15:57 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 6 Dec 2016 06:14:59 +0000 (06:14 +0000)
Fixes #13263.

Change-Id: Ie1cafc62b6bfe6c5381c35d9a95563267b4cc9b0
Reviewed-on: https://go-review.googlesource.com/33970
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/gc/sinit.go
test/fixedbugs/issue13263.go [new file with mode: 0644]

index 1192f3fac9b231f32ed1e5549d6de3f82be4b178..350c8677259a1e009df6b3d4829dab6b1d5a4ec9 100644 (file)
@@ -295,7 +295,9 @@ func staticcopy(l *Node, r *Node, out *[]*Node) bool {
                if staticcopy(l, r, out) {
                        return true
                }
-               *out = append(*out, nod(OAS, l, r))
+               // We may have skipped past one or more OCONVNOPs, so
+               // use conv to ensure r is assignable to l (#13263).
+               *out = append(*out, nod(OAS, l, conv(r, l.Type)))
                return true
 
        case OLITERAL:
diff --git a/test/fixedbugs/issue13263.go b/test/fixedbugs/issue13263.go
new file mode 100644 (file)
index 0000000..1933f2b
--- /dev/null
@@ -0,0 +1,15 @@
+// compile
+
+// Copyright 2016 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 b
+
+var (
+       x uint
+       y = x
+       z = uintptr(y)
+       a = uint32(y)
+       b = uint64(y)
+)