mirror of
https://github.com/golang/go
synced 2024-11-26 16:57:14 -07:00
width fixes.
* check for uncomputed struct offsets * distinguish function structs from ordinary structs * make sure function structs are not examined in isolation R=ken OCL=19005 CL=19005
This commit is contained in:
parent
07c54425c0
commit
792145723e
@ -154,6 +154,8 @@ dowidth(Type *t)
|
||||
break;
|
||||
|
||||
case TSTRUCT:
|
||||
if(t->funarg)
|
||||
fatal("dowidth fn struct %T", t);
|
||||
w = widstruct(t, 0, 1);
|
||||
offmod(t);
|
||||
break;
|
||||
|
@ -243,6 +243,8 @@ nodarg(Type *t, int fp)
|
||||
n = nod(ONAME, N, N);
|
||||
n->type = t->type;
|
||||
n->sym = t->sym;
|
||||
if(t->width == BADWIDTH)
|
||||
fatal("nodarg: offset not computed for %T", t);
|
||||
n->xoffset = t->width;
|
||||
n->addable = 1;
|
||||
|
||||
|
@ -161,9 +161,9 @@ functype(Node *this, Node *in, Node *out)
|
||||
|
||||
t = typ(TFUNC);
|
||||
|
||||
t->type = dostruct(this, TSTRUCT);
|
||||
t->type->down = dostruct(out, TSTRUCT);
|
||||
t->type->down->down = dostruct(in, TSTRUCT);
|
||||
t->type = dostruct(this, TFUNC);
|
||||
t->type->down = dostruct(out, TFUNC);
|
||||
t->type->down->down = dostruct(in, TFUNC);
|
||||
|
||||
t->thistuple = listcount(this);
|
||||
t->outtuple = listcount(out);
|
||||
@ -498,6 +498,7 @@ loop:
|
||||
f = typ(TFIELD);
|
||||
f->type = n->type;
|
||||
f->note = note;
|
||||
f->width = BADWIDTH;
|
||||
|
||||
if(n->left != N && n->left->op == ONAME) {
|
||||
f->nname = n->left;
|
||||
@ -517,15 +518,23 @@ Type*
|
||||
dostruct(Node *n, int et)
|
||||
{
|
||||
Type *t;
|
||||
int funarg;
|
||||
|
||||
/*
|
||||
* convert a parsed id/type list into
|
||||
* a type for struct/interface/arglist
|
||||
*/
|
||||
|
||||
funarg = 0;
|
||||
if(et == TFUNC) {
|
||||
funarg = 1;
|
||||
et = TSTRUCT;
|
||||
}
|
||||
t = typ(et);
|
||||
t->funarg = funarg;
|
||||
stotype(n, &t->type);
|
||||
checkwidth(t);
|
||||
if(!funarg)
|
||||
checkwidth(t);
|
||||
return t;
|
||||
}
|
||||
|
||||
@ -1130,6 +1139,11 @@ checkwidth(Type *t)
|
||||
{
|
||||
TypeList *l;
|
||||
|
||||
// function arg structs should not be checked
|
||||
// outside of the enclosing function.
|
||||
if(t->funarg)
|
||||
fatal("checkwidth %T", t);
|
||||
|
||||
if(!defercalc) {
|
||||
dowidth(t);
|
||||
return;
|
||||
|
@ -41,6 +41,8 @@ enum
|
||||
ASTRING,
|
||||
APTR,
|
||||
AINTER,
|
||||
|
||||
BADWIDTH = -1000000000
|
||||
};
|
||||
|
||||
/*
|
||||
@ -126,6 +128,7 @@ struct Type
|
||||
uchar printed;
|
||||
uchar embedded; // TFIELD embedded type
|
||||
uchar siggen;
|
||||
uchar funarg;
|
||||
|
||||
// TFUNCT
|
||||
uchar thistuple;
|
||||
|
Loading…
Reference in New Issue
Block a user