tmp/tmpc1a6frl9/{from.md → to.md}
RENAMED
|
@@ -17,11 +17,11 @@ attribute-specifier:
|
|
| 17 |
```
|
| 18 |
|
| 19 |
``` bnf
|
| 20 |
alignment-specifier:
|
| 21 |
'alignas (' type-id '...'ₒₚₜ ')'
|
| 22 |
-
'alignas ('
|
| 23 |
```
|
| 24 |
|
| 25 |
``` bnf
|
| 26 |
attribute-list:
|
| 27 |
attributeₒₚₜ
|
|
@@ -104,18 +104,18 @@ For an *attribute-token* not specified in this International Standard,
|
|
| 104 |
the behavior is *implementation-defined*.
|
| 105 |
|
| 106 |
Two consecutive left square bracket tokens shall appear only when
|
| 107 |
introducing an *attribute-specifier*. If two consecutive left square
|
| 108 |
brackets appear where an *attribute-specifier* is not allowed, the
|
| 109 |
-
program is ill
|
| 110 |
production.
|
| 111 |
|
| 112 |
``` cpp
|
| 113 |
int p[10];
|
| 114 |
void f() {
|
| 115 |
int x = 42, y[5];
|
| 116 |
-
int(p[[x] { return x; }()]); // error:
|
| 117 |
// declarator-id and not a function-style cast of
|
| 118 |
// an element of p.
|
| 119 |
y[[] { return 2; }()] = 2; // error even though attributes are not allowed
|
| 120 |
// in this context.
|
| 121 |
}
|
|
@@ -123,20 +123,24 @@ void f() {
|
|
| 123 |
|
| 124 |
### Alignment specifier <a id="dcl.align">[[dcl.align]]</a>
|
| 125 |
|
| 126 |
An *alignment-specifier* may be applied to a variable or to a class data
|
| 127 |
member, but it shall not be applied to a bit-field, a function
|
| 128 |
-
parameter,
|
| 129 |
-
|
| 130 |
-
*alignment-specifier* may also be applied to the declaration
|
| 131 |
-
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
|
| 134 |
When the *alignment-specifier* is of the form `alignas(`
|
| 135 |
-
*
|
| 136 |
|
| 137 |
-
- the *
|
| 138 |
- if the constant expression evaluates to a fundamental alignment, the
|
| 139 |
alignment requirement of the declared entity shall be the specified
|
| 140 |
fundamental alignment
|
| 141 |
- if the constant expression evaluates to an extended alignment and the
|
| 142 |
implementation supports that alignment in the context of the
|
|
@@ -268,18 +272,18 @@ int foo_array[10][10];
|
|
| 268 |
|
| 269 |
[[carries_dependency]] struct foo* f(int i) {
|
| 270 |
return foo_head[i].load(memory_order_consume);
|
| 271 |
}
|
| 272 |
|
| 273 |
-
|
| 274 |
return kill_dependency(foo_array[*x][*y]);
|
| 275 |
}
|
| 276 |
|
| 277 |
/* Translation unit B. */
|
| 278 |
|
| 279 |
[[carries_dependency]] struct foo* f(int i);
|
| 280 |
-
|
| 281 |
|
| 282 |
int c = 3;
|
| 283 |
|
| 284 |
void h(int i) {
|
| 285 |
struct foo* p;
|
|
@@ -294,11 +298,48 @@ The `carries_dependency` attribute on function `f` means that the return
|
|
| 294 |
value carries a dependency out of `f`, so that the implementation need
|
| 295 |
not constrain ordering upon return from `f`. Implementations of `f` and
|
| 296 |
its caller may choose to preserve dependencies instead of emitting
|
| 297 |
hardware memory ordering instructions (a.k.a. fences).
|
| 298 |
|
| 299 |
-
Function `g`’s second
|
| 300 |
-
its first
|
| 301 |
-
carries a dependency into `g`, but its second call does not. The
|
| 302 |
implementation might need to insert a fence prior to the second call to
|
| 303 |
`g`.
|
| 304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
```
|
| 18 |
|
| 19 |
``` bnf
|
| 20 |
alignment-specifier:
|
| 21 |
'alignas (' type-id '...'ₒₚₜ ')'
|
| 22 |
+
'alignas (' constant-expression '...'ₒₚₜ ')'
|
| 23 |
```
|
| 24 |
|
| 25 |
``` bnf
|
| 26 |
attribute-list:
|
| 27 |
attributeₒₚₜ
|
|
|
|
| 104 |
the behavior is *implementation-defined*.
|
| 105 |
|
| 106 |
Two consecutive left square bracket tokens shall appear only when
|
| 107 |
introducing an *attribute-specifier*. If two consecutive left square
|
| 108 |
brackets appear where an *attribute-specifier* is not allowed, the
|
| 109 |
+
program is ill-formed even if the brackets match an alternative grammar
|
| 110 |
production.
|
| 111 |
|
| 112 |
``` cpp
|
| 113 |
int p[10];
|
| 114 |
void f() {
|
| 115 |
int x = 42, y[5];
|
| 116 |
+
int(p[[x] { return x; }()]); // error: invalid attribute on a nested
|
| 117 |
// declarator-id and not a function-style cast of
|
| 118 |
// an element of p.
|
| 119 |
y[[] { return 2; }()] = 2; // error even though attributes are not allowed
|
| 120 |
// in this context.
|
| 121 |
}
|
|
|
|
| 123 |
|
| 124 |
### Alignment specifier <a id="dcl.align">[[dcl.align]]</a>
|
| 125 |
|
| 126 |
An *alignment-specifier* may be applied to a variable or to a class data
|
| 127 |
member, but it shall not be applied to a bit-field, a function
|
| 128 |
+
parameter, an *exception-declaration* ([[except.handle]]), or a
|
| 129 |
+
variable declared with the `register` storage class specifier. An
|
| 130 |
+
*alignment-specifier* may also be applied to the declaration or
|
| 131 |
+
definition of a class (in an *elaborated-type-specifier* (
|
| 132 |
+
[[dcl.type.elab]]) or *class-head* (Clause [[class]]), respectively)
|
| 133 |
+
and to the declaration or definition of an enumeration (in an
|
| 134 |
+
*opaque-enum-declaration* or *enum-head*, respectively ([[dcl.enum]])).
|
| 135 |
+
An *alignment-specifier* with an ellipsis is a pack expansion (
|
| 136 |
+
[[temp.variadic]]).
|
| 137 |
|
| 138 |
When the *alignment-specifier* is of the form `alignas(`
|
| 139 |
+
*constant-expression* `)`:
|
| 140 |
|
| 141 |
+
- the *constant-expression* shall be an integral constant expression
|
| 142 |
- if the constant expression evaluates to a fundamental alignment, the
|
| 143 |
alignment requirement of the declared entity shall be the specified
|
| 144 |
fundamental alignment
|
| 145 |
- if the constant expression evaluates to an extended alignment and the
|
| 146 |
implementation supports that alignment in the context of the
|
|
|
|
| 272 |
|
| 273 |
[[carries_dependency]] struct foo* f(int i) {
|
| 274 |
return foo_head[i].load(memory_order_consume);
|
| 275 |
}
|
| 276 |
|
| 277 |
+
int g(int* x, int* y [[carries_dependency]]) {
|
| 278 |
return kill_dependency(foo_array[*x][*y]);
|
| 279 |
}
|
| 280 |
|
| 281 |
/* Translation unit B. */
|
| 282 |
|
| 283 |
[[carries_dependency]] struct foo* f(int i);
|
| 284 |
+
int g(int* x, int* y [[carries_dependency]]);
|
| 285 |
|
| 286 |
int c = 3;
|
| 287 |
|
| 288 |
void h(int i) {
|
| 289 |
struct foo* p;
|
|
|
|
| 298 |
value carries a dependency out of `f`, so that the implementation need
|
| 299 |
not constrain ordering upon return from `f`. Implementations of `f` and
|
| 300 |
its caller may choose to preserve dependencies instead of emitting
|
| 301 |
hardware memory ordering instructions (a.k.a. fences).
|
| 302 |
|
| 303 |
+
Function `g`’s second parameter has a `carries_dependency` attribute,
|
| 304 |
+
but its first parameter does not. Therefore, function `h`’s first call
|
| 305 |
+
to `g` carries a dependency into `g`, but its second call does not. The
|
| 306 |
implementation might need to insert a fence prior to the second call to
|
| 307 |
`g`.
|
| 308 |
|
| 309 |
+
### Deprecated attribute <a id="dcl.attr.deprecated">[[dcl.attr.deprecated]]</a>
|
| 310 |
+
|
| 311 |
+
The *attribute-token* `deprecated` can be used to mark names and
|
| 312 |
+
entities whose use is still allowed, but is discouraged for some reason.
|
| 313 |
+
in particular, `deprecated` is appropriate for names and entities that
|
| 314 |
+
are deemed obsolescent or unsafe. It shall appear at most once in each
|
| 315 |
+
*attribute-list*. An *attribute-argument-clause* may be present and, if
|
| 316 |
+
present, it shall have the form:
|
| 317 |
+
|
| 318 |
+
``` cpp
|
| 319 |
+
( string-literal )
|
| 320 |
+
```
|
| 321 |
+
|
| 322 |
+
the *string-literal* in the *attribute-argument-clause* could be used to
|
| 323 |
+
explain the rationale for deprecation and/or to suggest a replacing
|
| 324 |
+
entity.
|
| 325 |
+
|
| 326 |
+
The attribute may be applied to the declaration of a class, a
|
| 327 |
+
*typedef-name*, a variable, a non-static data member, a function, an
|
| 328 |
+
enumeration, or a template specialization.
|
| 329 |
+
|
| 330 |
+
A name or entity declared without the `deprecated` attribute can later
|
| 331 |
+
be re-declared with the attribute and vice-versa. Thus, an entity
|
| 332 |
+
initially declared without the attribute can be marked as deprecated by
|
| 333 |
+
a subsequent redeclaration. However, after an entity is marked as
|
| 334 |
+
deprecated, later redeclarations do not un-deprecate the entity.
|
| 335 |
+
Redeclarations using different forms of the attribute (with or without
|
| 336 |
+
the *attribute-argument-clause* or with different
|
| 337 |
+
*attribute-argument-clause*s) are allowed.
|
| 338 |
+
|
| 339 |
+
Implementations may use the `deprecated `attribute to produce a
|
| 340 |
+
diagnostic message in case the program refers to a name or entity other
|
| 341 |
+
than to declare it, after a declaration that specifies the attribute.
|
| 342 |
+
The diagnostic message may include the text provided within the
|
| 343 |
+
*attribute-argument-clause* of any `deprecated` attribute applied to the
|
| 344 |
+
name or entity.
|
| 345 |
+
|