Commit 833dae6d authored by Jan Ziak's avatar Jan Ziak

cmd/gc: fix spurious 'const initializer is not a constant' error

Fixes #6403

LGTM=rsc
R=iant, rsc
CC=golang-codereviews
https://golang.org/cl/72840044
parent 4ffc7992
......@@ -2243,6 +2243,7 @@ adddot(Node *n)
int c, d;
typecheck(&n->left, Etype|Erv);
n->diag |= n->left->diag;
t = n->left->type;
if(t == T)
goto ret;
......
......@@ -3174,7 +3174,10 @@ typecheckdef(Node *n)
goto ret;
}
if(e->type != T && e->op != OLITERAL || !isgoconst(e)) {
yyerror("const initializer %N is not a constant", e);
if(!e->diag) {
yyerror("const initializer %N is not a constant", e);
e->diag = 1;
}
goto ret;
}
t = n->type;
......
// errorcheck
// Copyright 2014 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.
// Issue 6403: fix spurious 'const initializer is not a constant' error
package p
import "syscall"
const A int = syscall.X // ERROR "undefined: syscall.X"
const B int = voidpkg.X // ERROR "undefined: voidpkg"
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