diff options
Diffstat (limited to 'src/cmd/compile/internal/noder')
-rw-r--r-- | src/cmd/compile/internal/noder/writer.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/noder/writer.go b/src/cmd/compile/internal/noder/writer.go index e5894c9..c317f39 100644 --- a/src/cmd/compile/internal/noder/writer.go +++ b/src/cmd/compile/internal/noder/writer.go @@ -1209,10 +1209,17 @@ func (w *writer) stmt(stmt syntax.Stmt) { func (w *writer) stmts(stmts []syntax.Stmt) { dead := false w.Sync(pkgbits.SyncStmts) - for _, stmt := range stmts { - if dead { - // Any statements after a terminating statement are safe to - // omit, at least until the next labeled statement. + var lastLabel = -1 + for i, stmt := range stmts { + if _, ok := stmt.(*syntax.LabeledStmt); ok { + lastLabel = i + } + } + for i, stmt := range stmts { + if dead && i > lastLabel { + // Any statements after a terminating and last label statement are safe to omit. + // Otherwise, code after label statement may refer to dead stmts between terminating + // and label statement, see issue #65593. if _, ok := stmt.(*syntax.LabeledStmt); !ok { continue } |