Author: Haojian Wu Date: 2020-08-11T13:49:57+02:00 New Revision: 031738a5611843674d5f739e739e8a386d5e741b
URL: https://github.com/llvm/llvm-project/commit/031738a5611843674d5f739e739e8a386d5e741b DIFF: https://github.com/llvm/llvm-project/commit/031738a5611843674d5f739e739e8a386d5e741b.diff LOG: [AST][RecoveryExpr] Don't preserve the return type if the FunctionDecl is invalid. If a functionDecl is invalid (e.g. return type cannot be formed), int is use as he fallback type, which may lead to some bogus diagnostics. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D85714 Added: Modified: clang/lib/Sema/SemaOverload.cpp clang/test/SemaCXX/recovery-expr-type.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 5a20a7990c3b..bcf6aa7a310e 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -12821,6 +12821,8 @@ static QualType chooseRecoveryType(OverloadCandidateSet &CS, 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 index 6cd79326e8c3..2ce47f2f8efc 100644 --- a/clang/test/SemaCXX/recovery-expr-type.cpp +++ b/clang/test/SemaCXX/recovery-expr-type.cpp @@ -68,3 +68,10 @@ namespace test4 { 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<typename T> using U = T; // expected-note {{template parameter is declared here}} + template<typename...Ts> U<Ts...>& f(); // expected-error {{pack expansion used as argument for non-pack parameter of alias template}} + double &s1 = f(); // expected-error {{no matching function}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits