hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: clang.
hokein requested review of this revision.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85714

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===================================================================
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ 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<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}}
+}
Index: clang/lib/Sema/SemaOverload.cpp
===================================================================
--- clang/lib/Sema/SemaOverload.cpp
+++ 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;


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===================================================================
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ 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<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}}
+}
Index: clang/lib/Sema/SemaOverload.cpp
===================================================================
--- clang/lib/Sema/SemaOverload.cpp
+++ 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;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D85714: [AST][RecoveryE... Haojian Wu via Phabricator via cfe-commits

Reply via email to