]> granicus.if.org Git - clang/commitdiff
When computing surrogates for calls to a value of object type, look
authorDouglas Gregor <dgregor@apple.com>
Mon, 11 Jan 2010 19:36:35 +0000 (19:36 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 11 Jan 2010 19:36:35 +0000 (19:36 +0000)
for all visible conversion functions.

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

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

index e1d32497d923ab2bfd774acc5189e78e1178ed25..05e06a33ef579b9523ba1a4828da0a53b7cf1d3b 100644 (file)
@@ -5741,9 +5741,8 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
   //   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;
index 5c4db7f7f8bec4ebae1742c5c4b74f98c4a31034..861d679c72611bf420b200c6b1812a32060f7dd4 100644 (file)
@@ -190,16 +190,23 @@ typedef INTREF Func1(FLOAT, double);
 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 {