From: Russ Cox Date: Fri, 3 Apr 2009 04:38:11 +0000 (-0700) Subject: type n t; X-Git-Tag: weekly.2009-11-06~1900 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=07687705a4c2db718a3601d3558807833938dfbf;p=gostls13.git type n t; 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 --- diff --git a/src/cmd/gc/dcl.c b/src/cmd/gc/dcl.c index 51c76be752..2d83d9f9fd 100644 --- a/src/cmd/gc/dcl.c +++ b/src/cmd/gc/dcl.c @@ -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) { diff --git a/src/cmd/gc/obj.c b/src/cmd/gc/obj.c index 7c80ee22a8..9c0b6edb66 100644 --- a/src/cmd/gc/obj.c +++ b/src/cmd/gc/obj.c @@ -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; diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c index fe5d33084e..fb8a1744a4 100644 --- a/src/cmd/gc/subr.c +++ b/src/cmd/gc/subr.c @@ -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;