aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2024-02-21 18:50:11 +0700
committerGopher Robot <gobot@golang.org>2024-02-27 21:07:10 +0000
commitb847d4cd2c2293d025720d4ae57b2e9578831d29 (patch)
treeb29f2c8dd0493884252b81ca535940fb8b083101 /test
parentfdb200834feb8bd8e5d0073d83c51f68e364d0fd (diff)
downloadgo-b847d4cd2c2293d025720d4ae57b2e9578831d29.tar.gz
go-b847d4cd2c2293d025720d4ae57b2e9578831d29.zip
cmd/compile: fix early deadcode with label statement
CL 517775 moved early deadcode into unified writer. with new way to handle dead code with label statement involved: any statements after terminating statement will be considered dead until next label statement. However, this is not safe, because code after label statement may still refer to dead statements between terminating and label statement. It's only safe to remove statements after terminating *and* label one. Fixes #65593 Change-Id: Idb630165240931fad50789304a9e4535f51f56e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/565596 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/fixedbugs/issue65593.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/fixedbugs/issue65593.go b/test/fixedbugs/issue65593.go
new file mode 100644
index 0000000000..892a78122e
--- /dev/null
+++ b/test/fixedbugs/issue65593.go
@@ -0,0 +1,21 @@
+// compile
+
+// Copyright 2024 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
+
+const run = false
+
+func f() {
+ if !run {
+ return
+ }
+
+ messages := make(chan struct{}, 1)
+main:
+ for range messages {
+ break main
+ }
+}