]> granicus.if.org Git - clang/commitdiff
Don't indescriminately print overload candidates when we have invalid
authorDouglas Gregor <dgregor@apple.com>
Wed, 16 Mar 2011 18:21:05 +0000 (18:21 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 16 Mar 2011 18:21:05 +0000 (18:21 +0000)
operands to a binary expression; it doesn't make sense in all
contexts. The right answer would be to see if the user forgot at ().

Fixes <rdar://problem/9136502>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127740 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaCXX/overloaded-operator.cpp

index c208ed2fcab3e4050abd56c3ea5c59f7afe5c797..6acd2a5b034cdc64f4e8d901fccfec07e8faeefd 100644 (file)
@@ -6312,10 +6312,6 @@ QualType Sema::InvalidOperands(SourceLocation Loc, Expr *&lex, Expr *&rex) {
   Diag(Loc, diag::err_typecheck_invalid_operands)
     << lex->getType() << rex->getType()
     << lex->getSourceRange() << rex->getSourceRange();
-    if (lex->getType() == Context.OverloadTy)
-      NoteAllOverloadCandidates(lex);
-    if (rex->getType() == Context.OverloadTy)
-      NoteAllOverloadCandidates(rex);
   return QualType();
 }
 
index 4399a026eaf49f34a2d3da886f250c71a52d24e2..834b8d6e893893b76466571d60e87c8c1970c162 100644 (file)
@@ -384,3 +384,19 @@ void test_lookup_through_using() {
   N::X2 x;
   x << 17;
 }
+
+namespace rdar9136502 {
+  struct X {
+    int i();
+    int i(int);
+  };
+
+  struct Y {
+    Y &operator<<(int); // expected-note{{candidate function not viable: no overload of 'i' matching 'int' for 1st argument}}
+  };
+
+  void f(X x, Y y) {
+    // FIXME: This diagnostic is non-awesome.
+    y << x.i; // expected-error{{invalid operands to binary expression ('rdar9136502::Y' and '<overloaded function type>')}}
+  }
+}