mirror of
https://github.com/golang/go
synced 2024-11-22 03:14:41 -07:00
gc: fix inlining bug
Fixes #2682. R=lvd CC=golang-dev https://golang.org/cl/5538043
This commit is contained in:
parent
f2b51f564f
commit
836a517f69
@ -1078,7 +1078,9 @@ exprfmt(Fmt *f, Node *n, int prec)
|
|||||||
if(n->val.ctype == CTNIL)
|
if(n->val.ctype == CTNIL)
|
||||||
n = n->orig; // if this node was a nil decorated with at type, print the original naked nil
|
n = n->orig; // if this node was a nil decorated with at type, print the original naked nil
|
||||||
if(n->type != types[n->type->etype] && n->type != idealbool && n->type != idealstring) {
|
if(n->type != types[n->type->etype] && n->type != idealbool && n->type != idealstring) {
|
||||||
if(isptr[n->type->etype])
|
// Need parens when type begins with what might
|
||||||
|
// be misinterpreted as a unary operator: * or <-.
|
||||||
|
if(isptr[n->type->etype] || (n->type->etype == TCHAN && n->type->chan == Crecv))
|
||||||
return fmtprint(f, "(%T)(%V)", n->type, &n->val);
|
return fmtprint(f, "(%T)(%V)", n->type, &n->val);
|
||||||
else
|
else
|
||||||
return fmtprint(f, "%T(%V)", n->type, &n->val);
|
return fmtprint(f, "%T(%V)", n->type, &n->val);
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// Functions that the inliner exported incorrectly.
|
||||||
|
|
||||||
package one
|
package one
|
||||||
|
|
||||||
type file int
|
type T int
|
||||||
func (file *file) isnil() bool { return file == nil }
|
|
||||||
func (fil *file) isnil2() bool { return fil == nil }
|
|
||||||
|
|
||||||
|
// Issue 2678
|
||||||
|
func F1(T *T) bool { return T == nil }
|
||||||
|
|
||||||
|
// Issue 2682.
|
||||||
|
func F2(c chan int) bool { return c == (<-chan int)(nil) }
|
||||||
|
@ -1,4 +1,16 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// Use the functions in one.go so that the inlined
|
||||||
|
// forms get type-checked.
|
||||||
|
|
||||||
package two
|
package two
|
||||||
|
|
||||||
import _ "./one"
|
import "./one"
|
||||||
|
|
||||||
|
func use() {
|
||||||
|
one.F1(nil)
|
||||||
|
one.F2(nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
// $G $D/$F.dir/one.go && $G -ll $D/$F.dir/two.go
|
// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go
|
||||||
|
|
||||||
// Copyright 2011 The Go Authors. All rights reserved.
|
// Copyright 2011 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
//
|
|
||||||
// Issue 2678
|
|
||||||
// -ll flag in command above is to force typecheck on import, needed to trigger the bug.
|
|
||||||
// fixedbugs/bug392.dir/two.go:3: cannot call non-function *one.file (type one.file)
|
|
||||||
|
|
||||||
package ignored
|
package ignored
|
||||||
|
Loading…
Reference in New Issue
Block a user