aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/testdata
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2024-11-03 21:27:00 +0700
committerGopher Robot <gobot@golang.org>2024-11-04 16:54:28 +0000
commitea38fa534559d1c25e629d0b1e96a730fa96780b (patch)
treee2bf710af8f27a1876810fe41e94ac38df4d2445 /src/cmd/compile/testdata
parent324f41b748fd87ad4a1cafa458bac3014f2fb5f2 (diff)
downloadgo-ea38fa534559d1c25e629d0b1e96a730fa96780b.tar.xz
cmd/compile: fix mis-compilation with labeled fallthrough
A fallthrough statement can be a labeled fallthrough per Go spec. However, the hasFallthrough function is not considering this case, causing mis-compilation. Fixing this by un-wrapping (possible nested) labeled fallthrough statements if any. Fixes #70173 Change-Id: Ic93d4fb75ff02703a32dfc63c3e84a8b7f78c261 Reviewed-on: https://go-review.googlesource.com/c/go/+/624717 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Youlin Feng <fengyoulin@live.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd/compile/testdata')
-rw-r--r--src/cmd/compile/testdata/script/issue70173.txt23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/cmd/compile/testdata/script/issue70173.txt b/src/cmd/compile/testdata/script/issue70173.txt
new file mode 100644
index 0000000000..20d4b4fcbe
--- /dev/null
+++ b/src/cmd/compile/testdata/script/issue70173.txt
@@ -0,0 +1,23 @@
+go run main.go
+! stdout .
+! stderr .
+
+-- main.go --
+
+package main
+
+func main() {
+ switch {
+ case true:
+ _:
+ fallthrough
+ default:
+ }
+ switch {
+ case true:
+ _:
+ _:
+ fallthrough
+ default:
+ }
+}