Commit 28279238 authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile: prevent ICE from misuse of [...]T arrays

Fixes #16428.

Change-Id: I78d37472e228402bb3c06d7ebd441952386fa38a
Reviewed-on: https://go-review.googlesource.com/31731
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
parent d553c29d
......@@ -344,12 +344,15 @@ OpSwitch:
if n.Left == nil {
t = typSlice(r.Type)
} else if n.Left.Op == ODDD {
t = typDDDArray(r.Type)
if top&Ecomplit == 0 && n.Diag == 0 {
t.Broke = true
n.Diag = 1
yyerror("use of [...] array outside of array literal")
if top&Ecomplit == 0 {
if n.Diag == 0 {
n.Diag = 1
yyerror("use of [...] array outside of array literal")
}
n.Type = nil
return n
}
t = typDDDArray(r.Type)
} else {
n.Left = indexlit(typecheck(n.Left, Erv))
l := n.Left
......
// errorcheck
// Copyright 2016 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 p
var (
b = [...]byte("abc") // ERROR "outside of array literal"
s = len(b)
)
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