|
9012 | 9012 | unsafe. \end{note} It shall appear at most once in each \grammarterm{attribute-list}. An
|
9013 | 9013 | \grammarterm{attribute-argument-clause} may be present and, if present, it shall have the form:
|
9014 | 9014 |
|
9015 |
| -\begin{codeblock} |
9016 |
| -( @\grammarterm{string-literal}@ ) |
9017 |
| -\end{codeblock} |
| 9015 | +\begin{ncbnf} |
| 9016 | +\terminal{(} string-literal \terminal{)} |
| 9017 | +\end{ncbnf} |
9018 | 9018 | \begin{note} The \grammarterm{string-literal} in the \grammarterm{attribute-argument-clause}
|
9019 | 9019 | could be used to explain the rationale for deprecation and/or to suggest a replacing entity.
|
9020 | 9020 | \end{note}
|
|
9207 | 9207 | The \grammarterm{attribute-token} \tcode{nodiscard}
|
9208 | 9208 | may be applied to the \grammarterm{declarator-id}
|
9209 | 9209 | in a function declaration or to the declaration of a class or enumeration.
|
9210 |
| -It shall appear at most once in each \grammarterm{attribute-list} and |
9211 |
| -no \grammarterm{attribute-argument-clause} shall be present. |
| 9210 | +It shall appear at most once in each \grammarterm{attribute-list}. |
| 9211 | +An \grammarterm{attribute-argument-clause} may be present |
| 9212 | +and, if present, it shall have the form: |
| 9213 | + |
| 9214 | +\begin{ncbnf} |
| 9215 | +\terminal{(} string-literal \terminal{)} |
| 9216 | +\end{ncbnf} |
| 9217 | + |
| 9218 | +\pnum |
| 9219 | +A name or entity declared without the \tcode{nodiscard} attribute |
| 9220 | +can later be redeclared with the attribute and vice-versa. |
| 9221 | +\begin{note} |
| 9222 | +Thus, an entity initially declared without the attribute |
| 9223 | +can be marked as \tcode{nodiscard} |
| 9224 | +by a subsequent redeclaration. |
| 9225 | +However, after an entity is marked as \tcode{nodiscard}, |
| 9226 | +later redeclarations do not remove the \tcode{nodiscard} |
| 9227 | +from the entity. |
| 9228 | +\end{note} |
| 9229 | +Redeclarations using different forms of the attribute |
| 9230 | +(with or without the \grammarterm{attribute-argument-clause} |
| 9231 | +or with different \grammarterm{attribute-argument-clause}s) |
| 9232 | +are allowed. |
9212 | 9233 |
|
9213 | 9234 | \pnum
|
9214 | 9235 | \begin{note}
|
|
9221 | 9242 | Implementations should issue a warning in such cases.
|
9222 | 9243 | This is typically because discarding the return value
|
9223 | 9244 | of a nodiscard call has surprising consequences.
|
| 9245 | +The \grammarterm{string-literal} |
| 9246 | +in a \tcode{nodiscard} \grammarterm{attribute-argument-clause} |
| 9247 | +is intended to be used in the message of the warning |
| 9248 | +as the rationale for why the entity must not be discarded |
| 9249 | +or to suggest alternative entities |
| 9250 | +that may demonstrate the intent or proper usage. |
9224 | 9251 | \end{note}
|
9225 | 9252 |
|
9226 | 9253 | \pnum
|
|
0 commit comments