mirror of
https://github.com/golang/go
synced 2024-09-06 00:19:45 +00:00
cmd/8g: fix erroneous LEAL nil.
Fixes #4399. R=golang-dev, nigeltao CC=golang-dev https://golang.org/cl/6845053
This commit is contained in:
parent
d28133dc9f
commit
1bd4a7dbcb
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
15
test/fixedbugs/issue4399.go
Normal file
15
test/fixedbugs/issue4399.go
Normal file
|
@ -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)
|
||||
}
|
Loading…
Reference in a new issue