[cfe-commits] r127740 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/overloaded-operator.cpp
Douglas Gregor
dgregor at apple.com
Wed Mar 16 11:21:05 PDT 2011
Author: dgregor
Date: Wed Mar 16 13:21:05 2011
New Revision: 127740
URL: http://llvm.org/viewvc/llvm-project?rev=127740&view=rev
Log:
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 <rdar://problem/9136502>.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/overloaded-operator.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=127740&r1=127739&r2=127740&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Mar 16 13:21:05 2011
@@ -6312,10 +6312,6 @@
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();
}
Modified: cfe/trunk/test/SemaCXX/overloaded-operator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-operator.cpp?rev=127740&r1=127739&r2=127740&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/overloaded-operator.cpp (original)
+++ cfe/trunk/test/SemaCXX/overloaded-operator.cpp Wed Mar 16 13:21:05 2011
@@ -384,3 +384,19 @@
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>')}}
+ }
+}
More information about the cfe-commits
mailing list