mirror of
https://github.com/golang/go
synced 2024-11-21 22:04:39 -07:00
test: match gccgo error messages for goto.go and bug344.go
goto.go:39:2: error: goto jumps over declaration of ‘x’ goto.go:40:2: note: ‘x’ defined here goto.go:57:2: error: goto jumps over declaration of ‘x’ goto.go:62:2: note: ‘x’ defined here goto.go:77:2: error: goto jumps over declaration of ‘x’ goto.go:78:2: note: ‘x’ defined here goto.go:87:2: error: goto jumps over declaration of ‘x’ goto.go:88:2: note: ‘x’ defined here goto.go:114:2: error: goto jumps into block goto.go:115:2: note: goto target block starts here goto.go:125:2: error: goto jumps into block goto.go:122:2: note: goto target block starts here goto.go:130:2: error: goto jumps into block goto.go:133:4: note: goto target block starts here goto.go:142:2: error: goto jumps into block goto.go:145:2: note: goto target block starts here goto.go:179:2: error: goto jumps into block goto.go:180:10: note: goto target block starts here goto.go:186:2: error: goto jumps into block goto.go:187:10: note: goto target block starts here goto.go:194:2: error: goto jumps into block goto.go:196:4: note: goto target block starts here goto.go:205:3: error: goto jumps into block goto.go:202:11: note: goto target block starts here goto.go:211:3: error: goto jumps into block goto.go:212:4: note: goto target block starts here goto.go:219:3: error: goto jumps into block goto.go:220:18: note: goto target block starts here goto.go:227:3: error: goto jumps into block goto.go:228:18: note: goto target block starts here goto.go:241:3: error: goto jumps into block goto.go:243:4: note: goto target block starts here goto.go:290:2: error: goto jumps into block goto.go:287:6: note: goto target block starts here goto.go:299:2: error: goto jumps into block goto.go:294:6: note: goto target block starts here goto.go:306:2: error: goto jumps into block goto.go:303:12: note: goto target block starts here goto.go:313:2: error: goto jumps into block goto.go:310:24: note: goto target block starts here goto.go:320:2: error: goto jumps into block goto.go:317:18: note: goto target block starts here goto.go:327:2: error: goto jumps into block goto.go:324:18: note: goto target block starts here goto.go:334:2: error: goto jumps into block goto.go:331:18: note: goto target block starts here goto.go:341:2: error: goto jumps into block goto.go:338:18: note: goto target block starts here goto.go:395:2: error: goto jumps into block goto.go:398:2: note: goto target block starts here goto.go:403:2: error: goto jumps into block goto.go:406:2: note: goto target block starts here goto.go:413:2: error: goto jumps into block goto.go:417:2: note: goto target block starts here goto.go:424:3: error: goto jumps into block goto.go:426:2: note: goto target block starts here goto.go:436:3: error: goto jumps into block goto.go:433:2: note: goto target block starts here goto.go:492:2: error: goto jumps into block goto.go:495:2: note: goto target block starts here goto.go:500:2: error: goto jumps into block goto.go:503:2: note: goto target block starts here goto.go:510:2: error: goto jumps into block goto.go:514:2: note: goto target block starts here goto.go:521:3: error: goto jumps into block goto.go:523:2: note: goto target block starts here goto.go:533:3: error: goto jumps into block goto.go:530:2: note: goto target block starts here bug344.go:17:2: error: goto jumps into block bug344.go:20:21: note: goto target block starts here R=rsc CC=golang-dev https://golang.org/cl/5077044
This commit is contained in:
parent
5ee7ef90cd
commit
f1aefc0d36
@ -14,10 +14,10 @@ func main() {
|
||||
i := 42
|
||||
a := []*int{&i, &i, &i, &i}
|
||||
x := a[0]
|
||||
goto start // ERROR "goto start jumps into block"
|
||||
goto start // ERROR "jumps into block"
|
||||
z := 1
|
||||
_ = z
|
||||
for _, x = range a {
|
||||
for _, x = range a { // GCCGO_ERROR "block"
|
||||
start:
|
||||
fmt.Sprint(*x)
|
||||
}
|
||||
|
140
test/goto.go
140
test/goto.go
@ -36,8 +36,8 @@ L:
|
||||
|
||||
// goto across declaration not okay
|
||||
func _() {
|
||||
goto L // ERROR "goto L jumps over declaration of x at LINE+1"
|
||||
x := 1
|
||||
goto L // ERROR "goto L jumps over declaration of x at LINE+1|goto jumps over declaration"
|
||||
x := 1 // GCCGO_ERROR "defined here"
|
||||
_ = x
|
||||
L:
|
||||
}
|
||||
@ -54,12 +54,12 @@ L:
|
||||
|
||||
// goto across declaration after inner scope not okay
|
||||
func _() {
|
||||
goto L // ERROR "goto L jumps over declaration of x at LINE+5"
|
||||
goto L // ERROR "goto L jumps over declaration of x at LINE+5|goto jumps over declaration"
|
||||
{
|
||||
x := 1
|
||||
_ = x
|
||||
}
|
||||
x := 1
|
||||
x := 1 // GCCGO_ERROR "defined here"
|
||||
_ = x
|
||||
L:
|
||||
}
|
||||
@ -74,8 +74,8 @@ L:
|
||||
|
||||
// error shows first offending variable
|
||||
func _() {
|
||||
goto L // ERROR "goto L jumps over declaration of x at LINE+1"
|
||||
x := 1
|
||||
goto L // ERROR "goto L jumps over declaration of x at LINE+1|goto jumps over declaration"
|
||||
x := 1 // GCCGO_ERROR "defined here"
|
||||
_ = x
|
||||
y := 1
|
||||
_ = y
|
||||
@ -84,8 +84,8 @@ L:
|
||||
|
||||
// goto not okay even if code path is dead
|
||||
func _() {
|
||||
goto L // ERROR "goto L jumps over declaration of x at LINE+1"
|
||||
x := 1
|
||||
goto L // ERROR "goto L jumps over declaration of x at LINE+1|goto jumps over declaration"
|
||||
x := 1 // GCCGO_ERROR "defined here"
|
||||
_ = x
|
||||
y := 1
|
||||
_ = y
|
||||
@ -111,26 +111,26 @@ L:
|
||||
|
||||
// goto into inner block not okay
|
||||
func _() {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1"
|
||||
{
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
|
||||
{ // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
}
|
||||
}
|
||||
|
||||
// goto backward into inner block still not okay
|
||||
func _() {
|
||||
{
|
||||
{ // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
}
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
|
||||
}
|
||||
|
||||
// error shows first (outermost) offending block
|
||||
func _() {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
|
||||
{
|
||||
{
|
||||
{
|
||||
{ // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
}
|
||||
}
|
||||
@ -139,10 +139,10 @@ func _() {
|
||||
|
||||
// error prefers block diagnostic over declaration diagnostic
|
||||
func _() {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+3"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+3|goto jumps into block"
|
||||
x := 1
|
||||
_ = x
|
||||
{
|
||||
{ // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
}
|
||||
}
|
||||
@ -176,56 +176,56 @@ L:
|
||||
}
|
||||
|
||||
func _() {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1"
|
||||
if true {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
|
||||
if true { // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
}
|
||||
}
|
||||
|
||||
func _() {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1"
|
||||
if true {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
|
||||
if true { // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
func _() {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
|
||||
if true {
|
||||
} else {
|
||||
} else { // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
}
|
||||
}
|
||||
|
||||
func _() {
|
||||
if false {
|
||||
if false { // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
} else {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
|
||||
}
|
||||
}
|
||||
|
||||
func _() {
|
||||
if true {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1"
|
||||
} else {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
|
||||
} else { // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
}
|
||||
}
|
||||
|
||||
func _() {
|
||||
if true {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1"
|
||||
} else if false {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
|
||||
} else if false { // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
}
|
||||
}
|
||||
|
||||
func _() {
|
||||
if true {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1"
|
||||
} else if false {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
|
||||
} else if false { // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
} else {
|
||||
}
|
||||
@ -238,9 +238,9 @@ func _() {
|
||||
// really is LINE+1 (like in the previous test),
|
||||
// even though it looks like it might be LINE+3 instead.
|
||||
if true {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
|
||||
} else if false {
|
||||
} else {
|
||||
} else { // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
}
|
||||
}
|
||||
@ -259,10 +259,10 @@ func _() {
|
||||
|
||||
func _() {
|
||||
// Still not okay.
|
||||
if true {
|
||||
if true { //// GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
} else
|
||||
goto L //// ERROR "goto L jumps into block starting at LINE-3"
|
||||
goto L //// ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
|
||||
}
|
||||
|
||||
*/
|
||||
@ -284,61 +284,61 @@ func _() {
|
||||
}
|
||||
|
||||
func _() {
|
||||
for {
|
||||
for { // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
}
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
|
||||
}
|
||||
|
||||
func _() {
|
||||
for {
|
||||
for { // GCCGO_ERROR "block starts here"
|
||||
goto L
|
||||
L1:
|
||||
}
|
||||
L:
|
||||
goto L1 // ERROR "goto L1 jumps into block starting at LINE-5"
|
||||
goto L1 // ERROR "goto L1 jumps into block starting at LINE-5|goto jumps into block"
|
||||
}
|
||||
|
||||
func _() {
|
||||
for i < n {
|
||||
for i < n { // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
}
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
|
||||
}
|
||||
|
||||
func _() {
|
||||
for i = 0; i < n; i++ {
|
||||
for i = 0; i < n; i++ { // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
}
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
|
||||
}
|
||||
|
||||
func _() {
|
||||
for i = range x {
|
||||
for i = range x { // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
}
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
|
||||
}
|
||||
|
||||
func _() {
|
||||
for i = range c {
|
||||
for i = range c { // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
}
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
|
||||
}
|
||||
|
||||
func _() {
|
||||
for i = range m {
|
||||
for i = range m { // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
}
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
|
||||
}
|
||||
|
||||
func _() {
|
||||
for i = range s {
|
||||
for i = range s { // GCCGO_ERROR "block starts here"
|
||||
L:
|
||||
}
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block"
|
||||
}
|
||||
|
||||
// switch
|
||||
@ -392,48 +392,48 @@ func _() {
|
||||
}
|
||||
|
||||
func _() {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
|
||||
switch i {
|
||||
case 0:
|
||||
L:
|
||||
L: // GCCGO_ERROR "block starts here"
|
||||
}
|
||||
}
|
||||
|
||||
func _() {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
|
||||
switch i {
|
||||
case 0:
|
||||
L:
|
||||
L: // GCCGO_ERROR "block starts here"
|
||||
;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
func _() {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
|
||||
switch i {
|
||||
case 0:
|
||||
default:
|
||||
L:
|
||||
L: // GCCGO_ERROR "block starts here"
|
||||
}
|
||||
}
|
||||
|
||||
func _() {
|
||||
switch i {
|
||||
default:
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
|
||||
case 0:
|
||||
L:
|
||||
L: // GCCGO_ERROR "block starts here"
|
||||
}
|
||||
}
|
||||
|
||||
func _() {
|
||||
switch i {
|
||||
case 0:
|
||||
L:
|
||||
L: // GCCGO_ERROR "block starts here"
|
||||
;
|
||||
default:
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-4"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-4|goto jumps into block"
|
||||
}
|
||||
}
|
||||
|
||||
@ -489,47 +489,47 @@ func _() {
|
||||
}
|
||||
|
||||
func _() {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+2"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block"
|
||||
select {
|
||||
case c <- 1:
|
||||
L:
|
||||
L: // GCCGO_ERROR "block starts here"
|
||||
}
|
||||
}
|
||||
|
||||
func _() {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+2"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block"
|
||||
select {
|
||||
case c <- 1:
|
||||
L:
|
||||
L: // GCCGO_ERROR "block starts here"
|
||||
;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
func _() {
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+3"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+3|goto jumps into block"
|
||||
select {
|
||||
case <-c:
|
||||
default:
|
||||
L:
|
||||
L: // GCCGO_ERROR "block starts here"
|
||||
}
|
||||
}
|
||||
|
||||
func _() {
|
||||
select {
|
||||
default:
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block"
|
||||
case <-c:
|
||||
L:
|
||||
L: // GCCGO_ERROR "block starts here"
|
||||
}
|
||||
}
|
||||
|
||||
func _() {
|
||||
select {
|
||||
case <-c:
|
||||
L:
|
||||
L: // GCCGO_ERROR "block starts here"
|
||||
;
|
||||
default:
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-4"
|
||||
goto L // ERROR "goto L jumps into block starting at LINE-4|goto jumps into block"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user