diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 42b1340f9a65..a268837b3cc8 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -14322,8 +14322,7 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, FoundDecl = MemExpr->getFoundDecl(); Qualifier = MemExpr->getQualifier(); UnbridgedCasts.restore(); - } else { - UnresolvedMemberExpr *UnresExpr = cast(NakedMemExpr); + } else if (auto *UnresExpr = dyn_cast(NakedMemExpr)) { Qualifier = UnresExpr->getQualifier(); QualType ObjectType = UnresExpr->getBaseType(); @@ -14436,7 +14435,9 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, } MemExpr = cast(MemExprE->IgnoreParens()); - } + } else + // Unimaged NakedMemExpr type. + return ExprError(); QualType ResultType = Method->getReturnType(); ExprValueKind VK = Expr::getValueKindForType(ResultType); diff --git a/clang/test/SemaTemplate/constraints.cpp b/clang/test/SemaTemplate/constraints.cpp index 0bc4727245f6..e2bb6552fdb1 100644 --- a/clang/test/SemaTemplate/constraints.cpp +++ b/clang/test/SemaTemplate/constraints.cpp @@ -24,3 +24,35 @@ namespace PR45589 { // FIXME: These diagnostics are excessive. static_assert(test == 1); // expected-note 2{{while}} expected-note 2{{during}} } + +namespace PR52905 { +// A mock for std::convertible_to. Not complete support. +template +concept convertible_to = __is_convertible_to(_From, _To); // expected-note {{evaluated to false}} + +template +class A { +public: + using iterator = void **; + + iterator begin(); + const iterator begin() const; +}; + +template +concept Beginable1 = requires(T t) { + { t.begin } + ->convertible_to; // expected-note {{not satisfied}} +}; + +static_assert(Beginable1>); // expected-error {{static_assert failed}} + // expected-note@-1 {{does not satisfy 'Beginable1'}} + +template +concept Beginable2 = requires(T t) { + { t.begin() } + ->convertible_to; +}; + +static_assert(Beginable2>); +} // namespace PR52905