[cfe-commits] r98557 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaObjCXX/objc-pointer-conv.mm
Fariborz Jahanian
fjahanian at apple.com
Mon Mar 15 11:36:00 PDT 2010
Author: fjahanian
Date: Mon Mar 15 13:36:00 2010
New Revision: 98557
URL: http://llvm.org/viewvc/llvm-project?rev=98557&view=rev
Log:
objective-c++ must take into account qualifiers when
considering valid objc pointer converions.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaObjCXX/objc-pointer-conv.mm
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=98557&r1=98556&r2=98557&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Mar 15 13:36:00 2010
@@ -1135,6 +1135,12 @@
// Objective C++: We're able to convert from a pointer to an
// interface to a pointer to a different interface.
if (Context.canAssignObjCInterfaces(ToObjCPtr, FromObjCPtr)) {
+ const ObjCInterfaceType* LHS = ToObjCPtr->getInterfaceType();
+ const ObjCInterfaceType* RHS = FromObjCPtr->getInterfaceType();
+ if (getLangOptions().CPlusPlus && LHS && RHS &&
+ !ToObjCPtr->getPointeeType().isAtLeastAsQualifiedAs(
+ FromObjCPtr->getPointeeType()))
+ return false;
ConvertedType = ToType;
return true;
}
Modified: cfe/trunk/test/SemaObjCXX/objc-pointer-conv.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/objc-pointer-conv.mm?rev=98557&r1=98556&r2=98557&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/objc-pointer-conv.mm (original)
+++ cfe/trunk/test/SemaObjCXX/objc-pointer-conv.mm Mon Mar 15 13:36:00 2010
@@ -24,3 +24,15 @@
RandomFunc((CFMDRef)dict, key, objects[3]);
}
@end
+
+ at interface I
+- (void) Meth : (I*) Arg;
+ at end
+
+void Func (I* arg); // expected-note {{candidate function not viable: no known conversion from 'I const *' to 'I *' for 1st argument}}
+
+void foo(const I *p, I* sel) {
+ [sel Meth : p]; // expected-error {{incompatible type sending 'I const *', expected 'I *'}}
+ Func(p); // expected-error {{no matching function for call to 'Func'}}
+}
+
More information about the cfe-commits
mailing list