diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index f7f198f15a4e0..3436f2d22eb3c 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -401,6 +401,8 @@ Bug Fixes in This Version - ``#embed`` directive now diagnoses use of a non-character file (device file) such as ``/dev/urandom`` as an error. This restriction may be relaxed in the future. See (#GH126629). +- Fixed a clang 20 regression where diagnostics attached to some calls to member functions + using C++23 "deducing this" did not have a diagnostic location (#GH135522) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 5fab2c73f214b..59c0e47c7c195 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -1652,8 +1652,11 @@ SourceLocation CallExpr::getBeginLoc() const { if (!isTypeDependent()) { if (const auto *Method = dyn_cast_if_present(getCalleeDecl()); - Method && Method->isExplicitObjectMemberFunction()) - return getArg(0)->getBeginLoc(); + Method && Method->isExplicitObjectMemberFunction()) { + if (auto FirstArgLoc = getArg(0)->getBeginLoc(); FirstArgLoc.isValid()) { + return FirstArgLoc; + } + } } SourceLocation begin = getCallee()->getBeginLoc(); diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp b/clang/test/SemaCXX/cxx2b-deducing-this.cpp index 6f17ce7275456..7e392213710a4 100644 --- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp +++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp @@ -1134,3 +1134,10 @@ struct S { static_assert((S{} << 11) == a); // expected-error@-1 {{use of undeclared identifier 'a'}} } + +namespace GH135522 { +struct S { + auto f(this auto) -> S; + bool g() { return f(); } // expected-error {{no viable conversion from returned value of type 'S' to function return type 'bool'}} +}; +}