mirror of
https://github.com/golang/go
synced 2024-11-02 08:01:26 +00:00
4347baac7d
Previously, we used OXFALL vs OFALL to distinguish fallthrough statements that had been validated. Because in the Node AST we flatten statement blocks, OXCASE and OXFALL needed to keep track of their block scopes for this purpose. Now that we have an AST that keeps these separate, we can just perform the validation earlier. Passes toolstash-check. Fixes #14540. Change-Id: I8421eaba16c2b3b72c9c5483b5cf20b14261385e Reviewed-on: https://go-review.googlesource.com/61130 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
20 lines
379 B
Go
20 lines
379 B
Go
// errorcheck
|
|
|
|
// Copyright 2017 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package p
|
|
|
|
func f(x int) {
|
|
switch x {
|
|
case 0:
|
|
fallthrough
|
|
; // ok
|
|
case 1:
|
|
fallthrough // ERROR "fallthrough statement out of place"
|
|
{}
|
|
case 2:
|
|
fallthrough // ERROR "cannot fallthrough"
|
|
}
|
|
}
|