[cfe-commits] r93173 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/overloaded-operator.cpp
Douglas Gregor
dgregor at apple.com
Mon Jan 11 11:36:35 PST 2010
Author: dgregor
Date: Mon Jan 11 13:36:35 2010
New Revision: 93173
URL: http://llvm.org/viewvc/llvm-project?rev=93173&view=rev
Log:
When computing surrogates for calls to a value of object type, look
for all visible conversion functions.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/overloaded-operator.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=93173&r1=93172&r2=93173&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Jan 11 13:36:35 2010
@@ -5741,9 +5741,8 @@
// functions for each conversion function declared in an
// accessible base class provided the function is not hidden
// within T by another intervening declaration.
- // FIXME: Look in base classes for more conversion operators!
const UnresolvedSet *Conversions
- = cast<CXXRecordDecl>(Record->getDecl())->getConversionFunctions();
+ = cast<CXXRecordDecl>(Record->getDecl())->getVisibleConversionFunctions();
for (UnresolvedSet::iterator I = Conversions->begin(),
E = Conversions->end(); I != E; ++I) {
NamedDecl *D = *I;
Modified: cfe/trunk/test/SemaCXX/overloaded-operator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-operator.cpp?rev=93173&r1=93172&r2=93173&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/overloaded-operator.cpp (original)
+++ cfe/trunk/test/SemaCXX/overloaded-operator.cpp Mon Jan 11 13:36:35 2010
@@ -190,16 +190,23 @@
typedef float& Func2(int, double);
struct ConvertToFunc {
- operator Func1*(); // expected-note{{conversion candidate of type 'INTREF (*)(FLOAT, double)'}}
- operator Func2&(); // expected-note{{conversion candidate of type 'float &(&)(int, double)'}}
+ operator Func1*(); // expected-note 2{{conversion candidate of type 'INTREF (*)(FLOAT, double)'}}
+ operator Func2&(); // expected-note 2{{conversion candidate of type 'float &(&)(int, double)'}}
void operator()();
};
-void test_funcptr_call(ConvertToFunc ctf) {
+struct ConvertToFuncDerived : ConvertToFunc { };
+
+void test_funcptr_call(ConvertToFunc ctf, ConvertToFuncDerived ctfd) {
int &i1 = ctf(1.0f, 2.0);
- float &f2 = ctf((short int)1, 1.0f);
+ float &f1 = ctf((short int)1, 1.0f);
ctf((long int)17, 2.0); // expected-error{{error: call to object of type 'struct ConvertToFunc' is ambiguous; candidates are:}}
ctf();
+
+ int &i2 = ctfd(1.0f, 2.0);
+ float &f2 = ctfd((short int)1, 1.0f);
+ ctfd((long int)17, 2.0); // expected-error{{error: call to object of type 'struct ConvertToFuncDerived' is ambiguous; candidates are:}}
+ ctfd();
}
struct HasMember {
More information about the cfe-commits
mailing list