[Clang] Missing source location in diagnostic for invalid conversion in function w/ explicit object parameter · Issue #135522 · llvm/llvm-project (original) (raw)

Consider (https://godbolt.org/z/aa475YbW6):

struct X{};

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

struct B : A { 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:

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

: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.