cmd/gc: say 'non-constant array bound' instead of 'invalid array bound'

Fixes #8196.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/141510044
This commit is contained in:
Russ Cox 2014-09-16 10:21:54 -04:00
parent 3d2321f639
commit 8d61334dd5
2 changed files with 16 additions and 8 deletions

View file

@ -408,6 +408,9 @@ reswitch:
v = toint(l->val);
break;
default:
if(l->type != T && isint[l->type->etype] && l->op != OLITERAL)
yyerror("non-constant array bound %N", l);
else
yyerror("invalid array bound %N", l);
goto error;
}

View file

@ -13,3 +13,8 @@ var d ["abc"]int // ERROR "invalid array bound|not numeric"
var e [nil]int // ERROR "invalid array bound|not numeric"
var f [e]int // ERROR "invalid array bound|not constant"
var g [1 << 65]int // ERROR "array bound is too large|overflows"
var h [len(a)]int // ok
func ff() string
var i [len([1]string{ff()})]int // ERROR "non-constant array bound|not constant"