[llvm-commits] [test-suite] r106249 - /test-suite/trunk/SingleSource/UnitTests/ObjC++/property-reference.mm
Fariborz Jahanian
fjahanian at apple.com
Thu Jun 17 16:03:28 PDT 2010
Author: fjahanian
Date: Thu Jun 17 18:03:28 2010
New Revision: 106249
URL: http://llvm.org/viewvc/llvm-project?rev=106249&view=rev
Log:
Test case for fix to radar 7501812 (clang fix).
Added:
test-suite/trunk/SingleSource/UnitTests/ObjC++/property-reference.mm
Added: test-suite/trunk/SingleSource/UnitTests/ObjC++/property-reference.mm
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/ObjC%2B%2B/property-reference.mm?rev=106249&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/ObjC++/property-reference.mm (added)
+++ test-suite/trunk/SingleSource/UnitTests/ObjC++/property-reference.mm Thu Jun 17 18:03:28 2010
@@ -0,0 +1,69 @@
+#import <Cocoa/Cocoa.h>
+#import <tr1/memory>
+// rdar: //7501812
+
+class Value
+{
+public:
+ explicit Value(int amount) : m_amount(amount){}
+
+ int GetAmount() const { return m_amount; }
+
+private:
+ int m_amount;
+};
+
+typedef std::tr1::shared_ptr<Value> ValuePtr;
+
+ at interface ValueUser : NSObject
+{
+ at private
+ ValuePtr* _valuePtr;
+}
+- (id)initWithValue:(ValuePtr&)valuePtr;
+ at property ValuePtr value;
+ at end
+
+ at implementation ValueUser
+- (id)initWithValue:(ValuePtr&)valuePtr
+{
+ self = [super init];
+ _valuePtr = new ValuePtr(valuePtr);
+ return self;
+}
+
+- (void)setValue:(ValuePtr)valuePtr
+{
+ *_valuePtr = valuePtr;
+}
+
+- (ValuePtr)value
+{
+ return *_valuePtr;
+}
+
+- (void)dealloc
+{
+ delete _valuePtr;
+ [super dealloc];
+}
+ at end
+
+int main()
+{
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+
+ ValuePtr valuePtr(new Value(42));
+ ValueUser* valueUser = [[ValueUser alloc] initWithValue:valuePtr];
+
+#ifdef __clang__
+ ::NSLog(@"The value's amount is %d", (valueUser.value)->GetAmount());
+#endif
+ ::NSLog(@"The value's amount is %d", [valueUser value]->GetAmount());
+
+ [valueUser release];
+
+ [pool release];
+
+ return 0;
+}
More information about the llvm-commits
mailing list