]> Cypherpunks repositories - gostls13.git/commitdiff
compiler changes:
authorRuss Cox <rsc@golang.org>
Mon, 22 Sep 2008 19:45:01 +0000 (12:45 -0700)
committerRuss Cox <rsc@golang.org>
Mon, 22 Sep 2008 19:45:01 +0000 (12:45 -0700)
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

src/cmd/gc/export.c
src/cmd/gc/go.h
src/cmd/gc/go.y
src/cmd/gc/walk.c
test/fixedbugs/bug088.dir/bug0.go [moved from test/bugs/bug088.dir/bug0.go with 100% similarity]
test/fixedbugs/bug088.dir/bug1.go [moved from test/bugs/bug088.dir/bug1.go with 100% similarity]
test/fixedbugs/bug088.go [moved from test/bugs/bug088.go with 100% similarity]

index 427644e2e8320ca050fe8f37cef6f681c5598598..0fef1144e9e5d452312f9f2cb322a9d6de614a2b 100644 (file)
@@ -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)) {
-               print("redeclaring %S %lT => %lT\n", s, s->otype, t);
-               addtyp(newtype(s), t, PEXTERN);
-               return;
+       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);
+                       /*
+                        * 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);
 }
 
 /*
index 303c8cc52dd3fedc59426c277db4acaeadcec5b6..d80f6e77510a5a256263d6d61b8128e6da835795 100644 (file)
@@ -729,3 +729,4 @@ void        dowidth(Type*);
 void   argspace(int32);
 Node*  nodarg(Type*, int);
 void   nodconst(Node*, Type*, vlong);
+Type*  deep(Type*);
index 071d51b648e3f98cb2f767006011077fdd04e25f..d17f1fc6cb9a3f155a0c7178f018ec45cd17d4a1 100644 (file)
@@ -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;
        }
 
index 3856539ab3299a83eee463393ca172830d77ff8e..006d287e88b6a7aad39d623ad4f04103eae27588 100644 (file)
@@ -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)
similarity index 100%
rename from test/bugs/bug088.go
rename to test/fixedbugs/bug088.go