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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Missing source location in diagnostic for invalid conversion in function w/ explicit object parameter
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            regression:20
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          Sirraide
      </td>
    </tr>
</table>

<pre>
    Consider (https://godbolt.org/z/aa475YbW6):
```c++
struct X{};

template <typename T = void>
struct A {
    auto Error(this auto&& This) -> T {
        return T();
    }
};

struct B : A<X> {
    bool f();
};

bool B::f() {
    return Error();
}
```

Obviously, `X` isn’t convertible to `bool`, so we print an error, but the error is missing a source location:
```console
error: no viable conversion from returned value of type 'X' to function return type 'bool'
```

If I remove the explicit object parameter, we instead print
```console
<source>:15:12: error: no viable conversion from returned value of type 'X' to function return type 'bool'
   15 |     return Error();
      |            ^~~~~~~
```

This appears to be a regression since the source location *is* present in Clang 19.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VEFv8zYM_TX0hWih0JZTH3xwnQT4DsMOK7DuKNt0okGRDElO1x322wfZyZL123acYCSAJD6-90RShaCPlrkG-Qpyl6k5npyvf9LeKz1w1rnhs26dDXpgj0AvpxinAHkDdAA6HN3QOROfnT8CHX4HOihVbOUv3c8lUJWuiQZKsX490Gv6RBOin_uI77B9he0O8rQHool8noyKjJC38XNiq86Mbwj5Di9OD5Dv77ENpmDRICKqOTrce-880Es86bDsAJVAJb6ddACq8AnyfQL7Kyotz3H2Ft-AXha-t7PESjSP3K5pXxHyBhvI2_eEd0frnDM4PuI8Ri-nr8mPvLleeoi9srgp-BvCg38r1I_dRbs5mE-gFqEU71AK1MHCnuBFQFVF7J29sI-6M4zRpUspf0KgFoPDD8bJaxtRWeQ1aYvdHDGeeN1AHfCsQ9D2iAqDm33PaFyvonb267M6G5xhEM2KlTdoHV60SulXKkE7i6N356tUHvCizMzoRkwPjUDbd6BtYjvOtk9Zbq7czhcJtP3ekG8jfkPPZ3fhVcBvk9G9jui6X7mPOCmvzhx5UfnBqG2IrIbVgn8WAnm7ak4llzcbmX4oKfufJCLiRiJsW_yv-lhr-HbrukDu_1jW9069La0xTax8SDw6RoWej57DQj9o268efnlxBGpSFzU4eQ5sI2qLrVH2iJvqORvqfKjySmVcb7ZFISnfvIjsVCsWpVIkuSpHWRSyGsauoLJQxGMnizHTNQmSotjkQhYlieexUELIrpJjPlBFFRSCz0qbZ2Mu5zRlMh3CzPUml5IoM6pjE5bZRdQnPqm_vLOR7QBEQC0Q3RVC3pBI-3KX-TphPnXzMUAhjA4x3LNEHc0yExeRIHf4w7UbvjqjLQ5aHa0LUfc4ptaxF2X08FgX2t7f_APo8O81ms3e1F9mrI6nuXvu3RnokBhe_54m71Iw0GExJQAdrr5cavozAAD__3RGyRw">