Skip to content

[Clang] Missing source location in diagnostic for invalid conversion in function w/ explicit object parameter #135522

@Sirraide

Description

@Sirraide

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

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:

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

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

Metadata

Metadata

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"regression:20Regression in 20 release

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions