tmp/tmpqg1xpwff/{from.md → to.md}
RENAMED
|
@@ -8,20 +8,25 @@ attribute-specifier-seq:
|
|
| 8 |
attribute-specifier-seqₒₚₜ attribute-specifier
|
| 9 |
```
|
| 10 |
|
| 11 |
``` bnf
|
| 12 |
attribute-specifier:
|
| 13 |
-
'[' '[' attribute-list ']' ']'
|
| 14 |
alignment-specifier
|
| 15 |
```
|
| 16 |
|
| 17 |
``` bnf
|
| 18 |
alignment-specifier:
|
| 19 |
'alignas (' type-id '...'ₒₚₜ ')'
|
| 20 |
'alignas (' constant-expression '...'ₒₚₜ ')'
|
| 21 |
```
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
``` bnf
|
| 24 |
attribute-list:
|
| 25 |
attributeₒₚₜ
|
| 26 |
attribute-list ',' attributeₒₚₜ
|
| 27 |
attribute '...'
|
|
@@ -49,73 +54,104 @@ attribute-namespace:
|
|
| 49 |
identifier
|
| 50 |
```
|
| 51 |
|
| 52 |
``` bnf
|
| 53 |
attribute-argument-clause:
|
| 54 |
-
'(' balanced-token-seq ')'
|
| 55 |
```
|
| 56 |
|
| 57 |
``` bnf
|
| 58 |
balanced-token-seq:
|
| 59 |
-
balanced-token
|
| 60 |
balanced-token-seq balanced-token
|
| 61 |
```
|
| 62 |
|
| 63 |
``` bnf
|
| 64 |
balanced-token:
|
| 65 |
-
'(' balanced-token-seq ')'
|
| 66 |
-
'[' balanced-token-seq ']'
|
| 67 |
-
'{' balanced-token-seq '}'
|
| 68 |
any *token* other than a parenthesis, a bracket, or a brace
|
| 69 |
```
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
In an *attribute-list*, an ellipsis may appear only if that
|
| 75 |
*attribute*’s specification permits it. An *attribute* followed by an
|
| 76 |
ellipsis is a pack expansion ([[temp.variadic]]). An
|
| 77 |
*attribute-specifier* that contains no *attribute*s has no effect. The
|
| 78 |
-
order in which the *attribute-
|
| 79 |
not significant. If a keyword ([[lex.key]]) or an alternative token (
|
| 80 |
[[lex.digraph]]) that satisfies the syntactic requirements of an
|
| 81 |
*identifier* ([[lex.name]]) is contained in an *attribute-token*, it is
|
| 82 |
considered an identifier. No name lookup ([[basic.lookup]]) is
|
| 83 |
performed on any of the identifiers contained in an *attribute-token*.
|
| 84 |
The *attribute-token* determines additional requirements on the
|
| 85 |
-
*attribute-argument-clause* (if any).
|
| 86 |
-
*attribute-scoped-token* is conditionally-supported, with
|
| 87 |
-
*implementation-defined* behavior. Each implementation should choose a
|
| 88 |
-
distinctive name for the *attribute-namespace* in an
|
| 89 |
-
*attribute-scoped-token*.
|
| 90 |
|
| 91 |
Each *attribute-specifier-seq* is said to *appertain* to some entity or
|
| 92 |
statement, identified by the syntactic context where it appears (Clause
|
| 93 |
[[stmt.stmt]], Clause [[dcl.dcl]], Clause [[dcl.decl]]). If an
|
| 94 |
*attribute-specifier-seq* that appertains to some entity or statement
|
| 95 |
-
contains an *attribute* that is not allowed to
|
| 96 |
-
statement, the program is ill-formed. If an
|
| 97 |
-
appertains to a friend declaration (
|
| 98 |
-
shall be a definition. No
|
| 99 |
-
an explicit instantiation (
|
|
|
|
| 100 |
|
| 101 |
-
For an *attribute-token*
|
| 102 |
-
the behavior is
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
Two consecutive left square bracket tokens shall appear only when
|
| 105 |
-
introducing an *attribute-specifier*
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
``` cpp
|
| 111 |
int p[10];
|
| 112 |
void f() {
|
| 113 |
int x = 42, y[5];
|
| 114 |
-
int(p[[x] { return x; }()]); // error: invalid attribute on a nested
|
| 115 |
-
//
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
// in this context.
|
| 119 |
}
|
| 120 |
```
|
| 121 |
|
|
|
|
|
|
|
|
|
| 8 |
attribute-specifier-seqₒₚₜ attribute-specifier
|
| 9 |
```
|
| 10 |
|
| 11 |
``` bnf
|
| 12 |
attribute-specifier:
|
| 13 |
+
'[' '[' attribute-using-prefixₒₚₜ attribute-list ']' ']'
|
| 14 |
alignment-specifier
|
| 15 |
```
|
| 16 |
|
| 17 |
``` bnf
|
| 18 |
alignment-specifier:
|
| 19 |
'alignas (' type-id '...'ₒₚₜ ')'
|
| 20 |
'alignas (' constant-expression '...'ₒₚₜ ')'
|
| 21 |
```
|
| 22 |
|
| 23 |
+
``` bnf
|
| 24 |
+
attribute-using-prefix:
|
| 25 |
+
'using' attribute-namespace ':'
|
| 26 |
+
```
|
| 27 |
+
|
| 28 |
``` bnf
|
| 29 |
attribute-list:
|
| 30 |
attributeₒₚₜ
|
| 31 |
attribute-list ',' attributeₒₚₜ
|
| 32 |
attribute '...'
|
|
|
|
| 54 |
identifier
|
| 55 |
```
|
| 56 |
|
| 57 |
``` bnf
|
| 58 |
attribute-argument-clause:
|
| 59 |
+
'(' balanced-token-seqₒₚₜ ')'
|
| 60 |
```
|
| 61 |
|
| 62 |
``` bnf
|
| 63 |
balanced-token-seq:
|
| 64 |
+
balanced-token
|
| 65 |
balanced-token-seq balanced-token
|
| 66 |
```
|
| 67 |
|
| 68 |
``` bnf
|
| 69 |
balanced-token:
|
| 70 |
+
'(' balanced-token-seqₒₚₜ ')'
|
| 71 |
+
'[' balanced-token-seqₒₚₜ ']'
|
| 72 |
+
'{' balanced-token-seqₒₚₜ '}'
|
| 73 |
any *token* other than a parenthesis, a bracket, or a brace
|
| 74 |
```
|
| 75 |
|
| 76 |
+
If an *attribute-specifier* contains an *attribute-using-prefix*, the
|
| 77 |
+
*attribute-list* following that *attribute-using-prefix* shall not
|
| 78 |
+
contain an *attribute-scoped-token* and every *attribute-token* in that
|
| 79 |
+
*attribute-list* is treated as if its *identifier* were prefixed with
|
| 80 |
+
`N::`, where `N` is the *attribute-namespace* specified in the
|
| 81 |
+
*attribute-using-prefix*.
|
| 82 |
+
|
| 83 |
+
[*Note 1*: This rule imposes no constraints on how an
|
| 84 |
+
*attribute-using-prefix* affects the tokens in an
|
| 85 |
+
*attribute-argument-clause*. — *end note*]
|
| 86 |
+
|
| 87 |
+
[*Example 1*:
|
| 88 |
+
|
| 89 |
+
``` cpp
|
| 90 |
+
[[using CC: opt(1), debug]] // same as [[CC::opt(1), CC::debug]]
|
| 91 |
+
void f() {}
|
| 92 |
+
[[using CC: opt(1)]] [[CC::debug]] // same as [[CC::opt(1)]] [[CC::debug]]
|
| 93 |
+
void g() {}
|
| 94 |
+
[[using CC: CC::opt(1)]] // error: cannot combine using and scoped attribute token
|
| 95 |
+
void h() {}
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
— *end example*]
|
| 99 |
+
|
| 100 |
+
[*Note 2*: For each individual attribute, the form of the
|
| 101 |
+
*balanced-token-seq* will be specified. — *end note*]
|
| 102 |
|
| 103 |
In an *attribute-list*, an ellipsis may appear only if that
|
| 104 |
*attribute*’s specification permits it. An *attribute* followed by an
|
| 105 |
ellipsis is a pack expansion ([[temp.variadic]]). An
|
| 106 |
*attribute-specifier* that contains no *attribute*s has no effect. The
|
| 107 |
+
order in which the *attribute-token*s appear in an *attribute-list* is
|
| 108 |
not significant. If a keyword ([[lex.key]]) or an alternative token (
|
| 109 |
[[lex.digraph]]) that satisfies the syntactic requirements of an
|
| 110 |
*identifier* ([[lex.name]]) is contained in an *attribute-token*, it is
|
| 111 |
considered an identifier. No name lookup ([[basic.lookup]]) is
|
| 112 |
performed on any of the identifiers contained in an *attribute-token*.
|
| 113 |
The *attribute-token* determines additional requirements on the
|
| 114 |
+
*attribute-argument-clause* (if any).
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
Each *attribute-specifier-seq* is said to *appertain* to some entity or
|
| 117 |
statement, identified by the syntactic context where it appears (Clause
|
| 118 |
[[stmt.stmt]], Clause [[dcl.dcl]], Clause [[dcl.decl]]). If an
|
| 119 |
*attribute-specifier-seq* that appertains to some entity or statement
|
| 120 |
+
contains an *attribute* or *alignment-specifier* that is not allowed to
|
| 121 |
+
apply to that entity or statement, the program is ill-formed. If an
|
| 122 |
+
*attribute-specifier-seq* appertains to a friend declaration (
|
| 123 |
+
[[class.friend]]), that declaration shall be a definition. No
|
| 124 |
+
*attribute-specifier-seq* shall appertain to an explicit instantiation (
|
| 125 |
+
[[temp.explicit]]).
|
| 126 |
|
| 127 |
+
For an *attribute-token* (including an *attribute-scoped-token*) not
|
| 128 |
+
specified in this International Standard, the behavior is
|
| 129 |
+
*implementation-defined*. Any *attribute-token* that is not recognized
|
| 130 |
+
by the implementation is ignored.
|
| 131 |
+
|
| 132 |
+
[*Note 3*: Each implementation should choose a distinctive name for the
|
| 133 |
+
*attribute-namespace* in an *attribute-scoped-token*. — *end note*]
|
| 134 |
|
| 135 |
Two consecutive left square bracket tokens shall appear only when
|
| 136 |
+
introducing an *attribute-specifier* or within the *balanced-token-seq*
|
| 137 |
+
of an *attribute-argument-clause*.
|
| 138 |
+
|
| 139 |
+
[*Note 4*: If two consecutive left square brackets appear where an
|
| 140 |
+
*attribute-specifier* is not allowed, the program is ill-formed even if
|
| 141 |
+
the brackets match an alternative grammar production. — *end note*]
|
| 142 |
+
|
| 143 |
+
[*Example 2*:
|
| 144 |
|
| 145 |
``` cpp
|
| 146 |
int p[10];
|
| 147 |
void f() {
|
| 148 |
int x = 42, y[5];
|
| 149 |
+
int(p[[x] { return x; }()]); // error: invalid attribute on a nested declarator-id and
|
| 150 |
+
// not a function-style cast of an element of p.
|
| 151 |
+
y[[] { return 2; }()] = 2; // error even though attributes are not allowed in this context.
|
| 152 |
+
int i [[vendor::attr([[]])]]; // well-formed implementation-defined attribute.
|
|
|
|
| 153 |
}
|
| 154 |
```
|
| 155 |
|
| 156 |
+
— *end example*]
|
| 157 |
+
|