summaryrefslogtreecommitdiffstats
path: root/src/cmd/compile/internal/syntax/testdata/fallthrough.go
blob: 851da81ea04584891a03cc593da9f4d52fbdb694 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2022 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 fallthroughs

func _() {
	var x int
	switch x {
	case 0:
		fallthrough

	case 1:
		fallthrough // ERROR fallthrough statement out of place
		{
		}

	case 2:
		{
			fallthrough // ERROR fallthrough statement out of place
		}

	case 3:
		for {
			fallthrough // ERROR fallthrough statement out of place
		}

	case 4:
		fallthrough // trailing empty statements are ok
		;
		;

	case 5:
		fallthrough

	default:
		fallthrough // ERROR cannot fallthrough final case in switch
	}

	fallthrough // ERROR fallthrough statement out of place

	if true {
		fallthrough // ERROR fallthrough statement out of place
	}

	for {
		fallthrough // ERROR fallthrough statement out of place
	}

	var t any
	switch t.(type) {
	case int:
		fallthrough // ERROR cannot fallthrough in type switch
	}
}