[dcl.attr.grammar] (original) (raw)
9 Declarations [dcl.dcl]
9.12 Attributes [dcl.attr]
9.12.1 Attribute syntax and semantics [dcl.attr.grammar]
If an attribute-specifiercontains an attribute-using-prefix, the attribute-list following that attribute-using-prefixshall not contain an attribute-scoped-tokenand every attribute-token in that attribute-listis treated as if its identifier were prefixed with N::, where N is the attribute-namespacespecified in the attribute-using-prefix.
[ Note
:
This rule imposes no constraints on how an attribute-using-prefixaffects the tokens in an attribute-argument-clause.
— end note
]
[ Example
:
[[using CC: opt(1), debug]]
void f() {}
[[using CC: opt(1)]] [[CC::debug]]
void g() {}
[[using CC: CC::opt(1)]]
void h() {}
— end example
]
[ Note
:
For each individual attribute, the form of thebalanced-token-seq will be specified.
— end note
]
In an attribute-list, an ellipsis may appear only if thatattribute's specification permits it.
An attribute-specifier that contains no attributes has no effect.
The order in which the attribute-tokens appear in anattribute-list is not significant.
If akeywordor an alternative token that satisfies the syntactic requirements of an identifier is contained in an attribute-token, it is considered an identifier.
Noname lookup is performed on any of the identifiers contained in anattribute-token.
The attribute-token determines additional requirements on the attribute-argument-clause (if any).
Each attribute-specifier-seq is said to appertain to some entity or statement, identified by the syntactic context where it appears ([stmt.stmt], [dcl.dcl],[dcl.decl]).
If an attribute-specifier-seq that appertains to some entity or statement contains an attribute or alignment-specifier that is not allowed to apply to that entity or statement, the program is ill-formed.
If an attribute-specifier-seqappertains to a friend declaration ([class.friend]), that declaration shall be a definition.
For an attribute-token(including an attribute-scoped-token) not specified in this document, the behavior is implementation-defined.
Any attribute-token that is not recognized by the implementation is ignored.
An attribute-token is reserved for future standardization if
- it is not an attribute-scoped-token and is not specified in this document, or
- it is an attribute-scoped-token and its attribute-namespace isstd followed by zero or more digits.
[ Note
:
Each implementation should choose a distinctive name for theattribute-namespace in an attribute-scoped-token.
— end note
]
Two consecutive left square bracket tokens shall appear only when introducing an attribute-specifier or within the balanced-token-seq of an attribute-argument-clause.
[ Note
:
If two consecutive left square brackets appear where an attribute-specifier is not allowed, the program is ill-formed even if the brackets match an alternative grammar production.
— end note
]
[ Example
:
int p[10]; void f() { int x = 42, y[5]; int(p[[x] { return x; }()]);
y[[] { return 2; }()] = 2;
int i [[vendor::attr([[]])]];
}
— end example
]