|
102 | 102 | * | introduce an attribute-specifier |
103 | 103 | * | attribute argument |
104 | 104 |
|
105 | | - |
106 | | -An attribute without attribute-namespace and an attribute-namespace whose name is either `std` or `std` followed |
107 | | -by one or more digits is reserved for future standardization |
108 | | -* That is, every non-standard attribute is in the attribute-namespace provided by the implementation, e.g. `[[gnu::may_alias]]`, `[[clang::trivial_abi]]`, and `[[msvc::noop_dtor]]` |
109 | | -* | (since C++20) |
110 | | - |
111 | 105 | ### Standard attributes |
112 | 106 |
|
113 | 107 | * == defined -- by the -- C++ standard |
114 | | - |
115 | | -Standard attributes cannot be syntactically ignored: they cannot contain syntax errors, must be applied to the correct target, |
116 | | -and entities in the arguments must be [ODR-use](definition.html#ODR-use "cpp/language/definition"). |
117 | | - |
118 | | -Standard attributes cannot be semantically ignored either: the behavior with all instances of a particular standard attribute removed |
119 | | -would have been a conforming behavior for the original program with the attribute present. |
| 108 | +* | C++20, |
| 109 | + * == attribute / reserved ones |
| 110 | + * attribute WITHOUT `attribute-namespace` |
| 111 | + * attribute / `attribute-namespace` == `std` OR `std + OneOrMoreDigits` |
| 112 | +* ❌can NOT be |
| 113 | + * syntactically ignored❌ |
| 114 | + * == ❌can NOT contain syntax errors❌ |
| 115 | + * semantically ignored❌ |
| 116 | + * TODO: the behavior with all instances of a particular standard attribute removed would have been a conforming behavior for the original program with the attribute present. |
| 117 | +* MUST be applied | correct target |
| 118 | +* entities | arguments MUST be [ODR-use](definition.md#odr-use-formal-definition) |
120 | 119 |
|
121 | 120 | * [`[[noreturn]]`](attributes/noreturn.md) |
122 | | - * (C++11) | indicates that the function does not return |
123 | | - (attribute specifier) |
124 | | - ---|--- |
125 | | - `[[[carries_dependency](attributes/carries_dependency.html "cpp/language/attributes/carries dependency")]]`(C++11)(removed in C++26) | indicates that dependency chain in release-consume [std::memory_order](../atomic/memory_order.html "cpp/atomic/memory order") propagates in and out of the function |
126 | | - (attribute specifier) |
127 | | - `[[[deprecated](attributes/deprecated.html "cpp/language/attributes/deprecated")]]``[[[deprecated](attributes/deprecated.html "cpp/language/attributes/deprecated")("_reason_ ")]]`(C++14)(C++14) | indicates that the use of the name or entity declared with this attribute is allowed, but discouraged for some reason |
128 | | - (attribute specifier) |
129 | | - `[[[fallthrough](attributes/fallthrough.html "cpp/language/attributes/fallthrough")]]`(C++17) | indicates that the fall through from the previous case label is intentional and should not be diagnosed by a compiler that warns on fall-through |
130 | | - (attribute specifier) |
131 | | - `[[[maybe_unused](attributes/maybe_unused.html "cpp/language/attributes/maybe unused")]]`(C++17) | suppresses compiler warnings on unused entities, if any |
132 | | - (attribute specifier) |
133 | | - `[[[nodiscard](attributes/nodiscard.html "cpp/language/attributes/nodiscard")]]``[[[nodiscard](attributes/nodiscard.html "cpp/language/attributes/nodiscard")("_reason_ ")]]`(C++17)(C++20) | encourages the compiler to issue a warning if the return value is discarded |
134 | | - (attribute specifier) |
135 | | - `[[[likely](attributes/likely.html "cpp/language/attributes/likely")]]``[[[unlikely](attributes/likely.html "cpp/language/attributes/likely")]]`(C++20)(C++20) | indicates that the compiler should optimize for the case where a path of execution through a statement is more or less likely than any other path of execution |
136 | | - (attribute specifier) |
137 | | - `[[[no_unique_address](attributes/no_unique_address.html "cpp/language/attributes/no unique address")]]`(C++20) | indicates that a non-static data member need not have an address distinct from all other non-static data members of its class |
138 | | - (attribute specifier) |
139 | | - `[[[assume](attributes/assume.html "cpp/language/attributes/assume")(_expression_)]]`(C++23) | specifies that the _expression_ will always evaluate to true at a given point |
140 | | - (attribute specifier) |
141 | | - `[[[indeterminate](attributes/indeterminate.html "cpp/language/attributes/indeterminate")]]`(C++26) | specifies that an object has an indeterminate value if it is not initialized |
142 | | - (attribute specifier) |
143 | | - `[[[optimize_for_synchronized](attributes/optimize_for_synchronized.html "cpp/language/attributes/optimize for synchronized")]]`(TM TS) | indicates that the function definition should be optimized for invocation from a [synchronized statement](transactional_memory.html "cpp/language/transactional memory") |
144 | | - (attribute specifier) |
145 | | - |
| 121 | +* [`[[carries_dependency]]`](attributes/carries_dependency.md) |
| 122 | +* [`[[deprecated]]`](attributes/deprecated.md) OR `[[deprecated("reason")]]` |
| 123 | +* [`[[fallthrough]]`](attributes/fallthrough.md) |
| 124 | +* [`[[maybe_unused]]`](attributes/maybe_unused.md) |
| 125 | +* [`[[nodiscard]]`](attributes/nodiscard.md) OR `[[nodiscard("reason")]]` |
| 126 | +* [`[[likely]]`](attributes/likely.md) OR `[[unlikely]]` |
| 127 | +* [`[[no_unique_address]]`](attributes/no_unique_address.md) |
| 128 | +* [`[[assume(expression)]]`](attributes/assume.md) |
| 129 | +* [`[[indeterminate]]`](attributes/indeterminate.md) |
| 130 | +* [`[[optimize_for_synchronized]]`](attributes/optimize_for_synchronized.md) |
| 131 | + |
| 132 | +### Non-standard attribute |
| 133 | + |
| 134 | +* | C++20, |
| 135 | + * == attribute / |
| 136 | + * `attribute-namespace` == C++ implementation |
| 137 | + * _Examples:_ `[[gnu::may_alias]]`, `[[clang::trivial_abi]]`, `[[msvc::noop_dtor]]`, ... |
| 138 | + |
146 | 139 | ### Notes |
147 | 140 |
|
148 | 141 | The presence of each individual attribute on a given platform can be checked with [`__has_cpp_attribute`](../experimental/feature_test.html#Attributes "cpp/feature test") preprocessor macro. |
|
0 commit comments