Testcase:
struct S {
const int& x() const [[clang::lifetimebound]];
static const int& y(const S &self [[clang::lifetimebound]]);
int i;
};
#if DO_INLINE
inline const int& S::x() const { return i; }
inline const int& S::y(const S &self) { return self.i; }
#endif
void G() {
auto& x = S().x();
auto& y = S::y(S());
}
Clang warns that x and y are dangling with -UDO_INLINE but the warnings are silenced under -DDO_INLINE. It looks like these attributes are not being propagated from the declaration to the definition properly (presumably because they are type attributes rather than declaration attributes, and they don't change the canonical type).