From ea38fa534559d1c25e629d0b1e96a730fa96780b Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Sun, 3 Nov 2024 21:27:00 +0700 Subject: 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 Reviewed-by: Keith Randall Reviewed-by: Keith Randall Reviewed-by: Youlin Feng Auto-Submit: Cuong Manh Le LUCI-TryBot-Result: Go LUCI --- src/cmd/compile/testdata/script/issue70173.txt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/cmd/compile/testdata/script/issue70173.txt (limited to 'src/cmd/compile/testdata/script') 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: + } +} -- cgit v1.3