<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/119152>119152</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [[clang::musttail]] unnecessarily errors when tail-calling non-member function from member function
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          michael-kenzel
      </td>
    </tr>
</table>

<pre>
    The following example fails to compile:
```cpp
struct A
{
    void fun(int x);
};

void blub(A*, int);

void A::fun(int x)
{
 [[clang::musttail]] return blub(this, x);  //  error: non-static member function cannot perform a tail call to non-member function 'blub'
}
```
This is, however, unnecessary. On many platforms, a tail call would be perfectly possible here. In fact, clang will happily generate a tail call if the attribute is removed. gcc accepts this example: https://godbolt.org/z/d3f6b1b5c

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8k9-OozoMxp8m3FitICmlveCCnqrSuTo38wL5YyBnQ4IS007n6VehnZ3ZarUSEpHyOZ_9sy1TsoNHbFl9YvW5kAuNIbaT1aNEt_mB_gNdoYK5t28jQh-cCzfrB8B3Oc0OoZfWJaAAOkyzdchEx8qO7cvHp-eZlV2iuGiC9aY5sbIDALgGa6BfPOMH6wneGT8ycVol5-eh7FaRcoti_NAx3jH-D1hPX9qnpMu-ont57pfdWt1JO-mHh3BaEpG0jtVnVp8hIi3RfxrRaFM2eqYEwPiF8QsAxhgiEx344DeJJFkNE04KYy5Ekw0etPQ-EMwY-xAnkJBtQEvnMqUc-BrBePMwbp7Ff-PHyu5ttAkeCY3hhleM-bh4jxpTkvG-hf88TNLfYXaSsusq_u58C4szoHBNCzW5O8whJascwogRt_Cvh15qyoErJrhZ52CU82zdHQb0GCXhb4_aHmhEkETRqoUQbIKIU7ii2cKgNUitcaYEmefnwGR6I9Gcch9WrEMwKjjahjgwfvlg_GJEv1eVqjUru8K0whzFURbYVo0Q--OxFlUxtrKuUFYodrVE0R-1rveqN-IgZNMLZVRhW17yXcXLAxcVr6ptY0yzK0uORpb9vjFsV-Ikrds6d52yfWFTWrCtqmNV88JJhS59LkZss2qjliGxXelsovQVR5bcc4X-MmRfLctI11lKcBvRr0w3mWnerD-NSB_D9DppxRJd-4LS0riorQ4T45ec3fO3mWP4H3N3L2uJifHLs8pry38GAAD__1dqSxA">