mirror of
https://github.com/golang/go
synced 2024-09-23 21:30:18 -06:00
cmd/gc: fix wrong interaction between inlining and embedded builtins.
The patch makes the compile user an ordinary package-local symbol for the name of embedded fields of builtin type. This is incompatible with the fix delivered for issue 2687 (revision 3c060add43fb) but fixes it in a different way, because the explicit symbol on the field makes the typechecker able to find it in lookdot. Fixes #3552. R=lvd, rsc, daniel.morsing CC=golang-dev https://golang.org/cl/6866047
This commit is contained in:
parent
ced8004a00
commit
9aef20e823
@ -1013,6 +1013,9 @@ embedded(Sym *s)
|
||||
|
||||
if(exportname(name))
|
||||
n = newname(lookup(name));
|
||||
else if(s->pkg == builtinpkg && importpkg != nil)
|
||||
// The name of embedded builtins during imports belongs to importpkg.
|
||||
n = newname(pkglookup(name, importpkg));
|
||||
else
|
||||
n = newname(pkglookup(name, s->pkg));
|
||||
n = nod(ODCLFIELD, n, oldname(s));
|
||||
|
@ -1082,7 +1082,6 @@ exprfmt(Fmt *f, Node *n, int prec)
|
||||
{
|
||||
int nprec;
|
||||
NodeList *l;
|
||||
Type *t;
|
||||
|
||||
while(n && n->implicit && (n->op == OIND || n->op == OADDR))
|
||||
n = n->left;
|
||||
@ -1208,14 +1207,6 @@ exprfmt(Fmt *f, Node *n, int prec)
|
||||
else
|
||||
fmtprint(f, "(%T{", n->type);
|
||||
for(l=n->list; l; l=l->next) {
|
||||
// another special case: if n->left is an embedded field of builtin type,
|
||||
// it needs to be non-qualified. Can't figure that out in %S, so do it here
|
||||
if(l->n->left->type->embedded) {
|
||||
t = l->n->left->type->type;
|
||||
if(t->sym == S)
|
||||
t = t->type;
|
||||
fmtprint(f, " %hhS:%N", t->sym, l->n->right);
|
||||
} else
|
||||
fmtprint(f, " %hhS:%N", l->n->left->sym, l->n->right);
|
||||
|
||||
if(l->next)
|
||||
|
@ -1,10 +0,0 @@
|
||||
// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go || echo BUG:bug434
|
||||
|
||||
// NOTE: This test is not run by 'run.go' and so not run by all.bash.
|
||||
// To run this test you must use the ./run shell script.
|
||||
|
||||
// Copyright 2011 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.
|
||||
|
||||
package ignored
|
10
test/fixedbugs/issue3552.go
Normal file
10
test/fixedbugs/issue3552.go
Normal file
@ -0,0 +1,10 @@
|
||||
// compiledir
|
||||
|
||||
// Copyright 2011 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 3552: cross-package inlining misbehaves when
|
||||
// referencing embedded builtins.
|
||||
|
||||
package ignored
|
@ -710,5 +710,4 @@ var skipOkay = map[string]bool{
|
||||
"fixedbugs/bug385_64.go": true, // arch-specific errors.
|
||||
"fixedbugs/bug429.go": true,
|
||||
"bugs/bug395.go": true,
|
||||
"bugs/bug434.go": true,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user