mirror of
https://github.com/golang/go
synced 2024-11-20 06:04:52 -07:00
another piece for cross-file forward struct declarations.
R=ken OCL=31233 CL=31233
This commit is contained in:
parent
a14b28a24d
commit
ef4ddd63f8
@ -67,11 +67,23 @@ dodcltype(Type *n)
|
|||||||
// if n has been forward declared,
|
// if n has been forward declared,
|
||||||
// use the Type* created then
|
// use the Type* created then
|
||||||
s = n->sym;
|
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) {
|
switch(s->def->type->etype) {
|
||||||
case TFORWSTRUCT:
|
case TFORWSTRUCT:
|
||||||
case TFORWINTER:
|
case TFORWINTER:
|
||||||
n = s->def->type;
|
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;
|
goto found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,6 +121,7 @@ updatetype(Type *n, Type *t)
|
|||||||
yyerror("%T forward declared as struct", n);
|
yyerror("%T forward declared as struct", n);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
n->local = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TFORWINTER:
|
case TFORWINTER:
|
||||||
|
Loading…
Reference in New Issue
Block a user