]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/8g: fix erroneous LEAL nil.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Wed, 21 Nov 2012 07:39:45 +0000 (08:39 +0100)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Wed, 21 Nov 2012 07:39:45 +0000 (08:39 +0100)
Fixes #4399.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/6845053

src/cmd/8g/cgen.c
src/cmd/8g/gsubr.c
test/fixedbugs/issue4399.go [new file with mode: 0644]

index 7b44bac0d3124417305ff522165c510b2464ec7d..33506c770ca948e7da678205dc92baab958a2790 100644 (file)
@@ -827,16 +827,19 @@ igen(Node *n, Node *a, Node *res)
                return;
 
        case ODOTPTR:
-               if(n->left->addable
-                       || n->left->op == OCALLFUNC
-                       || n->left->op == OCALLMETH
-                       || n->left->op == OCALLINTER) {
+               switch(n->left->op) {
+               case ODOT:
+               case ODOTPTR:
+               case OCALLFUNC:
+               case OCALLMETH:
+               case OCALLINTER:
                        // igen-able nodes.
                        igen(n->left, &n1, res);
                        regalloc(a, types[tptr], &n1);
                        gmove(&n1, a);
                        regfree(&n1);
-               } else {
+                       break;
+               default:
                        regalloc(a, types[tptr], res);
                        cgen(n->left, a);
                }
index c5f6c22428be5b9244b1d1e83884ecd28a1a38c8..d6d171227cb97c74235e2d0597b006c570c998bc 100644 (file)
@@ -1747,7 +1747,7 @@ gins(int as, Node *f, Node *t)
        
        case ALEAL:
                if(f != N && isconst(f, CTNIL))
-                       fatal("gins LEAQ nil %T", f->type);
+                       fatal("gins LEAL nil %T", f->type);
                break;
        }
 
diff --git a/test/fixedbugs/issue4399.go b/test/fixedbugs/issue4399.go
new file mode 100644 (file)
index 0000000..6674db9
--- /dev/null
@@ -0,0 +1,15 @@
+// compile
+
+// Copyright 2012 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 4399: 8g would print "gins LEAQ nil *A".
+
+package main
+
+type A struct{ a int }
+
+func main() {
+       println(((*A)(nil)).a)
+}