[clang] [clang] Fix deprecation attribute being ignored when used inside other attributes that are already applied to a deprecated symbol (PR #222094)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 9 06:57:13 PDT 2026
higher-performance wrote:
I'm surprised to hear this. It absolutely looks like a bug to me -- the `deprecated` attribute applies to the symbol(s) being declared (`f` in that example), not to everything inside that declaration, and especially not to symbols used inside attributes in the declaration. They are completely orthogonal. For example, if we have
```
int foo();
template<class T>
__attribute__((deprecated)) decltype(foo()) bar();
```
then you wouldn't say `foo` is deprecated, right? Or if we have
```
namespace ns {
int foo(const void*);
struct S {
__attribute__((deprecated))
friend char foo(S*);
};
template<class T>
__attribute__((deprecated))
auto bar(T& x) -> decltype(foo(&x));
}
int main() {
ns::S s;
ns::bar(s);
}
```
then surely users should observe a difference between `foo` being deprecated vs. not-deprecated?
I also don't understand the motivation: what is the logic for _not_ telling users a symbol that they're using is deprecated? How are they supposed to migrate off the symbol if they don't know it's deprecated...?
P.S., there is apparently also an inconsistency here where removing `namespace { }` actually *does* cause this to fire! So even the intended behavior seems to have a bug in its implementation, though I'm arguing the intended behavior itself is buggy.
https://github.com/llvm/llvm-project/pull/222094
More information about the cfe-commits
mailing list