Skip to content

Commit 075b22b

Browse files
jensmaurertkoeppe
authored andcommitted
P2552R3 On the ignorability of standard attributes
1 parent eb712ad commit 075b22b

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

source/declarations.tex

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8727,6 +8727,11 @@
87278727
deduce information used to optimize the program.
87288728
Implementations are not required to deduce
87298729
any information from any particular assumption.
8730+
It is expected that the value of
8731+
a \grammarterm{has-attribute-expression} for the \tcode{assume} attribute
8732+
is \tcode{0}
8733+
if an implementation does not attempt to deduce
8734+
any such information from assumptions.
87308735
\end{note}
87318736
\begin{example}
87328737
\begin{codeblock}
@@ -8875,6 +8880,10 @@
88758880
declaration that specifies the attribute. The diagnostic message should include the text provided
88768881
within the \grammarterm{attribute-argument-clause} of any \tcode{deprecated} attribute applied
88778882
to the name or entity.
8883+
The value of
8884+
a \grammarterm{has-attribute-expression} for the \tcode{deprecated} attribute
8885+
should be \tcode{0}
8886+
unless the implementation can issue such diagnostic messages.
88788887

88798888
\rSec2[dcl.attr.fallthrough]{Fallthrough attribute}
88808889
\indextext{attribute!fallthrough}
@@ -8901,6 +8910,10 @@
89018910
a warning that an implementation might otherwise issue
89028911
for a case or default label that is reachable
89038912
from another case or default label along some path of execution.
8913+
The value of
8914+
a \grammarterm{has-attribute-expression} for the \tcode{fallthrough} attribute
8915+
should be \tcode{0}
8916+
if the attribute does not cause suppression of such warnings.
89048917
Implementations should issue a warning
89058918
if a fallthrough statement is not dynamically reachable.
89068919

@@ -8950,7 +8963,7 @@
89508963
that contains the \grammarterm{attribute-token} \tcode{unlikely}.
89518964

89528965
\pnum
8953-
\recommended
8966+
\begin{note}
89548967
The use of the \tcode{likely} attribute
89558968
is intended to allow implementations to optimize for
89568969
the case where paths of execution including it
@@ -8963,8 +8976,14 @@
89638976
are arbitrarily more unlikely
89648977
than any alternative path of execution
89658978
that does not include such an attribute on a statement or label.
8979+
It is expected that the value of a \grammarterm{has-attribute-expression}
8980+
for the \tcode{likely} and \tcode{unlikely} attributes
8981+
is \tcode{0}
8982+
if the implementation does not attempt to use these attributes
8983+
for such optimizations.
89668984
A path of execution includes a label
89678985
if and only if it contains a jump to that label.
8986+
\end{note}
89688987
\begin{note}
89698988
Excessive usage of either of these attributes
89708989
is liable to result in performance degradation.
@@ -9025,6 +9044,10 @@
90259044
For a structured binding declaration not marked \tcode{maybe_unused},
90269045
implementations should not emit such a warning unless
90279046
all of its structured bindings are unused.
9047+
The value of
9048+
a \grammarterm{has-attribute-expression} for the \tcode{maybe_unused} attribute
9049+
should be \tcode{0}
9050+
if the attribute does not cause suppression of such warnings.
90289051

90299052
\pnum
90309053
\begin{example}
@@ -9093,6 +9116,9 @@
90939116
a potentially-evaluated discarded-value expression\iref{expr.prop}
90949117
is discouraged unless explicitly cast to \keyword{void}.
90959118
Implementations should issue a warning in such cases.
9119+
The value of
9120+
a \grammarterm{has-attribute-expression} for the \tcode{nodiscard} attribute
9121+
should be \tcode{0} unless the implementation can issue such warnings.
90969122
\begin{note}
90979123
This is typically because discarding the return value
90989124
of a nodiscard call has surprising consequences.
@@ -9155,6 +9181,9 @@
91559181
\recommended
91569182
Implementations should issue a
91579183
warning if a function marked \tcode{[[noreturn]]} might return.
9184+
The value of
9185+
a \grammarterm{has-attribute-expression} for the \tcode{noreturn} attribute
9186+
should be \tcode{0} unless the implementation can issue such warnings.
91589187

91599188
\pnum
91609189
\begin{example}
@@ -9189,6 +9218,14 @@
91899218
at the end of the object
91909219
can be reused as storage for other members.
91919220
\end{note}
9221+
9222+
\recommended
9223+
The value of a \grammarterm{has-attribute-expression}
9224+
for the \tcode{no_unique_address} attribute
9225+
should be \tcode{0} for a given implementation
9226+
unless this attribute can cause a potentially-overlapping subobject
9227+
to have zero size.
9228+
91929229
\begin{example}
91939230
\begin{codeblock}
91949231
template<typename Key, typename Value,

source/preprocessor.tex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,10 @@
375375

376376
\pnum
377377
For an attribute specified in this document,
378-
the value of the \grammarterm{has-attribute-expression}
379-
is given by \tref{cpp.cond.ha}.
378+
it is \impldef{value of \grammarterm{has-attribute-expression}
379+
for standard attributes}
380+
whether the value of the \grammarterm{has-attribute-expression}
381+
is \tcode{0} or is given by \tref{cpp.cond.ha}.
380382
For other attributes recognized by the implementation,
381383
the value is
382384
\impldef{value of \grammarterm{has-attribute-expression}

0 commit comments

Comments
 (0)