mirror of
https://github.com/golang/go
synced 2024-11-22 03:14:41 -07:00
gc: Preserve original blank name for .anon substitution on out params.
Fixes #1802. R=rsc CC=golang-dev https://golang.org/cl/5364043
This commit is contained in:
parent
151b2f1509
commit
d5a5855ba1
@ -573,7 +573,7 @@ funchdr(Node *n)
|
|||||||
static void
|
static void
|
||||||
funcargs(Node *nt)
|
funcargs(Node *nt)
|
||||||
{
|
{
|
||||||
Node *n;
|
Node *n, *nn;
|
||||||
NodeList *l;
|
NodeList *l;
|
||||||
int gen;
|
int gen;
|
||||||
|
|
||||||
@ -615,6 +615,10 @@ funcargs(Node *nt)
|
|||||||
n->left->ntype = n->right;
|
n->left->ntype = n->right;
|
||||||
if(isblank(n->left)) {
|
if(isblank(n->left)) {
|
||||||
// Give it a name so we can assign to it during return.
|
// Give it a name so we can assign to it during return.
|
||||||
|
// preserve the original in ->orig
|
||||||
|
nn = nod(OXXX, N, N);
|
||||||
|
*nn = *n->left;
|
||||||
|
n->left = nn;
|
||||||
snprint(namebuf, sizeof(namebuf), ".anon%d", gen++);
|
snprint(namebuf, sizeof(namebuf), ".anon%d", gen++);
|
||||||
n->left->sym = lookup(namebuf);
|
n->left->sym = lookup(namebuf);
|
||||||
}
|
}
|
||||||
@ -1342,6 +1346,3 @@ funccompile(Node *n, int isclosure)
|
|||||||
funcdepth = 0;
|
funcdepth = 0;
|
||||||
dclcontext = PEXTERN;
|
dclcontext = PEXTERN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@
|
|||||||
//
|
//
|
||||||
// %T Type* Types
|
// %T Type* Types
|
||||||
// Flags: +,- #: mode (see below)
|
// Flags: +,- #: mode (see below)
|
||||||
// 'l' definition instead of name.
|
// 'l' definition instead of name.
|
||||||
// 'h' omit "func" and receiver in function types
|
// 'h' omit "func" and receiver in function types
|
||||||
// 'u' (only in -/Sym mode) print type identifiers wit package name instead of prefix.
|
// 'u' (only in -/Sym mode) print type identifiers wit package name instead of prefix.
|
||||||
//
|
//
|
||||||
// %N Node* Nodes
|
// %N Node* Nodes
|
||||||
// Flags: +,- #: mode (see below)
|
// Flags: +,- #: mode (see below)
|
||||||
@ -41,7 +41,7 @@
|
|||||||
// Flags: those of %N
|
// Flags: those of %N
|
||||||
// ',' separate items with ',' instead of ';'
|
// ',' separate items with ',' instead of ';'
|
||||||
//
|
//
|
||||||
// %Z Strlit* String literals
|
// %Z Strlit* String literals
|
||||||
//
|
//
|
||||||
// In mparith1.c:
|
// In mparith1.c:
|
||||||
// %B Mpint* Big integers
|
// %B Mpint* Big integers
|
||||||
@ -542,6 +542,7 @@ static int
|
|||||||
typefmt(Fmt *fp, Type *t)
|
typefmt(Fmt *fp, Type *t)
|
||||||
{
|
{
|
||||||
Type *t1;
|
Type *t1;
|
||||||
|
Sym *s;
|
||||||
|
|
||||||
if(t == T)
|
if(t == T)
|
||||||
return fmtstrcpy(fp, "<T>");
|
return fmtstrcpy(fp, "<T>");
|
||||||
@ -680,10 +681,23 @@ typefmt(Fmt *fp, Type *t)
|
|||||||
|
|
||||||
case TFIELD:
|
case TFIELD:
|
||||||
if(!(fp->flags&FmtShort)) {
|
if(!(fp->flags&FmtShort)) {
|
||||||
if(t->sym != S && !t->embedded)
|
s = t->sym;
|
||||||
fmtprint(fp, "%hS ", t->sym);
|
switch(fmtmode) {
|
||||||
if((!t->sym || t->embedded) && fmtmode == FExp)
|
case FErr:
|
||||||
fmtstrcpy(fp, "? ");
|
case FExp:
|
||||||
|
// Take the name from the original, lest we substituted it with .anon%d
|
||||||
|
if (t->nname)
|
||||||
|
s = t->nname->orig->sym;
|
||||||
|
|
||||||
|
if((s == S || t->embedded)) {
|
||||||
|
fmtstrcpy(fp, "? ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// fallthrough
|
||||||
|
default:
|
||||||
|
if(!(s == S || t->embedded))
|
||||||
|
fmtprint(fp, "%hS ", s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(t->isddd)
|
if(t->isddd)
|
||||||
|
6
test/fixedbugs/bug377.dir/one.go
Normal file
6
test/fixedbugs/bug377.dir/one.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package one
|
||||||
|
|
||||||
|
func Foo() (n int64, _ *int) {
|
||||||
|
return 42, nil
|
||||||
|
}
|
||||||
|
|
4
test/fixedbugs/bug377.dir/two.go
Normal file
4
test/fixedbugs/bug377.dir/two.go
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
package two
|
||||||
|
|
||||||
|
import _ "./one"
|
||||||
|
|
9
test/fixedbugs/bug377.go
Normal file
9
test/fixedbugs/bug377.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go
|
||||||
|
|
||||||
|
// 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 1802
|
||||||
|
|
||||||
|
ignored
|
Loading…
Reference in New Issue
Block a user