aboutsummaryrefslogtreecommitdiff
path: root/SingleSource/UnitTests/block-copied-in-cxxobj-1.cpp
blob: 44a3dac683d7b1a7b810213e7df5a8b3e7314413 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#if defined(__BLOCKS__) && defined(__clang__)
// rdar://8768050
#include <stdio.h>
#include <stdlib.h>
#include <Block.h>

static int expected_dtors;

class A {
private:
	void *p;
public:
	A() throw() {
	}
	A(const A &a) throw() : p(a.p) {
	}
	A &operator =(const A &a) throw() {
		return *this;
	}
	~A() throw() {
		expected_dtors--;
		if (expected_dtors < 0) {
			abort();
		}
	}
	void m() const throw() {
	}
};

#endif

int
main(void)
{
#if defined(__BLOCKS__) && defined(__clang__)
	A a;

	void (^b)(void) = Block_copy(^{
		a.m();
	});

	b();

        expected_dtors = 3;
	Block_release(b);
#endif
	return 0;
}