aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/noder')
-rw-r--r--src/cmd/compile/internal/noder/writer.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/noder/writer.go b/src/cmd/compile/internal/noder/writer.go
index 564087d912..f4b02f279d 100644
--- a/src/cmd/compile/internal/noder/writer.go
+++ b/src/cmd/compile/internal/noder/writer.go
@@ -3070,7 +3070,17 @@ func isPtrTo(from, to types2.Type) bool {
// hasFallthrough reports whether stmts ends in a fallthrough
// statement.
func hasFallthrough(stmts []syntax.Stmt) bool {
- last, ok := lastNonEmptyStmt(stmts).(*syntax.BranchStmt)
+ // From spec: the last non-empty statement may be a (possibly labeled) "fallthrough" statement
+ // Stripping (possible nested) labeled statement if any.
+ stmt := lastNonEmptyStmt(stmts)
+ for {
+ ls, ok := stmt.(*syntax.LabeledStmt)
+ if !ok {
+ break
+ }
+ stmt = ls.Stmt
+ }
+ last, ok := stmt.(*syntax.BranchStmt)
return ok && last.Tok == syntax.Fallthrough
}