Commit 258c817a authored by Ken Thompson's avatar Ken Thompson

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
parent b89c5384
...@@ -216,18 +216,26 @@ methcmp(Type *t1, Type *t2) ...@@ -216,18 +216,26 @@ methcmp(Type *t1, Type *t2)
Node* Node*
methodname(Node *n, Type *t) methodname(Node *n, Type *t)
{ {
Sym *s;
s = S;
if(t->sym != S)
s = t->sym;
if(isptr[t->etype]) if(isptr[t->etype])
t = t->type; t = t->type;
if(t->etype != TSTRUCT) if(t->sym != S)
goto bad; s = t->sym;
if(t->sym == S)
goto bad; // 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)); return newname(lookup(namebuf));
bad: bad:
yyerror("illegal <this> pointer"); yyerror("illegal <this> pointer: %T", t);
return n; return n;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment