Skip to content

Commit 73bfbf2

Browse files
jensmaurerzygoloid
authored andcommitted
[stmt.while] Generalize the equivalence for a declaration as the condition.
1 parent 1d50d2d commit 73bfbf2

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

source/statements.tex

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -510,26 +510,23 @@
510510
When the condition of a \tcode{while} statement is a declaration, the scope of
511511
the variable that is declared extends from its point of
512512
declaration\iref{basic.scope.pdecl} to the end of the \tcode{while}
513-
\grammarterm{statement}. A \tcode{while} statement of the form
514-
515-
\begin{codeblock}
516-
while (T t = x) @\grammarterm{statement}@
517-
\end{codeblock}
518-
513+
\grammarterm{statement}. A \tcode{while} statement whose \grammarterm{condition}
514+
is an initialized declaration of some variable \tcode{t}
519515
is equivalent to
520516

521517
\begin{codeblock}
522518
label:
523519
{ // start of condition scope
524-
T t = x;
520+
@\grammarterm{condition}@ ; @\,@// declares \tcode{t}
525521
if (t) {
526522
@\grammarterm{statement}@
527523
goto label;
528524
}
529525
} // end of condition scope
530526
\end{codeblock}
531527

532-
The variable created in a condition is destroyed and created with each
528+
\begin{note}
529+
The variable created in the condition is destroyed and created with each
533530
iteration of the loop.
534531
\begin{example}
535532

@@ -551,6 +548,7 @@
551548
once for the condition that succeeds and once for the condition that
552549
fails.
553550
\end{example}
551+
\end{note}
554552

555553
\rSec2[stmt.do]{The \tcode{do} statement}%
556554
\indextext{statement!\idxcode{do}}

0 commit comments

Comments
 (0)