]> Cypherpunks repositories - gostls13.git/commitdiff
type n t;
authorRuss Cox <rsc@golang.org>
Fri, 3 Apr 2009 04:38:11 +0000 (21:38 -0700)
committerRuss Cox <rsc@golang.org>
Fri, 3 Apr 2009 04:38:11 +0000 (21:38 -0700)
was copying a bit too much about t into n,
like whether the signature was queued to be printed.
(bug reported by anton)

was also editing t, meaning you could do
type T int;
func (p int) Meth() { }

both fixed.

R=ken
OCL=27052
CL=27052

src/cmd/gc/dcl.c
src/cmd/gc/obj.c
src/cmd/gc/subr.c

index 51c76be752dc6f898ed5dc7446e1d6322564d74c..2d83d9f9fd92fd8d901e6ab26da22ba4a2b56769 100644 (file)
@@ -91,6 +91,7 @@ void
 updatetype(Type *n, Type *t)
 {
        Sym *s;
+       int local;
 
        s = n->sym;
        if(s == S || s->otype != n)
@@ -118,10 +119,19 @@ updatetype(Type *n, Type *t)
                fatal("updatetype %T / %T", n, t);
        }
 
-       if(n->local)
-               t->local = 1;
+       // decl was
+       //      type n t;
+       // copy t, but then zero out state associated with t
+       // that is no longer associated with n.
+       local = n->local;
        *n = *t;
        n->sym = s;
+       n->local = local;
+       n->siggen = 0;
+       n->methptr = 0;
+       n->printed = 0;
+       n->method = nil;
+       n->vargen = 0;
 
        // catch declaration of incomplete type
        switch(n->etype) {
index 7c80ee22a85f148ef5681dddfe614c6e3c6d5cba..9c0b6edb66a01d091a95abca5cc6b019585886dc 100644 (file)
@@ -425,6 +425,7 @@ dumpsignatures(void)
                t = d->dtype;
                et = t->etype;
                s = signame(t);
+//print("signame %S for %T\n", s, t);
                if(s == S)
                        continue;
 
index fe5d33084ec82c679c2227204eb1643f07434e03..fb8a1744a49eb8e711cb224bb8e54ff29b240b58 100644 (file)
@@ -1637,8 +1637,8 @@ signame(Type *t)
                ss->oname->class = PEXTERN;
        }
 
+//print("siggen %T %d\n", t, t->siggen);
        if(!t->siggen) {
-//print("siggen %T\n", t);
                // special case: don't generate the empty interface
                if(strcmp(buf, "empty") == 0)
                        goto out;