]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: use a register to checknil constants.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Tue, 4 Mar 2014 07:18:17 +0000 (08:18 +0100)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Tue, 4 Mar 2014 07:18:17 +0000 (08:18 +0100)
Fixes #7346.

LGTM=rsc
R=rsc, iant, khr
CC=golang-codereviews
https://golang.org/cl/69050044

src/cmd/gc/pgen.c
test/fixedbugs/issue7346.go [new file with mode: 0644]

index d05471ee301135032d8cd322a81c453610c81c65..f819f923cbcd5d02b5bf7de08ebce9a9d1ee9258 100644 (file)
@@ -476,7 +476,7 @@ cgen_checknil(Node *n)
                dump("checknil", n);
                fatal("bad checknil");
        }
-       if((thechar == '5' && n->op != OREGISTER) || !n->addable) {
+       if((thechar == '5' && n->op != OREGISTER) || !n->addable || n->op == OLITERAL) {
                regalloc(&reg, types[tptr], n);
                cgen(n, &reg);
                gins(ACHECKNIL, &reg, N);
diff --git a/test/fixedbugs/issue7346.go b/test/fixedbugs/issue7346.go
new file mode 100644 (file)
index 0000000..dd5ea22
--- /dev/null
@@ -0,0 +1,14 @@
+// compile
+
+// Copyright 2014 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.
+
+// issue 7346 : internal error "doasm" error due to checknil
+// of a nil literal.
+
+package main
+
+func main() {
+       _ = *(*int)(nil)
+}