tmp/tmphw3oj3vd/{from.md → to.md}
RENAMED
|
@@ -1,36 +1,45 @@
|
|
| 1 |
### Maybe unused attribute <a id="dcl.attr.unused">[[dcl.attr.unused]]</a>
|
| 2 |
|
| 3 |
-
The *attribute-token* `maybe_unused` indicates that a name
|
| 4 |
-
possibly intentionally unused. No *attribute-argument-clause*
|
| 5 |
-
present.
|
| 6 |
|
| 7 |
-
The attribute may be applied to the declaration of a class,
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
|
| 11 |
A name or entity declared without the `maybe_unused` attribute can later
|
| 12 |
be redeclared with the attribute and vice versa. An entity is considered
|
| 13 |
marked after the first declaration that marks it.
|
| 14 |
|
| 15 |
*Recommended practice:* For an entity marked `maybe_unused`,
|
| 16 |
implementations should not emit a warning that the entity or its
|
| 17 |
structured bindings (if any) are used or unused. For a structured
|
| 18 |
binding declaration not marked `maybe_unused`, implementations should
|
| 19 |
not emit such a warning unless all of its structured bindings are
|
| 20 |
-
unused.
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
[*Example 1*:
|
| 23 |
|
| 24 |
``` cpp
|
| 25 |
[[maybe_unused]] void f([[maybe_unused]] bool thing1,
|
| 26 |
[[maybe_unused]] bool thing2) {
|
| 27 |
[[maybe_unused]] bool b = thing1 && thing2;
|
| 28 |
assert(b);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
}
|
| 30 |
```
|
| 31 |
|
| 32 |
-
Implementations should not warn that `b` is unused, whether or
|
| 33 |
-
`NDEBUG` is defined.
|
| 34 |
|
| 35 |
— *end example*]
|
| 36 |
|
|
|
|
| 1 |
### Maybe unused attribute <a id="dcl.attr.unused">[[dcl.attr.unused]]</a>
|
| 2 |
|
| 3 |
+
The *attribute-token* `maybe_unused` indicates that a name, label, or
|
| 4 |
+
entity is possibly intentionally unused. No *attribute-argument-clause*
|
| 5 |
+
shall be present.
|
| 6 |
|
| 7 |
+
The attribute may be applied to the declaration of a class, type alias,
|
| 8 |
+
variable (including a structured binding declaration), structured
|
| 9 |
+
binding, result binding [[dcl.contract.res]], non-static data member,
|
| 10 |
+
function, enumeration, or enumerator, or to an *identifier* label
|
| 11 |
+
[[stmt.label]].
|
| 12 |
|
| 13 |
A name or entity declared without the `maybe_unused` attribute can later
|
| 14 |
be redeclared with the attribute and vice versa. An entity is considered
|
| 15 |
marked after the first declaration that marks it.
|
| 16 |
|
| 17 |
*Recommended practice:* For an entity marked `maybe_unused`,
|
| 18 |
implementations should not emit a warning that the entity or its
|
| 19 |
structured bindings (if any) are used or unused. For a structured
|
| 20 |
binding declaration not marked `maybe_unused`, implementations should
|
| 21 |
not emit such a warning unless all of its structured bindings are
|
| 22 |
+
unused. For a label to which `maybe_unused` is applied, implementations
|
| 23 |
+
should not emit a warning that the label is used or unused. The value of
|
| 24 |
+
a *has-attribute-expression* for the `maybe_unused` attribute should be
|
| 25 |
+
`0` if the attribute does not cause suppression of such warnings.
|
| 26 |
|
| 27 |
[*Example 1*:
|
| 28 |
|
| 29 |
``` cpp
|
| 30 |
[[maybe_unused]] void f([[maybe_unused]] bool thing1,
|
| 31 |
[[maybe_unused]] bool thing2) {
|
| 32 |
[[maybe_unused]] bool b = thing1 && thing2;
|
| 33 |
assert(b);
|
| 34 |
+
#ifdef NDEBUG
|
| 35 |
+
goto x;
|
| 36 |
+
#endif
|
| 37 |
+
[[maybe_unused]] x:
|
| 38 |
}
|
| 39 |
```
|
| 40 |
|
| 41 |
+
Implementations should not warn that `b` or `x` is unused, whether or
|
| 42 |
+
not `NDEBUG` is defined.
|
| 43 |
|
| 44 |
— *end example*]
|
| 45 |
|