From 258c817a1b14acc5f24e96e03e6fad1ea6d18c19 Mon Sep 17 00:00:00 2001 From: Ken Thompson Date: Sun, 10 Aug 2008 15:09:09 -0700 Subject: [PATCH] allow name-type or pointer-to-named-type as method name (bug046) R=r DELTA=17 (11 added, 3 deleted, 3 changed) OCL=14048 CL=14048 --- src/cmd/gc/dcl.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/cmd/gc/dcl.c b/src/cmd/gc/dcl.c index 0025f4e65be..2db8c325c45 100644 --- a/src/cmd/gc/dcl.c +++ b/src/cmd/gc/dcl.c @@ -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; - snprint(namebuf, sizeof(namebuf), "%s_%s", t->sym->name, n->sym->name); +// if(t->etype != TSTRUCT) +// goto bad; + + if(s == S) + goto bad; + snprint(namebuf, sizeof(namebuf), "%s_%s", s->name, n->sym->name); return newname(lookup(namebuf)); bad: - yyerror("illegal pointer"); + yyerror("illegal pointer: %T", t); return n; }