[dev.ssa] test: gofmt {goto,label,label1}.go

Change-Id: I971d0c93632e39aad4e2ba1862f085df820baf8b
Reviewed-on: https://go-review.googlesource.com/12431
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2015-07-20 13:00:28 -07:00
parent f421735bb4
commit ffbf209a7c
3 changed files with 37 additions and 39 deletions

View file

@ -40,7 +40,7 @@ L:
// goto across declaration not okay // goto across declaration not okay
func _() { func _() {
goto L // ERROR "goto L jumps over declaration of x at LINE+1|goto jumps over declaration" goto L // ERROR "goto L jumps over declaration of x at LINE+1|goto jumps over declaration"
x := 1 // GCCGO_ERROR "defined here" x := 1 // GCCGO_ERROR "defined here"
_ = x _ = x
L: L:
} }
@ -62,7 +62,7 @@ func _() {
x := 1 x := 1
_ = x _ = x
} }
x := 1 // GCCGO_ERROR "defined here" x := 1 // GCCGO_ERROR "defined here"
_ = x _ = x
L: L:
} }
@ -78,7 +78,7 @@ L:
// error shows first offending variable // error shows first offending variable
func _() { func _() {
goto L // ERROR "goto L jumps over declaration of x at LINE+1|goto jumps over declaration" goto L // ERROR "goto L jumps over declaration of x at LINE+1|goto jumps over declaration"
x := 1 // GCCGO_ERROR "defined here" x := 1 // GCCGO_ERROR "defined here"
_ = x _ = x
y := 1 y := 1
_ = y _ = y
@ -88,7 +88,7 @@ L:
// goto not okay even if code path is dead // goto not okay even if code path is dead
func _() { func _() {
goto L // ERROR "goto L jumps over declaration of x at LINE+1|goto jumps over declaration" goto L // ERROR "goto L jumps over declaration of x at LINE+1|goto jumps over declaration"
x := 1 // GCCGO_ERROR "defined here" x := 1 // GCCGO_ERROR "defined here"
_ = x _ = x
y := 1 y := 1
_ = y _ = y
@ -115,14 +115,14 @@ L:
// goto into inner block not okay // goto into inner block not okay
func _() { func _() {
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
{ // GCCGO_ERROR "block starts here" { // GCCGO_ERROR "block starts here"
L: L:
} }
} }
// goto backward into inner block still not okay // goto backward into inner block still not okay
func _() { func _() {
{ // GCCGO_ERROR "block starts here" { // GCCGO_ERROR "block starts here"
L: L:
} }
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
@ -133,7 +133,7 @@ func _() {
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
{ {
{ {
{ // GCCGO_ERROR "block starts here" { // GCCGO_ERROR "block starts here"
L: L:
} }
} }
@ -145,7 +145,7 @@ func _() {
goto L // ERROR "goto L jumps into block starting at LINE+3|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE+3|goto jumps into block"
x := 1 x := 1
_ = x _ = x
{ // GCCGO_ERROR "block starts here" { // GCCGO_ERROR "block starts here"
L: L:
} }
} }
@ -179,15 +179,15 @@ L:
} }
func _() { func _() {
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
if true { // GCCGO_ERROR "block starts here" if true { // GCCGO_ERROR "block starts here"
L: L:
} }
} }
func _() { func _() {
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
if true { // GCCGO_ERROR "block starts here" if true { // GCCGO_ERROR "block starts here"
L: L:
} else { } else {
} }
@ -196,13 +196,13 @@ func _() {
func _() { func _() {
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
if true { if true {
} else { // GCCGO_ERROR "block starts here" } else { // GCCGO_ERROR "block starts here"
L: L:
} }
} }
func _() { func _() {
if false { // GCCGO_ERROR "block starts here" if false { // GCCGO_ERROR "block starts here"
L: L:
} else { } else {
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
@ -212,7 +212,7 @@ func _() {
func _() { func _() {
if true { if true {
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
} else { // GCCGO_ERROR "block starts here" } else { // GCCGO_ERROR "block starts here"
L: L:
} }
} }
@ -220,7 +220,7 @@ func _() {
func _() { func _() {
if true { if true {
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
} else if false { // GCCGO_ERROR "block starts here" } else if false { // GCCGO_ERROR "block starts here"
L: L:
} }
} }
@ -228,7 +228,7 @@ func _() {
func _() { func _() {
if true { if true {
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
} else if false { // GCCGO_ERROR "block starts here" } else if false { // GCCGO_ERROR "block starts here"
L: L:
} else { } else {
} }
@ -243,7 +243,7 @@ func _() {
if true { if true {
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
} else if false { } else if false {
} else { // GCCGO_ERROR "block starts here" } else { // GCCGO_ERROR "block starts here"
L: L:
} }
} }
@ -287,14 +287,14 @@ func _() {
} }
func _() { func _() {
for { // GCCGO_ERROR "block starts here" for { // GCCGO_ERROR "block starts here"
L: L:
} }
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
} }
func _() { func _() {
for { // GCCGO_ERROR "block starts here" for { // GCCGO_ERROR "block starts here"
goto L goto L
L1: L1:
} }
@ -303,42 +303,42 @@ L:
} }
func _() { func _() {
for i < n { // GCCGO_ERROR "block starts here" for i < n { // GCCGO_ERROR "block starts here"
L: L:
} }
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
} }
func _() { func _() {
for i = 0; i < n; i++ { // GCCGO_ERROR "block starts here" for i = 0; i < n; i++ { // GCCGO_ERROR "block starts here"
L: L:
} }
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
} }
func _() { func _() {
for i = range x { // GCCGO_ERROR "block starts here" for i = range x { // GCCGO_ERROR "block starts here"
L: L:
} }
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
} }
func _() { func _() {
for i = range c { // GCCGO_ERROR "block starts here" for i = range c { // GCCGO_ERROR "block starts here"
L: L:
} }
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
} }
func _() { func _() {
for i = range m { // GCCGO_ERROR "block starts here" for i = range m { // GCCGO_ERROR "block starts here"
L: L:
} }
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
} }
func _() { func _() {
for i = range s { // GCCGO_ERROR "block starts here" for i = range s { // GCCGO_ERROR "block starts here"
L: L:
} }
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
@ -398,7 +398,7 @@ func _() {
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
switch i { switch i {
case 0: case 0:
L: // GCCGO_ERROR "block starts here" L: // GCCGO_ERROR "block starts here"
} }
} }
@ -406,7 +406,7 @@ func _() {
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
switch i { switch i {
case 0: case 0:
L: // GCCGO_ERROR "block starts here" L: // GCCGO_ERROR "block starts here"
; ;
default: default:
} }
@ -417,7 +417,7 @@ func _() {
switch i { switch i {
case 0: case 0:
default: default:
L: // GCCGO_ERROR "block starts here" L: // GCCGO_ERROR "block starts here"
} }
} }
@ -426,14 +426,14 @@ func _() {
default: default:
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
case 0: case 0:
L: // GCCGO_ERROR "block starts here" L: // GCCGO_ERROR "block starts here"
} }
} }
func _() { func _() {
switch i { switch i {
case 0: case 0:
L: // GCCGO_ERROR "block starts here" L: // GCCGO_ERROR "block starts here"
; ;
default: default:
goto L // ERROR "goto L jumps into block starting at LINE-4|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE-4|goto jumps into block"
@ -495,7 +495,7 @@ func _() {
goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block"
select { select {
case c <- 1: case c <- 1:
L: // GCCGO_ERROR "block starts here" L: // GCCGO_ERROR "block starts here"
} }
} }
@ -503,7 +503,7 @@ func _() {
goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block"
select { select {
case c <- 1: case c <- 1:
L: // GCCGO_ERROR "block starts here" L: // GCCGO_ERROR "block starts here"
; ;
default: default:
} }
@ -514,7 +514,7 @@ func _() {
select { select {
case <-c: case <-c:
default: default:
L: // GCCGO_ERROR "block starts here" L: // GCCGO_ERROR "block starts here"
} }
} }
@ -523,14 +523,14 @@ func _() {
default: default:
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
case <-c: case <-c:
L: // GCCGO_ERROR "block starts here" L: // GCCGO_ERROR "block starts here"
} }
} }
func _() { func _() {
select { select {
case <-c: case <-c:
L: // GCCGO_ERROR "block starts here" L: // GCCGO_ERROR "block starts here"
; ;
default: default:
goto L // ERROR "goto L jumps into block starting at LINE-4|goto jumps into block" goto L // ERROR "goto L jumps into block starting at LINE-4|goto jumps into block"

View file

@ -17,8 +17,7 @@ L1: // ERROR "label .*L1.* defined and not used"
for { for {
} }
L2: // ERROR "label .*L2.* defined and not used" L2: // ERROR "label .*L2.* defined and not used"
select { select {}
}
L3: // ERROR "label .*L3.* defined and not used" L3: // ERROR "label .*L3.* defined and not used"
switch { switch {
} }

View file

@ -4,7 +4,6 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// Verify that erroneous labels are caught by the compiler. // Verify that erroneous labels are caught by the compiler.
// This set is caught by pass 2. That's why this file is label1.go. // This set is caught by pass 2. That's why this file is label1.go.
// Does not compile. // Does not compile.