summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-12-13 21:29:20 +0000
committerDouglas Gregor <dgregor@apple.com>2009-12-13 21:29:20 +0000
commit202eb8fcfdc6264ad34705647899509157f19e46 (patch)
treef60a71427b3b9c0078ab6dd614a67dacf073ebc8 /clang/lib/Sema/SemaOverload.cpp
parentb08f1a7b329f4d56860557920c09a37608c9b6de (diff)
downloadbcm5719-llvm-202eb8fcfdc6264ad34705647899509157f19e46.tar.gz
bcm5719-llvm-202eb8fcfdc6264ad34705647899509157f19e46.zip
Don't assume that all conversions to a void pointer are converting
from a PointerType. Fixes PR5756. llvm-svn: 91253
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp45
1 files changed, 25 insertions, 20 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index e498c71b9ba..2f6300d5bcb 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1723,26 +1723,31 @@ Sema::CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
if (SCS2.First == ICK_Array_To_Pointer)
FromType2 = Context.getArrayDecayedType(FromType2);
- QualType FromPointee1
- = FromType1->getAs<PointerType>()->getPointeeType().getUnqualifiedType();
- QualType FromPointee2
- = FromType2->getAs<PointerType>()->getPointeeType().getUnqualifiedType();
-
- if (IsDerivedFrom(FromPointee2, FromPointee1))
- return ImplicitConversionSequence::Better;
- else if (IsDerivedFrom(FromPointee1, FromPointee2))
- return ImplicitConversionSequence::Worse;
-
- // Objective-C++: If one interface is more specific than the
- // other, it is the better one.
- const ObjCInterfaceType* FromIface1 = FromPointee1->getAs<ObjCInterfaceType>();
- const ObjCInterfaceType* FromIface2 = FromPointee2->getAs<ObjCInterfaceType>();
- if (FromIface1 && FromIface1) {
- if (Context.canAssignObjCInterfaces(FromIface2, FromIface1))
- return ImplicitConversionSequence::Better;
- else if (Context.canAssignObjCInterfaces(FromIface1, FromIface2))
- return ImplicitConversionSequence::Worse;
- }
+ if (const PointerType *FromPointer1 = FromType1->getAs<PointerType>())
+ if (const PointerType *FromPointer2 = FromType2->getAs<PointerType>()) {
+ QualType FromPointee1
+ = FromPointer1->getPointeeType().getUnqualifiedType();
+ QualType FromPointee2
+ = FromPointer2->getPointeeType().getUnqualifiedType();
+
+ if (IsDerivedFrom(FromPointee2, FromPointee1))
+ return ImplicitConversionSequence::Better;
+ else if (IsDerivedFrom(FromPointee1, FromPointee2))
+ return ImplicitConversionSequence::Worse;
+
+ // Objective-C++: If one interface is more specific than the
+ // other, it is the better one.
+ const ObjCInterfaceType* FromIface1
+ = FromPointee1->getAs<ObjCInterfaceType>();
+ const ObjCInterfaceType* FromIface2
+ = FromPointee2->getAs<ObjCInterfaceType>();
+ if (FromIface1 && FromIface1) {
+ if (Context.canAssignObjCInterfaces(FromIface2, FromIface1))
+ return ImplicitConversionSequence::Better;
+ else if (Context.canAssignObjCInterfaces(FromIface1, FromIface2))
+ return ImplicitConversionSequence::Worse;
+ }
+ }
}
// Compare based on qualification conversions (C++ 13.3.3.2p3,
OpenPOWER on IntegriCloud