[cfe-commits] r103719 - in /cfe/trunk: lib/Sema/SemaExprObjC.cpp test/SemaObjCXX/conversion-to-objc-pointer-2.mm test/SemaObjCXX/conversion-to-objc-pointer.mm
Fariborz Jahanian
fjahanian at apple.com
Thu May 13 10:19:25 PDT 2010
Author: fjahanian
Date: Thu May 13 12:19:25 2010
New Revision: 103719
URL: http://llvm.org/viewvc/llvm-project?rev=103719&view=rev
Log:
Objective-C++ Sema. Fix a bug in instantiation of receivers.
Completes radar 7963410.
Added:
cfe/trunk/test/SemaObjCXX/conversion-to-objc-pointer-2.mm
Modified:
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/SemaObjCXX/conversion-to-objc-pointer.mm
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=103719&r1=103718&r2=103719&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Thu May 13 12:19:25 2010
@@ -977,7 +977,12 @@
CastExpr::CK_IntegralToPointer);
ReceiverType = Receiver->getType();
}
- else if (!PerformContextuallyConvertToObjCId(Receiver)) {
+ else if (getLangOptions().CPlusPlus &&
+ !PerformContextuallyConvertToObjCId(Receiver)) {
+ if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Receiver)) {
+ Receiver = ICE->getSubExpr();
+ ReceiverType = Receiver->getType();
+ }
return BuildInstanceMessage(Owned(Receiver),
ReceiverType,
SuperLoc,
Added: cfe/trunk/test/SemaObjCXX/conversion-to-objc-pointer-2.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/conversion-to-objc-pointer-2.mm?rev=103719&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjCXX/conversion-to-objc-pointer-2.mm (added)
+++ cfe/trunk/test/SemaObjCXX/conversion-to-objc-pointer-2.mm Thu May 13 12:19:25 2010
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar: // 7963410
+
+ at protocol NSObject @end
+ at interface NSObject
+- (id)init;
+- (id) alloc;
+- (id) autorelease;
+ at end
+
+template<class T>
+class TNSAutoRef
+{
+public:
+ TNSAutoRef(T t)
+ : fRef(t)
+ { }
+
+ ~TNSAutoRef()
+ { }
+
+ operator T() const
+ { return fRef; }
+
+private:
+ T fRef;
+};
+
+
+#pragma mark -
+
+
+ at protocol TFooProtocol <NSObject>
+
+- (void) foo;
+ at end
+
+
+#pragma mark -
+
+
+ at interface TFoo : NSObject
+
+- (void) setBlah: (id<TFooProtocol>)blah;
+ at end
+
+
+#pragma mark -
+
+
+ at implementation TFoo
+
+- (void) setBlah: (id<TFooProtocol>)blah
+ { }
+ at end
+
+
+#pragma mark -
+
+
+ at interface TBar : NSObject
+
+- (void) setBlah: (id)blah;
+ at end
+
+#pragma mark -
+
+
+ at implementation TBar
+
+- (void) setBlah: (id)blah
+ { }
+ at end
+
+
+#pragma mark -
+
+
+int main (int argc, const char * argv[]) {
+
+ NSObject* object1 = [[[NSObject alloc] init] autorelease];
+ TNSAutoRef<NSObject*> object2([[NSObject alloc] init]);
+ TNSAutoRef<TBar*> bar([[TBar alloc] init]);
+ [bar setBlah: object1]; // <== Does not compile. It should.
+ [bar setBlah: object2]; // <== Does not compile. It should.
+ return 0;
+}
Modified: cfe/trunk/test/SemaObjCXX/conversion-to-objc-pointer.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/conversion-to-objc-pointer.mm?rev=103719&r1=103718&r2=103719&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/conversion-to-objc-pointer.mm (original)
+++ cfe/trunk/test/SemaObjCXX/conversion-to-objc-pointer.mm Thu May 13 12:19:25 2010
@@ -28,20 +28,19 @@
@end
@interface TFoo : NSObject
-
- (void) foo;
@end
@implementation TFoo
-
-- (void) foo
- {}
+- (void) foo {}
@end
@interface TBar : NSObject
+- (void) foo;
@end
@implementation TBar
+- (void) foo {}
@end
int main () {
More information about the cfe-commits
mailing list