put toplevel & check back and add test

R=ken
OCL=17307
CL=17307
This commit is contained in:
Russ Cox 2008-10-16 14:02:20 -07:00
parent 2e4b8d94cd
commit 493a9d2f42
2 changed files with 13 additions and 0 deletions

View File

@ -754,6 +754,8 @@ uexpr:
}
| '&' uexpr
{
if($2->op == OCONV && !func)
yyerror("& of composite literal at top level");
$$ = nod(OADDR, $2, N);
}
| '+' uexpr
@ -1179,11 +1181,13 @@ xfndcl:
{
maxarg = 0;
stksize = 0;
func++;
} fndcl fnbody
{
$$ = $3;
$$->nbody = $4;
funcbody($$);
func--;
}
fndcl:

9
test/addr.go Normal file
View File

@ -0,0 +1,9 @@
// errchk $G $D/$F.go
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
var a = &[]int{1,2}; // ERROR "composite"