From: Russ Cox Date: Thu, 25 Jun 2009 23:42:08 +0000 (-0700) Subject: package main X-Git-Tag: weekly.2009-11-06~1325 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=fa6df47986866d2e47cc1ee537227ca2286d162f;p=gostls13.git package main const foo = []int{1,2} x.go:3: expression must be a constant instead of x.go:3: fatal error: gettype: addtop R=ken OCL=30767 CL=30767 --- diff --git a/src/cmd/gc/dcl.c b/src/cmd/gc/dcl.c index 471319d0d9..c33ead564d 100644 --- a/src/cmd/gc/dcl.c +++ b/src/cmd/gc/dcl.c @@ -1684,7 +1684,7 @@ void constiter(Node *vv, Type *t, Node *cc) { Iter viter, citer; - Node *v, *c; + Node *v, *c, n1; if(cc == N) { if(t != T) @@ -1712,7 +1712,16 @@ loop: return; } - gettype(c, N); + memset(&n1, 0, sizeof n1); + gettype(c, &n1); + if(n1.ninit != nil) { + // the expression had extra code to run. + // dodclconst is going to print an error + // because the expression isn't constant, + // but out of paranoia, bump nerrors so + // that compile cannot succeed accidentally + nerrors++; + } if(t != T) convlit(c, t); if(t == T)