]> Cypherpunks repositories - gostls13.git/commitdiff
gc: move typedcl2 into export.c
authorLuuk van Dijk <lvd@golang.org>
Tue, 29 Nov 2011 12:34:08 +0000 (13:34 +0100)
committerLuuk van Dijk <lvd@golang.org>
Tue, 29 Nov 2011 12:34:08 +0000 (13:34 +0100)
R=rsc
CC=golang-dev
https://golang.org/cl/5447043

src/cmd/gc/dcl.c
src/cmd/gc/export.c
src/cmd/gc/go.h

index da59e917fde173d1c509c319d4c7149bfdce9a99..a84b27c9ba7446b3e6dcb45ba3894da327ecdc68 100644 (file)
@@ -673,41 +673,6 @@ typedcl1(Node *n, Node *t, int local)
        return nod(ODCLTYPE, n, N);
 }
 
-/*
- * typedcl1 but during imports
- */
-void
-typedcl2(Type *pt, Type *t)
-{
-       Node *n;
-
-       // override declaration in unsafe.go for Pointer.
-       // there is no way in Go code to define unsafe.Pointer
-       // so we have to supply it.
-       if(incannedimport &&
-          strcmp(importpkg->name, "unsafe") == 0 &&
-          strcmp(pt->nod->sym->name, "Pointer") == 0) {
-               t = types[TUNSAFEPTR];
-       }
-
-       if(pt->etype == TFORW)
-               goto ok;
-       if(!eqtype(pt->orig, t))
-               yyerror("inconsistent definition for type %S during import\n\t%lT\n\t%lT", pt->sym, pt->orig, t);
-       return;
-
-ok:
-       n = pt->nod;
-       copytype(pt->nod, t);
-       // unzero nod
-       pt->nod = n;
-
-       pt->sym->lastlineno = parserline();
-       declare(n, PEXTERN);
-
-       checkwidth(pt);
-}
-
 /*
  * structs, functions, and methods.
  * they don't belong here, but where do they belong?
index d0b28a25b32e9692e14fdbc476f1aa107b49fda9..6938f0488907ddb5ecd773477b65d8061bc6a96d 100644 (file)
@@ -349,8 +349,31 @@ importvar(Sym *s, Type *t, int ctxt)
 void
 importtype(Type *pt, Type *t)
 {
-       if(pt != T && t != T)
-               typedcl2(pt, t);
+       Node *n;
+
+       if(pt != T && t != T) {
+               // override declaration in unsafe.go for Pointer.
+               // there is no way in Go code to define unsafe.Pointer
+               // so we have to supply it.
+               if(incannedimport &&
+                  strcmp(importpkg->name, "unsafe") == 0 &&
+                  strcmp(pt->nod->sym->name, "Pointer") == 0) {
+                       t = types[TUNSAFEPTR];
+               }
+
+               if(pt->etype == TFORW) {
+                       n = pt->nod;
+                       copytype(pt->nod, t);
+                       // unzero nod
+                       pt->nod = n;
+                       
+                       pt->sym->lastlineno = parserline();
+                       declare(n, PEXTERN);
+                       
+                       checkwidth(pt);
+               } else if(!eqtype(pt->orig, t))
+                       yyerror("inconsistent definition for type %S during import\n\t%lT\n\t%lT", pt->sym, pt->orig, t);
+       }
 
        if(debug['E'])
                print("import type %T %lT\n", pt, t);
index 217456c9a4bde57bd7070fef882d117fcc67cf71..7b121e6005549fe2beafeec88d3b2201c698e098 100644 (file)
@@ -964,7 +964,6 @@ Type*       tointerface(NodeList *l);
 Type*  tostruct(NodeList *l);
 Node*  typedcl0(Sym *s);
 Node*  typedcl1(Node *n, Node *t, int local);
-void   typedcl2(Type *pt, Type *t);
 Node*  typenod(Type *t);
 NodeList*      variter(NodeList *vl, Node *t, NodeList *el);