Commit 1bd4a7db authored by Rémy Oudompheng's avatar Rémy Oudompheng

cmd/8g: fix erroneous LEAL nil.

Fixes #4399.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/6845053
parent d28133dc
...@@ -827,16 +827,19 @@ igen(Node *n, Node *a, Node *res) ...@@ -827,16 +827,19 @@ igen(Node *n, Node *a, Node *res)
return; return;
case ODOTPTR: case ODOTPTR:
if(n->left->addable switch(n->left->op) {
|| n->left->op == OCALLFUNC case ODOT:
|| n->left->op == OCALLMETH case ODOTPTR:
|| n->left->op == OCALLINTER) { case OCALLFUNC:
case OCALLMETH:
case OCALLINTER:
// igen-able nodes. // igen-able nodes.
igen(n->left, &n1, res); igen(n->left, &n1, res);
regalloc(a, types[tptr], &n1); regalloc(a, types[tptr], &n1);
gmove(&n1, a); gmove(&n1, a);
regfree(&n1); regfree(&n1);
} else { break;
default:
regalloc(a, types[tptr], res); regalloc(a, types[tptr], res);
cgen(n->left, a); cgen(n->left, a);
} }
......
...@@ -1747,7 +1747,7 @@ gins(int as, Node *f, Node *t) ...@@ -1747,7 +1747,7 @@ gins(int as, Node *f, Node *t)
case ALEAL: case ALEAL:
if(f != N && isconst(f, CTNIL)) if(f != N && isconst(f, CTNIL))
fatal("gins LEAQ nil %T", f->type); fatal("gins LEAL nil %T", f->type);
break; break;
} }
......
// 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)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment