mirror of
https://github.com/golang/go.git
synced 2024-09-22 02:48:50 +00:00
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;
|
||||
|
||||
|
12
test/fixedbugs/issue7794.go
Normal file
12
test/fixedbugs/issue7794.go
Normal file
@ -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
Block a user