Remove elements that don't add value in ES.84 (#1390)

This commit is contained in:
Dave Smith 2019-03-21 13:04:49 -05:00 committed by Herb Sutter
parent 8301421762
commit c2a5785d7e

View File

@ -9884,7 +9884,7 @@ Statement rules:
* [ES.77: Minimize the use of `break` and `continue` in loops](#Res-continue) * [ES.77: Minimize the use of `break` and `continue` in loops](#Res-continue)
* [ES.78: Always end a non-empty `case` with a `break`](#Res-break) * [ES.78: Always end a non-empty `case` with a `break`](#Res-break)
* [ES.79: Use `default` to handle common cases (only)](#Res-default) * [ES.79: Use `default` to handle common cases (only)](#Res-default)
* [ES.84: Don't (try to) declare a local variable with no name](#Res-noname) * [ES.84: Don't try to declare a local variable with no name](#Res-noname)
* [ES.85: Make empty statements visible](#Res-empty) * [ES.85: Make empty statements visible](#Res-empty)
* [ES.86: Avoid modifying loop control variables inside the body of raw for-loops](#Res-loop-counter) * [ES.86: Avoid modifying loop control variables inside the body of raw for-loops](#Res-loop-counter)
* [ES.87: Don't add redundant `==` or `!=` to conditions](#Res-if) * [ES.87: Don't add redundant `==` or `!=` to conditions](#Res-if)
@ -12789,13 +12789,12 @@ Flag `switch`-statements over an enumeration that don't handle all enumerators a
This may yield too many false positives in some code bases; if so, flag only `switch`es that handle most but not all cases This may yield too many false positives in some code bases; if so, flag only `switch`es that handle most but not all cases
(that was the strategy of the very first C++ compiler). (that was the strategy of the very first C++ compiler).
### <a name="Res-noname"></a>ES.84: Don't (try to) declare a local variable with no name ### <a name="Res-noname"></a>ES.84: Don't try to declare a local variable with no name
##### Reason ##### Reason
There is no such thing. There is no such thing.
What looks to a human like a variable without a name is to the compiler a statement consisting of a temporary that immediately goes out of scope. What looks to a human like a variable without a name is to the compiler a statement consisting of a temporary that immediately goes out of scope.
To avoid unpleasant surprises.
##### Example, bad ##### Example, bad
@ -12808,7 +12807,6 @@ To avoid unpleasant surprises.
This declares an unnamed `lock` object that immediately goes out of scope at the point of the semicolon. This declares an unnamed `lock` object that immediately goes out of scope at the point of the semicolon.
This is not an uncommon mistake. This is not an uncommon mistake.
In particular, this particular example can lead to hard-to find race conditions. In particular, this particular example can lead to hard-to find race conditions.
There are exceedingly clever uses of this "idiom", but they are far rarer than the mistakes.
##### Note ##### Note
@ -12816,7 +12814,7 @@ Unnamed function arguments are fine.
##### Enforcement ##### Enforcement
Flag statements that are just a temporary Flag statements that are just a temporary.
### <a name="Res-empty"></a>ES.85: Make empty statements visible ### <a name="Res-empty"></a>ES.85: Make empty statements visible