]> Cypherpunks repositories - gostls13.git/commitdiff
allow name-type or pointer-to-named-type as method name (bug046)
authorKen Thompson <ken@golang.org>
Sun, 10 Aug 2008 22:09:09 +0000 (15:09 -0700)
committerKen Thompson <ken@golang.org>
Sun, 10 Aug 2008 22:09:09 +0000 (15:09 -0700)
R=r
DELTA=17  (11 added, 3 deleted, 3 changed)
OCL=14048
CL=14048

src/cmd/gc/dcl.c

index 0025f4e65be8824ac34d46484f79e7a856892f02..2db8c325c45b09fe82327c25dc45bc7e27d4001d 100644 (file)
@@ -216,18 +216,26 @@ methcmp(Type *t1, Type *t2)
 Node*
 methodname(Node *n, Type *t)
 {
+       Sym *s;
+
+       s = S;
+       if(t->sym != S)
+               s = t->sym;
        if(isptr[t->etype])
                t = t->type;
-       if(t->etype != TSTRUCT)
-               goto bad;
-       if(t->sym == S)
-               goto bad;
+       if(t->sym != S)
+               s = t->sym;
+
+//     if(t->etype != TSTRUCT)
+//             goto bad;
 
-       snprint(namebuf, sizeof(namebuf), "%s_%s", t->sym->name, n->sym->name);
+       if(s == S)
+               goto bad;
+       snprint(namebuf, sizeof(namebuf), "%s_%s", s->name, n->sym->name);
        return newname(lookup(namebuf));
 
 bad:
-       yyerror("illegal <this> pointer");
+       yyerror("illegal <this> pointer: %T", t);
        return n;
 }