Commit 3a1fdc65 authored by Russ Cox's avatar Russ Cox

gc: fix import width bug

Fixes #1705.

R=ken2
CC=golang-dev
https://golang.org/cl/4443060
parent 883d68f8
...@@ -43,6 +43,8 @@ cgen(Node *n, Node *res) ...@@ -43,6 +43,8 @@ cgen(Node *n, Node *res)
} }
if(isfat(n->type)) { if(isfat(n->type)) {
if(n->type->width < 0)
fatal("forgot to compute width for %T", n->type);
sgen(n, res, n->type->width); sgen(n, res, n->type->width);
goto ret; goto ret;
} }
......
...@@ -47,6 +47,8 @@ cgen(Node *n, Node *res) ...@@ -47,6 +47,8 @@ cgen(Node *n, Node *res)
} }
if(isfat(n->type)) { if(isfat(n->type)) {
if(n->type->width < 0)
fatal("forgot to compute width for %T", n->type);
sgen(n, res, n->type->width); sgen(n, res, n->type->width);
goto ret; goto ret;
} }
......
...@@ -78,6 +78,8 @@ cgen(Node *n, Node *res) ...@@ -78,6 +78,8 @@ cgen(Node *n, Node *res)
// structs etc get handled specially // structs etc get handled specially
if(isfat(n->type)) { if(isfat(n->type)) {
if(n->type->width < 0)
fatal("forgot to compute width for %T", n->type);
sgen(n, res, n->type->width); sgen(n, res, n->type->width);
return; return;
} }
......
...@@ -684,6 +684,10 @@ ok: ...@@ -684,6 +684,10 @@ ok:
pt->nod = n; pt->nod = n;
pt->sym = n->sym; pt->sym = n->sym;
pt->sym->lastlineno = parserline(); pt->sym->lastlineno = parserline();
pt->siggen = 0;
pt->printed = 0;
pt->deferwidth = 0;
pt->local = 0;
declare(n, PEXTERN); declare(n, PEXTERN);
checkwidth(pt); checkwidth(pt);
......
...@@ -142,7 +142,9 @@ walkdeftype(Node *n) ...@@ -142,7 +142,9 @@ walkdeftype(Node *n)
} }
// copy new type and clear fields // 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; maplineno = n->type->maplineno;
embedlineno = n->type->embedlineno; embedlineno = n->type->embedlineno;
*n->type = *t; *n->type = *t;
......
// 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
// 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()
// $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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment