<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62072>62072</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
missing dangling reference warnings if lifetimebound is applied to a function declaration but not the definition
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zygoloid
</td>
</tr>
</table>
<pre>
[Testcase](https://gcc.godbolt.org/z/Yfr5PbsrP):
```
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).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVE2P2zYQ_TX0ZbCGRMmSfNBhN66LBYo0wLaHngp-jCQ2NGmQoyTKry9Iq2srKNAChiwPZ957M48eEaMZHWLPDi_scNqJmSYf-u_L6K03eie9XtLZbxhJiYjscGK8m4iukVXPjJ8ZP49K7Uevpbe092Fk_Pyd8fMfQzh8kjF8YvyYUosTK55ZU6yf_DNSmBXBG7D25RYBAFDeRQLjiPEGvjHeMX5cg1nli7LCjQmzerZmQDIXlH52Ook7nFj1gBVJkFFbyIXx7hZ4A8abiHb4f8CpkQds4wjMe4S1d-b1ySszwOnXP18__vL68adb0DhrHG4Fvd0of2i1fYGANAeXSSDh_xfCv3SWAB-gUmi_xWO8QqfN8Cj9izcafl71bMwRM_nsC7DqBG-3lP0qfTOefzKXNfNd4Vr0mH8Xs70gt-eHZAt8FcFFoEkQsKb4xpoChNPpfcnvAUELN1qTcg1N6eTp9_v4mwLkTEATZijjxpiLorHoFGqYncaQq06PVXt4JbDef45gzWdMABFBEAUjZ8IbiPMEEhP1NfirGAWhhiH4S-bTqKwIgox3QH4NDcaZHEkVGOwCjHfXgHG-CGkXkKjEHDPfkjlouW54g6AJQ5qI2zDcUxj_kGeUIbR3jLcEahJuzLCghPPOKGEzdjJyp_tKH6uj2GFfNl3Jq65ujrupb8taYlVgw5t24AMv6vrYyk4oOXTlsRQ70_OCV0VdlmVXl8Vxr-TAOYoWRV1qlC2rC7wIY_fWfrmkRbEzMc7YN7xo-c4KiTbmNcS5w6-QDxnnaSuFPtU8yXmMrC6siRTvKGTIYn8xMabxv1-BgAOGZOzdbTPA5m8NJoK4Xq1BnWwRMMxO5RE-jjNdmmTv1rXdHGz_wx40NM1yr_yF8XOSt349XYP_CxUxfs5NRcbPuem_AwAA__-7VrEm">