mirror of
https://github.com/golang/go
synced 2024-11-22 00:34:40 -07:00
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)
|
||||
fatal("dumpexporttype: basic type: %S %E", s, et);
|
||||
/* 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;
|
||||
|
||||
case TARRAY:
|
||||
@ -298,11 +301,6 @@ renamepkg(Node *n)
|
||||
if(n->psym == pkgimportname)
|
||||
if(pkgmyname != S)
|
||||
n->psym = pkgmyname;
|
||||
|
||||
if(n->psym->lexical != LPACK) {
|
||||
warn("%S is becoming a package behind your back", n->psym);
|
||||
n->psym->lexical = LPACK;
|
||||
}
|
||||
}
|
||||
|
||||
Sym*
|
||||
@ -425,16 +423,21 @@ importaddtyp(Node *ss, Type *t)
|
||||
Sym *s;
|
||||
|
||||
s = getimportsym(ss);
|
||||
if(s->otype == T) {
|
||||
addtyp(newtype(s), t, PEXTERN);
|
||||
return;
|
||||
}
|
||||
if(!eqtype(t, s->otype, 0)) {
|
||||
if(ss->etype){ // exported
|
||||
if(s->otype == T || !eqtype(t, s->otype, 0)) {
|
||||
if(s->otype != T)
|
||||
print("redeclaring %S %lT => %lT\n", s, s->otype, t);
|
||||
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);
|
||||
Node* nodarg(Type*, int);
|
||||
void nodconst(Node*, Type*, vlong);
|
||||
Type* deep(Type*);
|
||||
|
@ -1693,7 +1693,12 @@ latype:
|
||||
}
|
||||
| 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;
|
||||
}
|
||||
|
||||
|
@ -2691,6 +2691,8 @@ multi:
|
||||
case OCALL:
|
||||
walktype(nr->left, Erv);
|
||||
t = nr->left->type;
|
||||
if(t != T && t->etype == tptr)
|
||||
t = t->type;
|
||||
if(t == T || t->etype != TFUNC)
|
||||
goto badt;
|
||||
if(t->outtuple != cl)
|
||||
|
Loading…
Reference in New Issue
Block a user