[llvm-commits] [test-suite] r119159 - /test-suite/trunk/SingleSource/UnitTests/black-copied-in-cxxobj.cpp

Fariborz Jahanian fjahanian at apple.com
Mon Nov 15 09:26:22 PST 2010


Author: fjahanian
Date: Mon Nov 15 11:26:22 2010
New Revision: 119159

URL: http://llvm.org/viewvc/llvm-project?rev=119159&view=rev
Log:
Test case for blocks with cxx objects copied-in.
related to // rdar://8594790

Added:
    test-suite/trunk/SingleSource/UnitTests/black-copied-in-cxxobj.cpp

Added: test-suite/trunk/SingleSource/UnitTests/black-copied-in-cxxobj.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/black-copied-in-cxxobj.cpp?rev=119159&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/black-copied-in-cxxobj.cpp (added)
+++ test-suite/trunk/SingleSource/UnitTests/black-copied-in-cxxobj.cpp Mon Nov 15 11:26:22 2010
@@ -0,0 +1,48 @@
+#if defined(__BLOCKS__) && defined(__clang__)
+// rdar://8594790
+#include <Block.h>
+
+extern "C" void abort();
+
+int count = 100;
+int no=1;
+
+struct S {
+  S() { no = 0; };
+  ~S() { if (no != 0) abort(); }
+};
+
+static S s1;
+
+class A {
+public:
+        int x;
+        A(const A &o) { ++no; x = o.x; }
+        A &operator =(const A &o) { x = o.x; return *this; }
+        A() : x(count++) { ++no; }
+        virtual ~A() { --no; }
+        void hello() const { }
+};
+#endif
+
+int
+main()
+{
+#if defined(__BLOCKS__) && defined(__clang__)
+        A a;
+        A a1;
+        A a2;
+        void (^b)(void) = ^{ a.hello(); a1.hello(); a2.hello(); };
+        b();
+
+        void (^c)(void) = Block_copy(^{ a.hello(); a1.hello(); a2.hello(); });
+        c();
+	if (no != 12)
+	  abort();
+        Block_release(c);
+	if (no != 9)
+	  abort();
+#endif
+        return 0;
+}
+





More information about the llvm-commits mailing list