83 lines
3.6 KiB
Markdown
83 lines
3.6 KiB
Markdown
[dcl.attr.deprecated]
|
||
|
||
# 9 Declarations [[dcl]](./#dcl)
|
||
|
||
## 9.13 Attributes [[dcl.attr]](dcl.attr#deprecated)
|
||
|
||
### 9.13.4 Deprecated attribute [dcl.attr.deprecated]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L9715)
|
||
|
||
The [*attribute-token*](dcl.attr.grammar#nt:attribute-token "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") deprecated can be used to mark names and entities
|
||
whose use is still allowed, but is discouraged for some reason[.](#1.sentence-1)
|
||
|
||
[*Note [1](#note-1)*:
|
||
|
||
In particular,deprecated is appropriate for names and entities that are deemed obsolescent or
|
||
unsafe[.](#1.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
An[*attribute-argument-clause*](dcl.attr.grammar#nt:attribute-argument-clause "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") may be present and, if present, it shall have the form:
|
||
|
||
( [*unevaluated-string*](lex.string.uneval#nt:unevaluated-string "5.13.6 Unevaluated strings [lex.string.uneval]") )
|
||
|
||
[*Note [2](#note-2)*:
|
||
|
||
The [*unevaluated-string*](lex.string.uneval#nt:unevaluated-string "5.13.6 Unevaluated strings [lex.string.uneval]") in the [*attribute-argument-clause*](dcl.attr.grammar#nt:attribute-argument-clause "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") can be used to explain the rationale for deprecation and/or to suggest a replacing entity[.](#1.sentence-3)
|
||
|
||
â *end note*]
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L9733)
|
||
|
||
The attribute may be applied to the declaration of
|
||
a class,
|
||
a type alias,
|
||
a variable,
|
||
a non-static data member,
|
||
a function,
|
||
a namespace,
|
||
an enumeration,
|
||
an enumerator,
|
||
a concept, or
|
||
a template specialization[.](#2.sentence-1)
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L9746)
|
||
|
||
An entity declared without the deprecated attribute can later be redeclared
|
||
with the attribute and vice-versa[.](#3.sentence-1)
|
||
|
||
[*Note [3](#note-3)*:
|
||
|
||
Thus, an entity initially declared without the
|
||
attribute can be marked as deprecated by a subsequent redeclaration[.](#3.sentence-2)
|
||
|
||
However, after an entity
|
||
is marked as deprecated, later redeclarations do not un-deprecate the entity[.](#3.sentence-3)
|
||
|
||
â *end note*]
|
||
|
||
Redeclarations using different forms of the attribute (with or without the[*attribute-argument-clause*](dcl.attr.grammar#nt:attribute-argument-clause "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") or with different[*attribute-argument-clause*](dcl.attr.grammar#nt:attribute-argument-clause "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")*s*) are allowed[.](#3.sentence-4)
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L9758)
|
||
|
||
*Recommended practice*: Implementations should use the deprecated attribute to produce a diagnostic
|
||
message in case the program refers to a name or entity other than to declare it, after a
|
||
declaration that specifies the attribute[.](#4.sentence-1)
|
||
|
||
The diagnostic message should include the text provided
|
||
within the [*attribute-argument-clause*](dcl.attr.grammar#nt:attribute-argument-clause "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") of any deprecated attribute applied
|
||
to the name or entity[.](#4.sentence-2)
|
||
|
||
The value of
|
||
a [*has-attribute-expression*](cpp.cond#nt:has-attribute-expression "15.2 Conditional inclusion [cpp.cond]") for the deprecated attribute
|
||
should be 0 unless the implementation can issue such diagnostic messages[.](#4.sentence-3)
|