| 
									
										
										
										
											2012-02-16 23:50:37 -05:00
										 |  |  | // errorcheck | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-10 14:32:26 -07:00
										 |  |  | // Copyright 2011 The Go Authors. All rights reserved. | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | // Use of this source code is governed by a BSD-style | 
					
						
							|  |  |  | // license that can be found in the LICENSE file. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-19 14:28:53 +11:00
										 |  |  | // Verify goto semantics. | 
					
						
							|  |  |  | // Does not compile. | 
					
						
							|  |  |  | // | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | // Each test is in a separate function just so that if the | 
					
						
							|  |  |  | // compiler stops processing after one error, we don't | 
					
						
							|  |  |  | // lose other ones. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | package main | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var ( | 
					
						
							|  |  |  | 	i, n int | 
					
						
							|  |  |  | 	x    []int | 
					
						
							|  |  |  | 	c    chan int | 
					
						
							|  |  |  | 	m    map[int]int | 
					
						
							|  |  |  | 	s    string | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // goto after declaration okay | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	x := 1 | 
					
						
							|  |  |  | 	goto L | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | 	_ = x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // goto before declaration okay | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	goto L | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | 	x := 1 | 
					
						
							|  |  |  | 	_ = x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // goto across declaration not okay | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2011-09-20 14:45:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps over declaration of x at LINE+1|goto jumps over declaration" | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	x := 1 // GCCGO_ERROR "defined here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	_ = x | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // goto across declaration in inner scope okay | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	goto L | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		x := 1 | 
					
						
							|  |  |  | 		_ = x | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // goto across declaration after inner scope not okay | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2011-09-20 14:45:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps over declaration of x at LINE+5|goto jumps over declaration" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		x := 1 | 
					
						
							|  |  |  | 		_ = x | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	x := 1 // GCCGO_ERROR "defined here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	_ = x | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // goto across declaration in reverse okay | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | 	x := 1 | 
					
						
							|  |  |  | 	_ = x | 
					
						
							|  |  |  | 	goto L | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // error shows first offending variable | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps over declaration of y at LINE+3|goto jumps over declaration" | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	x := 1 // GCCGO_ERROR "defined here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	_ = x | 
					
						
							|  |  |  | 	y := 1 | 
					
						
							|  |  |  | 	_ = y | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // goto not okay even if code path is dead | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps over declaration of y at LINE+3|goto jumps over declaration" | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	x := 1 // GCCGO_ERROR "defined here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	_ = x | 
					
						
							|  |  |  | 	y := 1 | 
					
						
							|  |  |  | 	_ = y | 
					
						
							|  |  |  | 	return | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // goto into outer block okay | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // goto backward into outer block okay | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // goto into inner block not okay | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	{      // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // goto backward into inner block still not okay | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	{ // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // error shows first (outermost) offending block | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE+3|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 			{ // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 			L: | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // error prefers block diagnostic over declaration diagnostic | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE+3|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	x := 1 | 
					
						
							|  |  |  | 	_ = x | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	{ // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // many kinds of blocks, all invalid to jump into or among, | 
					
						
							|  |  |  | // but valid to jump out of | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // if | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | 	if true { | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | 	if true { | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | 	if false { | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L    // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	if true { // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L    // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	if true { // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	if true { | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	} else { // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	if false { // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 		goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	if true { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 		goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	} else { // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	if true { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 		goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	} else if false { // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	if true { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 		goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	} else if false { // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	// This one is tricky.  There is an implicit scope | 
					
						
							|  |  |  | 	// starting at the second if statement, and it contains | 
					
						
							|  |  |  | 	// the final else, so the outermost offending scope | 
					
						
							|  |  |  | 	// really is LINE+1 (like in the previous test), | 
					
						
							|  |  |  | 	// even though it looks like it might be LINE+3 instead. | 
					
						
							|  |  |  | 	if true { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 		goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	} else if false { | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	} else { // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Want to enable these tests but gofmt mangles them.  Issue 1972. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	// This one is okay, because the else is in the | 
					
						
							|  |  |  | 	// implicit whole-if block and has no inner block | 
					
						
							|  |  |  | 	// (no { }) around it. | 
					
						
							|  |  |  | 	if true { | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	} else | 
					
						
							|  |  |  | 		L: | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	// Still not okay. | 
					
						
							| 
									
										
										
										
											2011-09-20 14:45:54 -07:00
										 |  |  | 	if true {	//// GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} else | 
					
						
							| 
									
										
										
										
											2011-09-20 14:45:54 -07:00
										 |  |  | 		goto L //// ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // for | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	for { | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	for { | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	for { // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	for { // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 		goto L | 
					
						
							|  |  |  | 	L1: | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | L: | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L1 // ERROR "goto L1 jumps into block starting at LINE-5|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	for i < n { // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	for i = 0; i < n; i++ { // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	for i = range x { // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	for i = range c { // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	for i = range m { // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	for i = range s { // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // switch | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | 	switch i { | 
					
						
							|  |  |  | 	case 0: | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | 	switch i { | 
					
						
							|  |  |  | 	case 0: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	switch i { | 
					
						
							|  |  |  | 	case 0: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 	L: | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	switch i { | 
					
						
							|  |  |  | 	case 0: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	switch i { | 
					
						
							|  |  |  | 	case 0: | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	L: | 
					
						
							|  |  |  | 		; | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	switch i { | 
					
						
							|  |  |  | 	case 0: | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	L: // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	switch i { | 
					
						
							|  |  |  | 	case 0: | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	L: // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 		; | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE+3|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	switch i { | 
					
						
							|  |  |  | 	case 0: | 
					
						
							|  |  |  | 	default: | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	L: // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	switch i { | 
					
						
							|  |  |  | 	default: | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 		goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	case 0: | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	L: // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	switch i { | 
					
						
							|  |  |  | 	case 0: | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	L: // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 		; | 
					
						
							|  |  |  | 	default: | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 		goto L // ERROR "goto L jumps into block starting at LINE-4|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // select | 
					
						
							|  |  |  | // different from switch.  the statement has no implicit block around it. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | 	select { | 
					
						
							|  |  |  | 	case <-c: | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | L: | 
					
						
							|  |  |  | 	select { | 
					
						
							|  |  |  | 	case c <- 1: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	select { | 
					
						
							|  |  |  | 	case <-c: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 	L: | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	select { | 
					
						
							|  |  |  | 	case c <- 1: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	L: | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	select { | 
					
						
							|  |  |  | 	case <-c: | 
					
						
							|  |  |  | 		goto L | 
					
						
							|  |  |  | 	L: | 
					
						
							|  |  |  | 		; | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	select { | 
					
						
							|  |  |  | 	case c <- 1: | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	L: // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	select { | 
					
						
							|  |  |  | 	case c <- 1: | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	L: // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 		; | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 	goto L // ERROR "goto L jumps into block starting at LINE+3|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	select { | 
					
						
							|  |  |  | 	case <-c: | 
					
						
							|  |  |  | 	default: | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	L: // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	select { | 
					
						
							|  |  |  | 	default: | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 		goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	case <-c: | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	L: // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _() { | 
					
						
							|  |  |  | 	select { | 
					
						
							|  |  |  | 	case <-c: | 
					
						
							| 
									
										
										
										
											2015-07-20 13:00:28 -07:00
										 |  |  | 	L: // GCCGO_ERROR "block starts here" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 		; | 
					
						
							|  |  |  | 	default: | 
					
						
							| 
									
										
										
										
											2017-04-18 17:16:54 -07:00
										 |  |  | 		goto L // ERROR "goto L jumps into block starting at LINE-4|goto jumps into block" | 
					
						
							| 
									
										
										
										
											2011-06-20 14:06:00 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | } |