1
0
mirror of https://github.com/golang/go synced 2024-11-25 12:17:56 -07:00

gc: make sure main.main has correct type

R=ken2
CC=golang-dev
https://golang.org/cl/883049
This commit is contained in:
Russ Cox 2010-04-11 14:51:35 -07:00
parent d77010547d
commit fe7826858c
2 changed files with 10 additions and 3 deletions

View File

@ -1070,11 +1070,18 @@ fndcl:
$3 = checkarglist($3, 1); $3 = checkarglist($3, 1);
$$ = nod(ODCLFUNC, N, N); $$ = nod(ODCLFUNC, N, N);
$$->nname = $1; $$->nname = $1;
if($3 == nil && $5 == nil)
$$->nname = renameinit($1);
n = nod(OTFUNC, N, N); n = nod(OTFUNC, N, N);
n->list = $3; n->list = $3;
n->rlist = $5; n->rlist = $5;
if(strcmp($1->sym->name, "init") == 0) {
$$->nname = renameinit($1);
if($3 != nil || $5 != nil)
yyerror("func init must have no arguments and no return values");
}
if(strcmp(localpkg->name, "main") == 0 && strcmp($1->sym->name, "main") == 0) {
if($3 != nil || $5 != nil)
yyerror("func main must have no arguments and no return values");
}
// TODO: check if nname already has an ntype // TODO: check if nname already has an ntype
$$->nname->ntype = n; $$->nname->ntype = n;
funchdr($$); funchdr($$);

View File

@ -6,6 +6,6 @@
package main package main
func main (x int) { // GCCGO_ERROR "previous" func f (x int) { // GCCGO_ERROR "previous"
var x int; // ERROR "redecl|redefinition" var x int; // ERROR "redecl|redefinition"
} }