1
0
mirror of https://github.com/golang/go synced 2024-11-21 20:54:45 -07:00

gc: fix import width bug

Fixes #1705.

R=ken2
CC=golang-dev
https://golang.org/cl/4443060
This commit is contained in:
Russ Cox 2011-04-25 12:08:48 -04:00
parent 883d68f885
commit 3a1fdc655e
8 changed files with 43 additions and 1 deletions

View File

@ -43,6 +43,8 @@ cgen(Node *n, Node *res)
}
if(isfat(n->type)) {
if(n->type->width < 0)
fatal("forgot to compute width for %T", n->type);
sgen(n, res, n->type->width);
goto ret;
}

View File

@ -47,6 +47,8 @@ cgen(Node *n, Node *res)
}
if(isfat(n->type)) {
if(n->type->width < 0)
fatal("forgot to compute width for %T", n->type);
sgen(n, res, n->type->width);
goto ret;
}

View File

@ -78,6 +78,8 @@ cgen(Node *n, Node *res)
// structs etc get handled specially
if(isfat(n->type)) {
if(n->type->width < 0)
fatal("forgot to compute width for %T", n->type);
sgen(n, res, n->type->width);
return;
}

View File

@ -684,6 +684,10 @@ ok:
pt->nod = n;
pt->sym = n->sym;
pt->sym->lastlineno = parserline();
pt->siggen = 0;
pt->printed = 0;
pt->deferwidth = 0;
pt->local = 0;
declare(n, PEXTERN);
checkwidth(pt);

View File

@ -142,7 +142,9 @@ walkdeftype(Node *n)
}
// copy new type and clear fields
// that don't come along
// that don't come along.
// anything zeroed here must be zeroed in
// typedcl2 too.
maplineno = n->type->maplineno;
embedlineno = n->type->embedlineno;
*n->type = *t;

View File

@ -0,0 +1,9 @@
// 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 a
import "./b"
var Bar = b.Foo

View File

@ -0,0 +1,11 @@
// 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 b
type T interface{}
func f() T { return nil }
var Foo T = f()

10
test/fixedbugs/bug335.go Normal file
View File

@ -0,0 +1,10 @@
// $G $D/$F.dir/b.go && $G $D/$F.dir/a.go
// rm -f a.$A b.$A
// 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 1705.
unused (see script at top of file)