cmd/compile: address several more 1.6 TODOs in parser
- fix/check location of popdcl calls where questioned
- remove unnecessary handling of ... (LDDD) in ntype (couldn't be reached)
- inlined and fnret_type and simplified fnres as a consequence
- leave handling of ... (LDDD) in arg_list alone (remove TODO)
- verify that parser requires a ';' after last statement in a case/default
(added test case)
Fixes #13243.
Change-Id: Iad94b498591a5e85f4cb15bbc01e8e101415560d
Reviewed-on: https://go-review.googlesource.com/17155
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
diff --git a/test/switch2.go b/test/switch2.go
index 3582da8..11ff5c5 100644
--- a/test/switch2.go
+++ b/test/switch2.go
@@ -4,11 +4,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Check various syntax errors with switches.
+// Verify that erroneous switch statements are detected by the compiler.
+// Does not compile.
package main
-func _() {
+func f() {
switch {
case 0; // ERROR "expecting := or = or : or comma"
}
@@ -19,6 +20,20 @@
}
switch {
+ case 0: case 0: default:
+ }
+
+ switch {
+ case 0: f(); case 0:
+ case 0: f() case 0: // ERROR "unexpected case at end of statement"
+ }
+
+ switch {
+ case 0: f(); default:
+ case 0: f() default: // ERROR "unexpected default at end of statement"
+ }
+
+ switch {
if x: // ERROR "expecting case or default or }"
}
}