diagnosed some incorrect

inputs for method receivers.

R=r
OCL=17304
CL=17304
This commit is contained in:
Ken Thompson 2008-10-16 13:29:03 -07:00
parent b705ac6cf5
commit 2e4b8d94cd

View File

@ -754,8 +754,6 @@ uexpr:
} }
| '&' uexpr | '&' uexpr
{ {
if($2->op == OCONV && !func)
yyerror("& of composite literal at top level");
$$ = nod(OADDR, $2, N); $$ = nod(OADDR, $2, N);
} }
| '+' uexpr | '+' uexpr
@ -1181,13 +1179,11 @@ xfndcl:
{ {
maxarg = 0; maxarg = 0;
stksize = 0; stksize = 0;
func++;
} fndcl fnbody } fndcl fnbody
{ {
$$ = $3; $$ = $3;
$$->nbody = $4; $$->nbody = $4;
funcbody($$); funcbody($$);
func--;
} }
fndcl: fndcl:
@ -1207,15 +1203,22 @@ fndcl:
b0stack = dclstack; // mark base for fn literals b0stack = dclstack; // mark base for fn literals
$$ = nod(ODCLFUNC, N, N); $$ = nod(ODCLFUNC, N, N);
t = ismethod($2->type); if(listcount($2) == 1) {
if(t != T) t = ismethod($2->type);
$$->nname = methodname($4, t);
else
$$->nname = $4; $$->nname = $4;
$$->type = functype($2, $6, $8); if(t != T)
funchdr($$); $$->nname = methodname($4, t);
$$->type = functype($2, $6, $8);
funchdr($$);
addmethod($4, $$->type, 1);
} else {
/* declare it as a function */
yyerror("unknown method receiver");
$$->nname = $4;
$$->type = functype(N, $6, $8);
funchdr($$);
}
addmethod($4, $$->type, 1);
} }
fntype: fntype: