]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: allow VARDEF at top level
authorKeith Randall <khr@golang.org>
Sat, 6 Oct 2018 15:56:03 +0000 (08:56 -0700)
committerKeith Randall <khr@golang.org>
Sat, 6 Oct 2018 16:28:04 +0000 (16:28 +0000)
This was missed as part of adding a top-level VARDEF
for stack tracing (CL 134156).

Fixes #28055

Change-Id: Id14748dfccb119197d788867d2ec6a3b3c9835cf
Reviewed-on: https://go-review.googlesource.com/c/140304
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
src/cmd/compile/internal/gc/walk.go
test/fixedbugs/issue28055.go [new file with mode: 0644]

index 1c398ef43cdff7cc57576692980ca98b0e5ab99f..80fdc55b5df47733e45437d951535494d51b5cd1 100644 (file)
@@ -211,6 +211,7 @@ func walkstmt(n *Node) *Node {
                ODCLCONST,
                ODCLTYPE,
                OCHECKNIL,
+               OVARDEF,
                OVARKILL,
                OVARLIVE:
                break
diff --git a/test/fixedbugs/issue28055.go b/test/fixedbugs/issue28055.go
new file mode 100644 (file)
index 0000000..d4889d5
--- /dev/null
@@ -0,0 +1,16 @@
+// compile
+
+// Copyright 2018 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.
+
+// Make sure VARDEF can be a top-level statement.
+
+package p
+
+func f() {
+       var s string
+       var as []string
+       switch false && (s+"a"+as[0]+s+as[0]+s == "") {
+       }
+}