From 60b3e38d421cab497de1c62c06be6a6a5f321edf Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 16 Mar 2011 18:21:05 +0000 Subject: [PATCH] Don't indescriminately print overload candidates when we have invalid 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 . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127740 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExpr.cpp | 4 ---- test/SemaCXX/overloaded-operator.cpp | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index c208ed2fca..6acd2a5b03 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -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(); } diff --git a/test/SemaCXX/overloaded-operator.cpp b/test/SemaCXX/overloaded-operator.cpp index 4399a026ea..834b8d6e89 100644 --- a/test/SemaCXX/overloaded-operator.cpp +++ b/test/SemaCXX/overloaded-operator.cpp @@ -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 '')}} + } +} -- 2.40.0