[llvm-commits] [test-suite] r128436 - in /test-suite/trunk/SingleSource/UnitTests/ObjC++: Makefile property-reference-object.mm property-reference-object.reference_output
Fariborz Jahanian
fjahanian at apple.com
Mon Mar 28 16:48:25 PDT 2011
Author: fjahanian
Date: Mon Mar 28 18:48:25 2011
New Revision: 128436
URL: http://llvm.org/viewvc/llvm-project?rev=128436&view=rev
Log:
This is test for clang's // rdar://9070460.
I have modified the Makefile so test is skipped
for llvm-gcc (which does not fully support this feature).
Added:
test-suite/trunk/SingleSource/UnitTests/ObjC++/property-reference-object.mm
test-suite/trunk/SingleSource/UnitTests/ObjC++/property-reference-object.reference_output
Modified:
test-suite/trunk/SingleSource/UnitTests/ObjC++/Makefile
Modified: test-suite/trunk/SingleSource/UnitTests/ObjC++/Makefile
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/ObjC%2B%2B/Makefile?rev=128436&r1=128435&r2=128436&view=diff
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/ObjC++/Makefile (original)
+++ test-suite/trunk/SingleSource/UnitTests/ObjC++/Makefile Mon Mar 28 18:48:25 2011
@@ -6,4 +6,10 @@
LDFLAGS += -lstdc++ -lobjc -framework Foundation
PROGRAM_REQUIRED_TO_EXIT_OK := 1
+
+# This is a known gcc / llvm-gcc miscompilation fixed in clang.
+ifdef CC_UNDER_TEST_IS_LLVM_GCC
+EXEC_XFAILS = property-reference-object
+endif
+
include $(LEVEL)/SingleSource/Makefile.singlesrc
Added: test-suite/trunk/SingleSource/UnitTests/ObjC++/property-reference-object.mm
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/ObjC%2B%2B/property-reference-object.mm?rev=128436&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/ObjC++/property-reference-object.mm (added)
+++ test-suite/trunk/SingleSource/UnitTests/ObjC++/property-reference-object.mm Mon Mar 28 18:48:25 2011
@@ -0,0 +1,105 @@
+#import <Foundation/Foundation.h>
+
+static int count;
+class Foo
+{
+ static int sNextId;
+ int mId;
+ int mRefId;
+public:
+ Foo(const Foo& rhs){
+ mId = sNextId++;
+ mRefId = rhs.mId;
+ printf("Foo(%d,%d)\n", mId, mRefId);
+ };
+
+ Foo() {
+ mId = sNextId++;
+ mRefId = mId;
+ printf("Foo(%d,%d)\n", mId,mRefId);
+ }
+ ~Foo(){
+ printf("~Foo(%d, %d)\n", mId, mRefId);
+ };
+
+ Foo& operator=(const Foo& rhs){
+ mRefId = rhs.mRefId;
+ return *this;
+ };
+
+ int Data() { return fData; };
+
+private:
+ int fData;
+};
+
+int Foo::sNextId = 0;
+
+
+#pragma mark -
+
+
+ at interface TNSObject : NSObject
+{
+ at private
+ Foo _cppObjectNonAtomic;
+ Foo _cppObjectAtomic;
+ Foo _cppObjectDynamic;
+}
+
+ at property (assign, readwrite, nonatomic) const Foo& cppObjectNonAtomic;
+ at property (assign, readwrite) const Foo& cppObjectAtomic;
+ at property (assign, readwrite, nonatomic) const Foo& cppObjectDynamic;
+ at end
+
+
+#pragma mark -
+
+
+ at implementation TNSObject
+
+ at synthesize cppObjectNonAtomic = _cppObjectNonAtomic;
+ at synthesize cppObjectAtomic = _cppObjectAtomic;
+ at dynamic cppObjectDynamic;
+
+- (id)init
+{
+ self = [super init];
+ if (self) {
+
+ // Add your subclass-specific initialization here.
+ // If an error occurs here, send a [self release] message and return nil.
+
+ Foo cppObject;
+ self.cppObjectNonAtomic = cppObject;
+ self.cppObjectAtomic = cppObject;
+ self.cppObjectDynamic = cppObject;
+ }
+ return self;
+}
+
+- (const Foo&) cppObjectDynamic
+{
+ return _cppObjectDynamic;
+}
+
+- (void) setCppObjectDynamic: (const Foo&)cppObject
+{
+ _cppObjectDynamic = cppObject;
+}
+ at end
+
+
+#pragma mark -
+
+
+int main (int argc, const char * argv[])
+{
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ [[[TNSObject alloc] init] autorelease];
+
+ [pool drain];
+ return 0;
+}
+
Added: test-suite/trunk/SingleSource/UnitTests/ObjC++/property-reference-object.reference_output
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/ObjC%2B%2B/property-reference-object.reference_output?rev=128436&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/ObjC++/property-reference-object.reference_output (added)
+++ test-suite/trunk/SingleSource/UnitTests/ObjC++/property-reference-object.reference_output Mon Mar 28 18:48:25 2011
@@ -0,0 +1,14 @@
+Foo(0,0)
+Foo(1,1)
+Foo(2,2)
+Foo(3,3)
+Foo(4,3)
+~Foo(4, 3)
+Foo(5,3)
+~Foo(5, 3)
+Foo(6,3)
+~Foo(6, 3)
+~Foo(3, 3)
+~Foo(2, 3)
+~Foo(1, 3)
+~Foo(0, 3)
More information about the llvm-commits
mailing list