On Mon, Dec 02, 2002 at 02:20:33PM -0600, Esh, Andrew wrote:
> BTW: In the syntax below, it is also legal to have multiple cases stacked
> above a single statement, so "case {constant-expression} :" is legal, if it
> is followed by another case. I'm not sure if that's standard C,
The syntax in question was copied directly from the ANSI C standard, and
a {statement} is (from 3.6 "Statements"):
{statement}:
{labeled-statement}
{compound-statement}
{expression-statement}
{selection-statement}
{iteration-statement}
{jump-statement}
so you can stack labels (whether they're case labels, "default" labels,
or goto labels), as long as there's a statement after the last of the
labels, as a {labeled-statement} is a {statement} and thus you can have,
as a {labeled-statement}:
case {constant-expression} : {labeled-statement}
and thus
case {constant-expression} : case {constant-expression}: {labeled-statement}
and so on.
Powered by MHonArc 2.6.10