]> Cypherpunks repositories - gostls13.git/commitdiff
export
authorKen Thompson <ken@golang.org>
Sat, 27 Sep 2008 00:41:23 +0000 (17:41 -0700)
committerKen Thompson <ken@golang.org>
Sat, 27 Sep 2008 00:41:23 +0000 (17:41 -0700)
R=r
OCL=16018
CL=16022

src/cmd/6g/cgen.c
src/cmd/gc/export.c

index 51cf162f94532e24e3b53226b55b7c0273eb0845..c47c016e75bc5dc3acfd8a58dfa03dc73c535b97 100644 (file)
@@ -386,6 +386,9 @@ agen(Node *n, Node *res)
                // i is in &n1
                // w is width
 
+               if(w == 0)
+                       fatal("index is zero width");
+
                if(isptrdarray(nl->type)) {
                        regalloc(&n2, types[tptr], res);
                        gmove(res, &n2);
index d4e5b0d193c3926f7f09d096c4e6f9cc535363dd..119fc43136c5c318de4889e3bb1baa6b321541ab 100644 (file)
@@ -506,15 +506,18 @@ importaddtyp(Node *ss, Type *t)
        Sym *s;
 
        s = getimportsym(ss);
-       if(s->otype != T && !eqtype(t, s->otype, 0)) {
-               if(!isptrto(t, TFORW))
-                       yyerror("import redeclaration of %lS %lT => %lT\n",
-                               s, s->otype, t);
-               s->otype = t;
+       if(s->otype != T) {
+               // here we should try to discover if
+               // the new type is the same as the old type
+               if(eqtype(t, s->otype, 0))
+                       return;
+               if(isptrto(t, TFORW))
+                       return; // hard part
+               warn("redeclare import %S from %lT to %lT",
+                       s, s->otype, t);
+               return;
        }
-
-       if(s->otype == T)
-               addtyp(newtype(s), t, PEXTERN);
+       addtyp(newtype(s), t, PEXTERN);
 }
 
 /*