diff options
author | R?my Oudompheng <oudomphe@phare.normalesup.org> | 2012-12-22 19:16:31 +0100 |
---|---|---|
committer | R?my Oudompheng <oudomphe@phare.normalesup.org> | 2012-12-22 19:16:31 +0100 |
commit | b90c45a9555bdfb7c53b414842e260b3b40d2bc5 (patch) | |
tree | 2fbb3e2315716cc47bb1c0d7543b35a40c001d18 | |
parent | 1899bd6c0561e5a184df22ea5e7b7a19bda71f27 (diff) | |
download | go-b90c45a9555bdfb7c53b414842e260b3b40d2bc5.tar.gz |
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 issue 3552.
R=lvd, rsc, daniel.morsing
CC=golang-dev
https://codereview.appspot.com/6866047
-rw-r--r-- | src/cmd/gc/dcl.c | 3 | ||||
-rw-r--r-- | src/cmd/gc/fmt.c | 11 | ||||
-rw-r--r-- | test/bugs/bug434.go | 10 | ||||
-rw-r--r-- | test/fixedbugs/issue3552.dir/one.go (renamed from test/bugs/bug434.dir/one.go) | 0 | ||||
-rw-r--r-- | test/fixedbugs/issue3552.dir/two.go (renamed from test/bugs/bug434.dir/two.go) | 0 | ||||
-rw-r--r-- | test/fixedbugs/issue3552.go | 10 | ||||
-rw-r--r-- | test/run.go | 73 |
7 files changed, 50 insertions, 57 deletions
diff --git a/src/cmd/gc/dcl.c b/src/cmd/gc/dcl.c index 7748289b4..bf226d92a 100644 --- a/src/cmd/gc/dcl.c +++ b/src/cmd/gc/dcl.c @@ -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)); diff --git a/src/cmd/gc/fmt.c b/src/cmd/gc/fmt.c index 114c3f025..cbaba467e 100644 --- a/src/cmd/gc/fmt.c +++ b/src/cmd/gc/fmt.c @@ -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,15 +1207,7 @@ 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); + fmtprint(f, " %hhS:%N", l->n->left->sym, l->n->right); if(l->next) fmtstrcpy(f, ","); diff --git a/test/bugs/bug434.go b/test/bugs/bug434.go deleted file mode 100644 index 5eec7a577..000000000 --- a/test/bugs/bug434.go +++ /dev/null @@ -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 diff --git a/test/bugs/bug434.dir/one.go b/test/fixedbugs/issue3552.dir/one.go index 491ada1d9..491ada1d9 100644 --- a/test/bugs/bug434.dir/one.go +++ b/test/fixedbugs/issue3552.dir/one.go diff --git a/test/bugs/bug434.dir/two.go b/test/fixedbugs/issue3552.dir/two.go index 1366d244d..1366d244d 100644 --- a/test/bugs/bug434.dir/two.go +++ b/test/fixedbugs/issue3552.dir/two.go diff --git a/test/fixedbugs/issue3552.go b/test/fixedbugs/issue3552.go new file mode 100644 index 000000000..a198dbe97 --- /dev/null +++ b/test/fixedbugs/issue3552.go @@ -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 diff --git a/test/run.go b/test/run.go index 420b5ddd0..3b99211bc 100644 --- a/test/run.go +++ b/test/run.go @@ -5,7 +5,7 @@ // license that can be found in the LICENSE file. // Run runs tests in the test directory. -// +// // TODO(bradfitz): docs of some sort, once we figure out how we're changing // headers of files package main @@ -204,7 +204,7 @@ type test struct { err error } -// startTest +// startTest func startTest(dir, gofile string) *test { t := &test{ dir: dir, @@ -676,39 +676,38 @@ func (t *test) wantedErrors(file, short string) (errs []wantedError) { } var skipOkay = map[string]bool{ - "linkx.go": true, - "rotate.go": true, - "sigchld.go": true, - "sinit.go": true, - "dwarf/main.go": true, - "dwarf/z1.go": true, - "dwarf/z10.go": true, - "dwarf/z11.go": true, - "dwarf/z12.go": true, - "dwarf/z13.go": true, - "dwarf/z14.go": true, - "dwarf/z15.go": true, - "dwarf/z16.go": true, - "dwarf/z17.go": true, - "dwarf/z18.go": true, - "dwarf/z19.go": true, - "dwarf/z2.go": true, - "dwarf/z20.go": true, - "dwarf/z3.go": true, - "dwarf/z4.go": true, - "dwarf/z5.go": true, - "dwarf/z6.go": true, - "dwarf/z7.go": true, - "dwarf/z8.go": true, - "dwarf/z9.go": true, - "fixedbugs/bug248.go": true, // combines errorcheckdir and rundir in the same dir. - "fixedbugs/bug302.go": true, // tests both .$O and .a imports. - "fixedbugs/bug313.go": true, // errorcheckdir with failures in the middle. - "fixedbugs/bug345.go": true, // needs the appropriate flags in gc invocation. - "fixedbugs/bug369.go": true, // needs compiler flags. - "fixedbugs/bug385_32.go": true, // arch-specific errors. - "fixedbugs/bug385_64.go": true, // arch-specific errors. - "fixedbugs/bug429.go": true, - "bugs/bug395.go": true, - "bugs/bug434.go": true, + "linkx.go": true, + "rotate.go": true, + "sigchld.go": true, + "sinit.go": true, + "dwarf/main.go": true, + "dwarf/z1.go": true, + "dwarf/z10.go": true, + "dwarf/z11.go": true, + "dwarf/z12.go": true, + "dwarf/z13.go": true, + "dwarf/z14.go": true, + "dwarf/z15.go": true, + "dwarf/z16.go": true, + "dwarf/z17.go": true, + "dwarf/z18.go": true, + "dwarf/z19.go": true, + "dwarf/z2.go": true, + "dwarf/z20.go": true, + "dwarf/z3.go": true, + "dwarf/z4.go": true, + "dwarf/z5.go": true, + "dwarf/z6.go": true, + "dwarf/z7.go": true, + "dwarf/z8.go": true, + "dwarf/z9.go": true, + "fixedbugs/bug248.go": true, // combines errorcheckdir and rundir in the same dir. + "fixedbugs/bug302.go": true, // tests both .$O and .a imports. + "fixedbugs/bug313.go": true, // errorcheckdir with failures in the middle. + "fixedbugs/bug345.go": true, // needs the appropriate flags in gc invocation. + "fixedbugs/bug369.go": true, // needs compiler flags. + "fixedbugs/bug385_32.go": true, // arch-specific errors. + "fixedbugs/bug385_64.go": true, // arch-specific errors. + "fixedbugs/bug429.go": true, + "bugs/bug395.go": true, } |