[llvm-commits] [test-suite] r120715 - /test-suite/trunk/SingleSource/UnitTests/block-byref-cxxobj-test.cpp

Fariborz Jahanian fjahanian at apple.com
Thu Dec 2 09:14:17 PST 2010


Author: fjahanian
Date: Thu Dec  2 11:14:17 2010
New Revision: 120715

URL: http://llvm.org/viewvc/llvm-project?rev=120715&view=rev
Log:
Test for // rdar://8594790

Added:
    test-suite/trunk/SingleSource/UnitTests/block-byref-cxxobj-test.cpp

Added: test-suite/trunk/SingleSource/UnitTests/block-byref-cxxobj-test.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/block-byref-cxxobj-test.cpp?rev=120715&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/block-byref-cxxobj-test.cpp (added)
+++ test-suite/trunk/SingleSource/UnitTests/block-byref-cxxobj-test.cpp Thu Dec  2 11:14:17 2010
@@ -0,0 +1,46 @@
+// rdar://8594790
+#if defined(__BLOCKS__) && defined(__clang__)
+#include <Block.h>
+extern "C" void abort();
+static int count=0;
+class A {
+public:
+        int x;
+        A(const A &o) { ++count; x = o.x; 
+	  if (this == &o)
+            abort();
+        }
+        A &operator =(const A &o) { x = o.x; return *this; }
+        A() : x(100) { ++count; }
+        ~A();
+        void hello() const { 
+          if (x != 100) 
+            abort();
+        }
+};
+
+A::~A() { 
+  --count; 
+  if (x != 100)
+    abort();
+  x = 0; 
+}
+#endif
+
+int
+main()
+{
+#if defined(__BLOCKS__) && defined(__clang__)
+  if (!count) {
+        __block A a;
+        A ca;
+        void (^b)(void) = Block_copy(^{ a.hello(); ca.hello(); });
+        b();
+        Block_release(b);
+  }
+  if (count)
+    abort();
+#endif
+  return 0;
+}
+





More information about the llvm-commits mailing list