Commit 493a9d2f authored by Russ Cox's avatar Russ Cox

put toplevel & check back and add test

R=ken
OCL=17307
CL=17307
parent 2e4b8d94
...@@ -754,6 +754,8 @@ uexpr: ...@@ -754,6 +754,8 @@ 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
...@@ -1179,11 +1181,13 @@ xfndcl: ...@@ -1179,11 +1181,13 @@ 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:
......
// 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"
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