[cfe-commits] r81475 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/arrow-operator.cpp
Anders Carlsson
andersca at mac.com
Thu Sep 10 16:18:36 PDT 2009
Author: andersca
Date: Thu Sep 10 18:18:36 2009
New Revision: 81475
URL: http://llvm.org/viewvc/llvm-project?rev=81475&view=rev
Log:
Look for overloaded arrow operators in base classes.
Added:
cfe/trunk/test/SemaCXX/arrow-operator.cpp
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=81475&r1=81474&r2=81475&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Sep 10 18:18:36 2009
@@ -4878,9 +4878,11 @@
OverloadCandidateSet CandidateSet;
const RecordType *BaseRecord = Base->getType()->getAs<RecordType>();
- DeclContext::lookup_const_iterator Oper, OperEnd;
- for (llvm::tie(Oper, OperEnd)
- = BaseRecord->getDecl()->lookup(OpName); Oper != OperEnd; ++Oper)
+ LookupResult R = LookupQualifiedName(BaseRecord->getDecl(), OpName,
+ LookupOrdinaryName);
+
+ for (LookupResult::iterator Oper = R.begin(), OperEnd = R.end();
+ Oper != OperEnd; ++Oper)
AddMethodCandidate(cast<CXXMethodDecl>(*Oper), Base, 0, 0, CandidateSet,
/*SuppressUserConversions=*/false);
@@ -4903,14 +4905,14 @@
case OR_Ambiguous:
Diag(OpLoc, diag::err_ovl_ambiguous_oper)
- << "operator->" << Base->getSourceRange();
+ << "->" << Base->getSourceRange();
PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/true);
return ExprError();
case OR_Deleted:
Diag(OpLoc, diag::err_ovl_deleted_oper)
<< Best->Function->isDeleted()
- << "operator->" << Base->getSourceRange();
+ << "->" << Base->getSourceRange();
PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/true);
return ExprError();
}
Added: cfe/trunk/test/SemaCXX/arrow-operator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/arrow-operator.cpp?rev=81475&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/arrow-operator.cpp (added)
+++ cfe/trunk/test/SemaCXX/arrow-operator.cpp Thu Sep 10 18:18:36 2009
@@ -0,0 +1,22 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+struct T {
+ void f();
+};
+
+struct A {
+ T* operator->(); // expected-note{{candidate function}}
+};
+
+struct B {
+ T* operator->(); // expected-note{{candidate function}}
+};
+
+struct C : A, B {
+};
+
+struct D : A { };
+
+void f(C &c, D& d) {
+ c->f(); // expected-error{{use of overloaded operator '->' is ambiguous}}
+ d->f();
+}
\ No newline at end of file
More information about the cfe-commits
mailing list