Commit 32dffef0 authored by Shenghou Ma's avatar Shenghou Ma Committed by Russ Cox

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
parent dc370995
......@@ -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;
......
// 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)
}
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