mirror of https://github.com/golang/go.git
compiler changes:
export.c: - only expose explicitly exported types to importer - fix behind your back go.h: - add deep() prototype (fixes 64-bit linux crash on time.go) go.y: - add a new syntax error case walk.c: - allow a,b = f() where f is func ptr (fixes bug088) R=ken OCL=15617 CL=15630
This commit is contained in:
parent
8231e94520
commit
fb2c66710c
|
|
@ -143,7 +143,10 @@ dumpexporttype(Sym *s)
|
||||||
if(et < 0 || et >= nelem(types) || types[et] == T)
|
if(et < 0 || et >= nelem(types) || types[et] == T)
|
||||||
fatal("dumpexporttype: basic type: %S %E", s, et);
|
fatal("dumpexporttype: basic type: %S %E", s, et);
|
||||||
/* type 5 */
|
/* type 5 */
|
||||||
Bprint(bout, "\ttype %lS %d\n", s, et);
|
Bprint(bout, "\ttype ");
|
||||||
|
if(s->export != 0)
|
||||||
|
Bprint(bout, "!");
|
||||||
|
Bprint(bout, "%lS %d\n", s, et);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TARRAY:
|
case TARRAY:
|
||||||
|
|
@ -298,11 +301,6 @@ renamepkg(Node *n)
|
||||||
if(n->psym == pkgimportname)
|
if(n->psym == pkgimportname)
|
||||||
if(pkgmyname != S)
|
if(pkgmyname != S)
|
||||||
n->psym = pkgmyname;
|
n->psym = pkgmyname;
|
||||||
|
|
||||||
if(n->psym->lexical != LPACK) {
|
|
||||||
warn("%S is becoming a package behind your back", n->psym);
|
|
||||||
n->psym->lexical = LPACK;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Sym*
|
Sym*
|
||||||
|
|
@ -425,16 +423,21 @@ importaddtyp(Node *ss, Type *t)
|
||||||
Sym *s;
|
Sym *s;
|
||||||
|
|
||||||
s = getimportsym(ss);
|
s = getimportsym(ss);
|
||||||
if(s->otype == T) {
|
if(ss->etype){ // exported
|
||||||
addtyp(newtype(s), t, PEXTERN);
|
if(s->otype == T || !eqtype(t, s->otype, 0)) {
|
||||||
return;
|
if(s->otype != T)
|
||||||
}
|
|
||||||
if(!eqtype(t, s->otype, 0)) {
|
|
||||||
print("redeclaring %S %lT => %lT\n", s, s->otype, t);
|
print("redeclaring %S %lT => %lT\n", s, s->otype, t);
|
||||||
addtyp(newtype(s), t, PEXTERN);
|
addtyp(newtype(s), t, PEXTERN);
|
||||||
return;
|
/*
|
||||||
|
* mark as export to avoid conflicting export bits
|
||||||
|
* in multi-file package.
|
||||||
|
*/
|
||||||
|
s->export = 1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
s->otype = t;
|
||||||
|
t->sym = s;
|
||||||
}
|
}
|
||||||
// print("sametype %S %lT => %lT\n", s, s->otype, t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -729,3 +729,4 @@ void dowidth(Type*);
|
||||||
void argspace(int32);
|
void argspace(int32);
|
||||||
Node* nodarg(Type*, int);
|
Node* nodarg(Type*, int);
|
||||||
void nodconst(Node*, Type*, vlong);
|
void nodconst(Node*, Type*, vlong);
|
||||||
|
Type* deep(Type*);
|
||||||
|
|
|
||||||
|
|
@ -1693,7 +1693,12 @@ latype:
|
||||||
}
|
}
|
||||||
| LNAME
|
| LNAME
|
||||||
{
|
{
|
||||||
yyerror("%s is var, not type", $1->name);
|
yyerror("no type %s", $1->name);
|
||||||
|
YYERROR;
|
||||||
|
}
|
||||||
|
| lpack '.' LNAME
|
||||||
|
{
|
||||||
|
yyerror("no type %s.%s", context, $3->name);
|
||||||
YYERROR;
|
YYERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2691,6 +2691,8 @@ multi:
|
||||||
case OCALL:
|
case OCALL:
|
||||||
walktype(nr->left, Erv);
|
walktype(nr->left, Erv);
|
||||||
t = nr->left->type;
|
t = nr->left->type;
|
||||||
|
if(t != T && t->etype == tptr)
|
||||||
|
t = t->type;
|
||||||
if(t == T || t->etype != TFUNC)
|
if(t == T || t->etype != TFUNC)
|
||||||
goto badt;
|
goto badt;
|
||||||
if(t->outtuple != cl)
|
if(t->outtuple != cl)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue