[cfe-commits] r91253 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/overload-call.cpp
Douglas Gregor
dgregor at apple.com
Sun Dec 13 13:29:20 PST 2009
Author: dgregor
Date: Sun Dec 13 15:29:20 2009
New Revision: 91253
URL: http://llvm.org/viewvc/llvm-project?rev=91253&view=rev
Log:
Don't assume that all conversions to a void pointer are converting
from a PointerType. Fixes PR5756.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/overload-call.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=91253&r1=91252&r2=91253&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sun Dec 13 15:29:20 2009
@@ -1723,26 +1723,31 @@
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 (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;
- }
+ 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,
Modified: cfe/trunk/test/SemaCXX/overload-call.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overload-call.cpp?rev=91253&r1=91252&r2=91253&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/overload-call.cpp (original)
+++ cfe/trunk/test/SemaCXX/overload-call.cpp Sun Dec 13 15:29:20 2009
@@ -291,3 +291,13 @@
void g(opt o) {
f(o);
}
+
+
+namespace PR5756 {
+ int &a(void*, int);
+ float &a(void*, float);
+ void b() {
+ int &ir = a(0,0);
+ (void)ir;
+ }
+}
More information about the cfe-commits
mailing list