Commit 0a7e4a74 authored by Ken Thompson's avatar Ken Thompson

bug generating duplicate interface signatures

R=r
OCL=15119
CL=15119
parent 27a56171
...@@ -322,7 +322,11 @@ loop: ...@@ -322,7 +322,11 @@ loop:
s = t->sym; s = t->sym;
if(s == S) if(s == S)
fatal("nodtypesig: no sym for type"); fatal("signame: no sym for type");
// mark it as used so signature will be generated
if(s->local == 1)
s->local = 2;
snprint(namebuf, sizeof(namebuf), "%s_%s", e, s->name); snprint(namebuf, sizeof(namebuf), "%s_%s", e, s->name);
s = pkglookup(namebuf, s->package); s = pkglookup(namebuf, s->package);
......
...@@ -459,7 +459,7 @@ sigcmp(Sig *a, Sig *b) ...@@ -459,7 +459,7 @@ sigcmp(Sig *a, Sig *b)
void void
dumpsignatures(void) dumpsignatures(void)
{ {
Dcl *d; Dcl *d, *x;
Type *t, *f; Type *t, *f;
Sym *s1, *s; Sym *s1, *s;
int et, o, wi, ot; int et, o, wi, ot;
...@@ -468,6 +468,44 @@ dumpsignatures(void) ...@@ -468,6 +468,44 @@ dumpsignatures(void)
Prog *p; Prog *p;
char *sp; char *sp;
// copy externdcl list to signatlist
for(d=externdcl; d!=D; d=d->forw) {
if(d->op != OTYPE)
continue;
t = d->dtype;
if(t == T)
continue;
et = t->etype;
if(et != TSTRUCT && et != TINTER)
continue;
s = d->dsym;
if(s == S)
continue;
if(s->name[0] == '_')
continue;
// if it was imported
if(s->local == 0)
continue;
// until i can figure out
// when/if it is used, do them all
// // if not used and not exported
// if(s->local == 1 && !s->export)
// continue;
x = mal(sizeof(*d));
x->op = OTYPE;
x->dsym = s;
x->dtype = t;
x->forw = signatlist;
signatlist = x;
}
/* /*
* put all the names into a linked * put all the names into a linked
* list so that it may be generated in sorted order. * list so that it may be generated in sorted order.
...@@ -505,7 +543,7 @@ dumpsignatures(void) ...@@ -505,7 +543,7 @@ dumpsignatures(void)
wi = types[TINT32]->width; wi = types[TINT32]->width;
for(d=externdcl; d!=D; d=d->forw) { for(d=signatlist; d!=D; d=d->forw) {
if(d->op != OTYPE) if(d->op != OTYPE)
continue; continue;
......
...@@ -52,6 +52,7 @@ dodcltype(Type *n, Type *t) ...@@ -52,6 +52,7 @@ dodcltype(Type *n, Type *t)
} }
if(exportadj) if(exportadj)
exportsym(n->sym); exportsym(n->sym);
n->sym->local = 1;
addtyp(n, t, dclcontext); addtyp(n, t, dclcontext);
} }
......
...@@ -195,8 +195,9 @@ struct Sym ...@@ -195,8 +195,9 @@ struct Sym
uchar undef; // a diagnostic has been generated uchar undef; // a diagnostic has been generated
uchar export; // marked as export uchar export; // marked as export
uchar exported; // has been exported uchar exported; // exported
uchar sym; // huffman encoding in object file uchar sym; // huffman encoding in object file
uchar local; // created in this file
char* opackage; // original package name char* opackage; // original package name
char* package; // package name char* package; // package name
...@@ -429,6 +430,7 @@ EXTERN Dcl* autodcl; ...@@ -429,6 +430,7 @@ EXTERN Dcl* autodcl;
EXTERN Dcl* paramdcl; EXTERN Dcl* paramdcl;
EXTERN Dcl* externdcl; EXTERN Dcl* externdcl;
EXTERN Dcl* exportlist; EXTERN Dcl* exportlist;
EXTERN Dcl* signatlist;
EXTERN int dclcontext; // PEXTERN/PAUTO EXTERN int dclcontext; // PEXTERN/PAUTO
EXTERN int importflag; EXTERN int importflag;
EXTERN int inimportsys; EXTERN int inimportsys;
......
...@@ -1970,8 +1970,6 @@ mapop(Node *n, int top) ...@@ -1970,8 +1970,6 @@ mapop(Node *n, int top)
goto shape; goto shape;
// mapassign1(hmap *map[any-1]any-2, key any-3, val any-4); // mapassign1(hmap *map[any-1]any-2, key any-3, val any-4);
//dump("assign1", n);
if(n->left->op != OINDEX) if(n->left->op != OINDEX)
goto shape; goto shape;
...@@ -1999,8 +1997,6 @@ mapop(Node *n, int top) ...@@ -1999,8 +1997,6 @@ mapop(Node *n, int top)
assign2: assign2:
// mapassign2(hmap *map[any]any, key any, val any, pres bool); // mapassign2(hmap *map[any]any, key any, val any, pres bool);
//dump("assign2", n);
if(n->left->op != OINDEX) if(n->left->op != OINDEX)
goto shape; goto shape;
......
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