diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -12821,6 +12821,8 @@ auto ConsiderCandidate = [&](const OverloadCandidate &Candidate) { if (!Candidate.Function) return; + if (Candidate.Function->isInvalidDecl()) + return; QualType T = Candidate.Function->getReturnType(); if (T.isNull()) return; diff --git a/clang/test/SemaCXX/recovery-expr-type.cpp b/clang/test/SemaCXX/recovery-expr-type.cpp --- a/clang/test/SemaCXX/recovery-expr-type.cpp +++ b/clang/test/SemaCXX/recovery-expr-type.cpp @@ -68,3 +68,10 @@ int &&f(int); // expected-note {{candidate function not viable}} int &&k = f(); // expected-error {{no matching function for call}} } + +// verify that "type 'double' cannot bind to a value of unrelated type 'int'" diagnostic is suppressed. +namespace test5 { + template using U = T; // expected-note {{template parameter is declared here}} + template U& f(); // expected-error {{pack expansion used as argument for non-pack parameter of alias template}} + double &s1 = f(); // expected-error {{no matching function}} +}