modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/issue8042.go (about) 1 // compile 2 3 // Copyright 2017 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 // Verify that gotos across non-variable declarations 8 // are accepted. 9 10 package p 11 12 func _() { 13 goto L1 14 const x = 0 15 L1: 16 goto L2 17 type T int 18 L2: 19 } 20 21 func _() { 22 { 23 goto L1 24 } 25 const x = 0 26 L1: 27 { 28 goto L2 29 } 30 type T int 31 L2: 32 } 33 34 func _(d int) { 35 if d > 0 { 36 goto L1 37 } else { 38 goto L2 39 } 40 const x = 0 41 L1: 42 switch d { 43 case 1: 44 goto L3 45 case 2: 46 default: 47 goto L4 48 } 49 type T1 int 50 L2: 51 const y = 1 52 L3: 53 for d > 0 { 54 if d < 10 { 55 goto L4 56 } 57 } 58 type T2 int 59 L4: 60 select { 61 default: 62 goto L5 63 } 64 type T3 int 65 L5: 66 }