1
0
mirror of https://github.com/golang/go synced 2024-11-25 13:07:57 -07:00

another piece for cross-file forward struct declarations.

R=ken
OCL=31233
CL=31233
This commit is contained in:
Russ Cox 2009-07-06 21:39:18 -07:00
parent a14b28a24d
commit ef4ddd63f8

View File

@ -67,11 +67,23 @@ dodcltype(Type *n)
// if n has been forward declared,
// use the Type* created then
s = n->sym;
if(s->block == block && s->def != N && s->def->op == OTYPE) {
if((funcdepth == 0 || s->block == block) && s->def != N && s->def->op == OTYPE) {
switch(s->def->type->etype) {
case TFORWSTRUCT:
case TFORWINTER:
n = s->def->type;
if(s->block != block) {
// completing forward struct from other file
Dcl *d, *r;
d = dcl();
d->dsym = s;
d->dtype = n;
d->op = OTYPE;
r = externdcl;
d->back = r->back;
r->back->forw = d;
r->back = d;
}
goto found;
}
}
@ -109,6 +121,7 @@ updatetype(Type *n, Type *t)
yyerror("%T forward declared as struct", n);
return;
}
n->local = 1;
break;
case TFORWINTER: