From 67a6b4f0ef04e547e671230d84f96b00a2966113 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Fri, 1 Mar 2013 16:45:14 -0800 Subject: [PATCH] spec: fallthrough may not appear in last clause of a switch Replacement for CL 7370053 which attempted to make fallthrough's syntactically a part of switch statements. Because they may be labeled, fixing that CL completely would require too much spec surgery. Fixes #4923. R=r, iant, rsc, ken CC=golang-dev https://golang.org/cl/7416048 --- doc/go_spec.html | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index c5611cb1f7..0cb9f54b12 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -4154,12 +4154,14 @@ ExprSwitchCase = "case" ExpressionList | "default" .

-In a case or default clause, -the last statement only may be a "fallthrough" statement -(§Fallthrough statement) to +In a case or default clause, the last non-empty statement +may be a (possibly labeled) +"fallthrough" statement to indicate that control should flow from the end of this clause to the first statement of the next clause. Otherwise control flows to the end of the "switch" statement. +A "fallthrough" statement may appear as the last statement of all +but the last clause of an expression switch.

@@ -4798,9 +4800,8 @@ the "for" statement's block but the goto is not.

A "fallthrough" statement transfers control to the first statement of the -next case clause in a expression "switch" statement (§Expression switches). It may -be used only as the final non-empty statement in a case or default clause in an -expression "switch" statement. +next case clause in a expression "switch" statement. +It may be used only as the final non-empty statement in such a clause.

-- 
2.50.0