mirror of https://github.com/golang/go.git
cmd/gc: fix segfault in isgoconst.
Variables declared with 'var' have no sym->def. Fixes #7794. LGTM=rsc R=golang-codereviews, bradfitz, rsc CC=golang-codereviews https://golang.org/cl/88360043
This commit is contained in:
parent
dc370995a8
commit
32dffef098
|
|
@ -1594,7 +1594,7 @@ isgoconst(Node *n)
|
|||
|
||||
case ONAME:
|
||||
l = n->sym->def;
|
||||
if(l->op == OLITERAL && n->val.ctype != CTNIL)
|
||||
if(l && l->op == OLITERAL && n->val.ctype != CTNIL)
|
||||
return 1;
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
// compile
|
||||
|
||||
// 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.
|
||||
|
||||
package main
|
||||
|
||||
func main() {
|
||||
var a [10]int
|
||||
const ca = len(a)
|
||||
}
|
||||
Loading…
Reference in New Issue