diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-16 19:27:12 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-16 19:27:12 +0000 |
commit | 0e07b82b3b3ec5af236400610939724e137f8e90 (patch) | |
tree | 1ff52042665843a28e0cf521c79aa33f5d52709e /src/cmd/compile/internal/noder | |
parent | Releasing progress-linux version 1.22.1-1~progress7.99u1. (diff) | |
download | golang-1.22-0e07b82b3b3ec5af236400610939724e137f8e90.tar.xz golang-1.22-0e07b82b3b3ec5af236400610939724e137f8e90.zip |
Merging upstream version 1.22.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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 } |