|
9025 | 9025 | unsafe. \end{note} It shall appear at most once in each \grammarterm{attribute-list}. An
|
9026 | 9026 | \grammarterm{attribute-argument-clause} may be present and, if present, it shall have the form:
|
9027 | 9027 |
|
9028 |
| -\begin{codeblock} |
9029 |
| -( @\grammarterm{string-literal}@ ) |
9030 |
| -\end{codeblock} |
| 9028 | +\begin{ncbnf} |
| 9029 | +\terminal{(} string-literal \terminal{)} |
| 9030 | +\end{ncbnf} |
9031 | 9031 | \begin{note} The \grammarterm{string-literal} in the \grammarterm{attribute-argument-clause}
|
9032 | 9032 | could be used to explain the rationale for deprecation and/or to suggest a replacing entity.
|
9033 | 9033 | \end{note}
|
|
9235 | 9235 | The \grammarterm{attribute-token} \tcode{nodiscard}
|
9236 | 9236 | may be applied to the \grammarterm{declarator-id}
|
9237 | 9237 | in a function declaration or to the declaration of a class or enumeration.
|
9238 |
| -It shall appear at most once in each \grammarterm{attribute-list} and |
9239 |
| -no \grammarterm{attribute-argument-clause} shall be present. |
| 9238 | +It shall appear at most once in each \grammarterm{attribute-list}. |
| 9239 | +An \grammarterm{attribute-argument-clause} may be present |
| 9240 | +and, if present, it shall have the form: |
| 9241 | + |
| 9242 | +\begin{ncbnf} |
| 9243 | +\terminal{(} string-literal \terminal{)} |
| 9244 | +\end{ncbnf} |
| 9245 | + |
| 9246 | +\pnum |
| 9247 | +A name or entity declared without the \tcode{nodiscard} attribute |
| 9248 | +can later be redeclared with the attribute and vice-versa. |
| 9249 | +\begin{note} |
| 9250 | +Thus, an entity initially declared without the attribute |
| 9251 | +can be marked as \tcode{nodiscard} |
| 9252 | +by a subsequent redeclaration. |
| 9253 | +However, after an entity is marked as \tcode{nodiscard}, |
| 9254 | +later redeclarations do not remove the \tcode{nodiscard} |
| 9255 | +from the entity. |
| 9256 | +\end{note} |
| 9257 | +Redeclarations using different forms of the attribute |
| 9258 | +(with or without the \grammarterm{attribute-argument-clause} |
| 9259 | +or with different \grammarterm{attribute-argument-clause}s) |
| 9260 | +are allowed. |
9240 | 9261 |
|
9241 | 9262 | \pnum
|
9242 | 9263 | \begin{note}
|
|
9249 | 9270 | Implementations should issue a warning in such cases.
|
9250 | 9271 | This is typically because discarding the return value
|
9251 | 9272 | of a nodiscard call has surprising consequences.
|
| 9273 | +The \grammarterm{string-literal} |
| 9274 | +in a \tcode{nodiscard} \grammarterm{attribute-argument-clause} |
| 9275 | +is intended to be used in the message of the warning |
| 9276 | +as the rationale for why the result should not be discarded. |
9252 | 9277 | \end{note}
|
9253 | 9278 |
|
9254 | 9279 | \pnum
|
|
0 commit comments