Skip to content

P2552R3 On the ignorability of standard attributes #6321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion source/declarations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8746,6 +8746,11 @@
deduce information used to optimize the program.
Implementations are not required to deduce
any information from any particular assumption.
It is expected that the value of
a \grammarterm{has-attribute-expression} for the \tcode{assume} attribute
is \tcode{0}
if an implementation does not attempt to deduce
any such information from assumptions.
\end{note}
\begin{example}
\begin{codeblock}
Expand Down Expand Up @@ -8894,6 +8899,10 @@
declaration that specifies the attribute. The diagnostic message should include the text provided
within the \grammarterm{attribute-argument-clause} of any \tcode{deprecated} attribute applied
to the name or entity.
The value of
a \grammarterm{has-attribute-expression} for the \tcode{deprecated} attribute
should be \tcode{0}
unless the implementation can issue such diagnostic messages.

\rSec2[dcl.attr.fallthrough]{Fallthrough attribute}
\indextext{attribute!fallthrough}
Expand All @@ -8920,6 +8929,10 @@
a warning that an implementation might otherwise issue
for a case or default label that is reachable
from another case or default label along some path of execution.
The value of
a \grammarterm{has-attribute-expression} for the \tcode{fallthrough} attribute
should be \tcode{0}
if the attribute does not cause suppression of such warnings.
Implementations should issue a warning
if a fallthrough statement is not dynamically reachable.

Expand Down Expand Up @@ -8969,7 +8982,7 @@
that contains the \grammarterm{attribute-token} \tcode{unlikely}.

\pnum
\recommended
\begin{note}
The use of the \tcode{likely} attribute
is intended to allow implementations to optimize for
the case where paths of execution including it
Expand All @@ -8982,8 +8995,14 @@
are arbitrarily more unlikely
than any alternative path of execution
that does not include such an attribute on a statement or label.
It is expected that the value of a \grammarterm{has-attribute-expression}
for the \tcode{likely} and \tcode{unlikely} attributes
is \tcode{0}
if the implementation does not attempt to use these attributes
for such optimizations.
A path of execution includes a label
if and only if it contains a jump to that label.
\end{note}
\begin{note}
Excessive usage of either of these attributes
is liable to result in performance degradation.
Expand Down Expand Up @@ -9044,6 +9063,10 @@
For a structured binding declaration not marked \tcode{maybe_unused},
implementations should not emit such a warning unless
all of its structured bindings are unused.
The value of
a \grammarterm{has-attribute-expression} for the \tcode{maybe_unused} attribute
should be \tcode{0}
if the attribute does not cause suppression of such warnings.

\pnum
\begin{example}
Expand Down Expand Up @@ -9112,6 +9135,9 @@
a potentially-evaluated discarded-value expression\iref{expr.prop}
is discouraged unless explicitly cast to \keyword{void}.
Implementations should issue a warning in such cases.
The value of
a \grammarterm{has-attribute-expression} for the \tcode{nodiscard} attribute
should be \tcode{0} unless the implementation can issue such warnings.
\begin{note}
This is typically because discarding the return value
of a nodiscard call has surprising consequences.
Expand Down Expand Up @@ -9174,6 +9200,9 @@
\recommended
Implementations should issue a
warning if a function marked \tcode{[[noreturn]]} might return.
The value of
a \grammarterm{has-attribute-expression} for the \tcode{noreturn} attribute
should be \tcode{0} unless the implementation can issue such warnings.

\pnum
\begin{example}
Expand Down Expand Up @@ -9208,6 +9237,14 @@
at the end of the object
can be reused as storage for other members.
\end{note}

\recommended
The value of a \grammarterm{has-attribute-expression}
for the \tcode{no_unique_address} attribute
should be \tcode{0} for a given implementation
unless this attribute can cause a potentially-overlapping subobject
to have zero size.

\begin{example}
\begin{codeblock}
template<typename Key, typename Value,
Expand Down
6 changes: 4 additions & 2 deletions source/preprocessor.tex
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,10 @@

\pnum
For an attribute specified in this document,
the value of the \grammarterm{has-attribute-expression}
is given by \tref{cpp.cond.ha}.
it is \impldef{value of \grammarterm{has-attribute-expression}
for standard attributes}
whether the value of the \grammarterm{has-attribute-expression}
is \tcode{0} or is given by \tref{cpp.cond.ha}.
For other attributes recognized by the implementation,
the value is
\impldef{value of \grammarterm{has-attribute-expression}
Expand Down