summaryrefslogtreecommitdiff
path: root/clang/test/SemaObjCXX/conversion-to-objc-pointer-2.mm
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/SemaObjCXX/conversion-to-objc-pointer-2.mm')
-rw-r--r--clang/test/SemaObjCXX/conversion-to-objc-pointer-2.mm88
1 files changed, 88 insertions, 0 deletions
diff --git a/clang/test/SemaObjCXX/conversion-to-objc-pointer-2.mm b/clang/test/SemaObjCXX/conversion-to-objc-pointer-2.mm
new file mode 100644
index 0000000..b03d4d8
--- /dev/null
+++ b/clang/test/SemaObjCXX/conversion-to-objc-pointer-2.mm
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar: // 7963410
+
+@protocol NSObject @end
+@interface NSObject
+- (id)init;
+- (id) alloc;
+- (id) autorelease;
+@end
+
+template<class T>
+class TNSAutoRef
+{
+public:
+ TNSAutoRef(T t)
+ : fRef(t)
+ { }
+
+ ~TNSAutoRef()
+ { }
+
+ operator T() const
+ { return fRef; }
+
+private:
+ T fRef;
+};
+
+
+#pragma mark -
+
+
+@protocol TFooProtocol <NSObject>
+
+- (void) foo;
+@end
+
+
+#pragma mark -
+
+
+@interface TFoo : NSObject
+
+- (void) setBlah: (id<TFooProtocol>)blah;
+@end
+
+
+#pragma mark -
+
+
+@implementation TFoo
+
+- (void) setBlah: (id<TFooProtocol>)blah
+ { }
+@end
+
+
+#pragma mark -
+
+
+@interface TBar : NSObject
+
+- (void) setBlah: (id)blah;
+@end
+
+#pragma mark -
+
+
+@implementation TBar
+
+- (void) setBlah: (id)blah
+ { }
+@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.
+ if (object1 == object2)
+ [bar setBlah: object2]; // <== Does not compile. It should.
+ return 0;
+}