return;
t = a->type;
- if(t != D_AUTO && t != D_PARAM)
+ if(t != D_AUTO && t != D_PARAM) {
+ if(a->gotype)
+ s->gotype = a->gotype;
return;
+ }
l = a->offset;
for(u=curauto; u; u=u->link) {
if(u->asym == s)
if(u->type == t) {
if(u->aoffset > l)
u->aoffset = l;
+ if(a->gotype)
+ u->gotype = a->gotype;
return;
}
}
u->asym = s;
u->aoffset = l;
u->type = t;
+ u->gotype = a->gotype;
}
void
s = p->from.sym;
if(s != S && s->dupok) {
if(debug['v'])
- Bprint(&bso, "skipping %s in %s: dupok", s->name, pn);
+ Bprint(&bso, "skipping %s in %s: dupok\n", s->name, pn);
goto loop;
}
if(s != S) {
}
diag("%s: redefinition: %s\n%P", pn, s->name, p);
}
+ if(p->from.gotype) {
+ if(s->gotype && s->gotype != p->from.gotype)
+ diag("%s: type mismatch for %s", pn, s->name);
+ s->gotype = p->from.gotype;
+ }
newtext(p, s);
goto loop;
}
void
-putsymb(char *s, int t, vlong v, int ver, vlong go)
+putsymb(char *s, int t, vlong v, int ver, Sym *go)
{
int i, f, l;
+ vlong gv;
if(t == 'f')
s++;
cput(s[i]);
cput(0);
}
+ gv = 0;
+ if(go)
+ gv = go->value+INITDAT;
if(l == 8)
- lputb(go>>32);
- lputb(go);
- symsize += l + 1 + i + 1 + l;
+ lputb(gv>>32);
+ lputb(gv);
+ symsize += l + 1 + i+1 + l;
if(debug['n']) {
if(t == 'z' || t == 'Z') {
return;
}
if(ver)
- Bprint(&bso, "%c %.8llux %s<%d> %s\n", t, v, s, ver, go);
+ Bprint(&bso, "%c %.8llux %s<%d> %s (%.8llux)\n", t, v, s, ver, go ? go->name : "", gv);
else
- Bprint(&bso, "%c %.8llux %s %s\n", t, v, s, go);
+ Bprint(&bso, "%c %.8llux %s %s (%.8llux)\n", t, v, s, go ? go->name : "", gv);
}
}
for(s=hash[h]; s!=S; s=s->link)
switch(s->type) {
case SCONST:
- putsymb(s->name, 'D', s->value, s->version, gotypefor(s->name));
+ putsymb(s->name, 'D', s->value, s->version, s->gotype);
continue;
case SDATA:
- putsymb(s->name, 'D', s->value+INITDAT, s->version, gotypefor(s->name));
+ putsymb(s->name, 'D', s->value+INITDAT, s->version, s->gotype);
continue;
case SBSS:
- putsymb(s->name, 'B', s->value+INITDAT, s->version, gotypefor(s->name));
+ putsymb(s->name, 'B', s->value+INITDAT, s->version, s->gotype);
continue;
case SFILE:
if(s->type != STEXT)
continue;
- putsymb(s->name, 'T', s->value, s->version, gotypefor(s->name));
+ putsymb(s->name, 'T', s->value, s->version, s->gotype);
/* frame, auto and param after */
putsymb(".frame", 'm', p->to.offset+8, 0, 0);
/* TODO(rsc): Add types for D_AUTO and D_PARAM */
for(a=p->to.autom; a; a=a->link)
if(a->type == D_AUTO)
- putsymb(a->asym->name, 'a', -a->aoffset, 0, gotypefor(nil));
+ putsymb(a->asym->name, 'a', -a->aoffset, 0, a->gotype);
else
if(a->type == D_PARAM)
- putsymb(a->asym->name, 'p', a->aoffset, 0, gotypefor(nil));
+ putsymb(a->asym->name, 'p', a->aoffset, 0, a->gotype);
}
if(debug['v'] || debug['n'])
Bprint(&bso, "symsize = %lud\n", symsize);
Sym *s;
Node *n;
+ if(isptr[t->etype] && t->type == T)
+ fatal("typename %T", t);
s = typesym(t);
if(s->def == N) {
n = nod(ONAME, N, N);
goto ok;
if(t1 && t1 == types[t1->etype])
goto ok;
+ if(t1 && t1->etype == tptr && t1->type->etype == TANY)
+ goto ok;
}
// named types from other files are defined in those files
dtypesym(ptrto(t));
}
- // do basic types if compiling package runtime, type.go.
+ // do basic types if compiling package runtime.
// they have to be in at least one package,
// and reflect is always loaded implicitly,
// so this is as good as any.
// another possible choice would be package main,
// but using runtime means fewer copies in .6 files.
- if(strcmp(package, "runtime") == 0 && strcmp(filename, "type") == 0) {
+ if(strcmp(package, "runtime") == 0) {
for(i=1; i<=TBOOL; i++)
if(i != TFLOAT80)
dtypesym(ptrto(types[i]));