Commit ef4ddd63 authored by Russ Cox's avatar Russ Cox

another piece for cross-file forward struct declarations.

R=ken
OCL=31233
CL=31233
parent a14b28a2
...@@ -67,11 +67,23 @@ dodcltype(Type *n) ...@@ -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) ...@@ -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:
......
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