[llvm-commits] [test-suite] r130548 - in /test-suite/trunk/SingleSource/UnitTests/ObjC: block-byref-aggr.m block-byref-aggr.reference_output
Fariborz Jahanian
fjahanian at apple.com
Fri Apr 29 15:04:21 PDT 2011
Author: fjahanian
Date: Fri Apr 29 17:04:21 2011
New Revision: 130548
URL: http://llvm.org/viewvc/llvm-project?rev=130548&view=rev
Log:
Executable test for clang's // rdar://9309454
Added:
test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.m
test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.reference_output
Added: test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.m
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.m?rev=130548&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.m (added)
+++ test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.m Fri Apr 29 17:04:21 2011
@@ -0,0 +1,36 @@
+#import <Foundation/Foundation.h>
+#import <dispatch/dispatch.h>
+
+typedef struct { uintptr_t v; } RetType;
+#define logRetType(msg, val) printf(msg, val.v);
+
+RetType func(dispatch_block_t block);
+
+RetType func(dispatch_block_t block) {
+ block = Block_copy(block);
+ block();
+
+ RetType ret = {4};
+ return ret;
+}
+
+int main (int argc, const char * argv[]) {
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ __block RetType a = {0};
+ dispatch_block_t b = ^{
+ logRetType("a was originally: %ld\n", a);
+ };
+
+ a = func(b);
+ logRetType("a is now: %ld\n", a);
+
+ // b was Block_copied already, so the result is different.
+
+ a = func(b);
+ logRetType("a has become: %ld\n", a);
+
+ [pool drain];
+ return 0;
+}
+
Added: test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.reference_output
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.reference_output?rev=130548&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.reference_output (added)
+++ test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.reference_output Fri Apr 29 17:04:21 2011
@@ -0,0 +1,5 @@
+a was originally: 0
+a is now: 4
+a was originally: 4
+a has become: 4
+exit 0
More information about the llvm-commits
mailing list