[Sanitizer] Add rudimentary support for wide-character strings to scanf/printf interc...
[blocksruntime.git] / test / BlocksRuntime / reference.C
blobf86f11e86ce11f187c8d6402d8c806e6dbd863f1
1 //
2 //                     The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
7 #import <Block.h>
8 #import <stdio.h>
9 #import <stdlib.h>
11 // CONFIG C++
13 int recovered = 0;
17 int constructors = 0;
18 int destructors = 0;
20 #define CONST const
22 class TestObject
24 public:
25         TestObject(CONST TestObject& inObj);
26         TestObject();
27         ~TestObject();
28         
29         TestObject& operator=(CONST TestObject& inObj);
30         
31         void test(void);
33         int version() CONST { return _version; }
34 private:
35         mutable int _version;
38 TestObject::TestObject(CONST TestObject& inObj)
39         
41         ++constructors;
42         _version = inObj._version;
43         //printf("%p (%d) -- TestObject(const TestObject&) called", this, _version); 
47 TestObject::TestObject()
49         _version = ++constructors;
50         //printf("%p (%d) -- TestObject() called\n", this, _version); 
54 TestObject::~TestObject()
56         //printf("%p -- ~TestObject() called\n", this);
57         ++destructors;
60 #if 1
61 TestObject& TestObject::operator=(CONST TestObject& inObj)
63         //printf("%p -- operator= called", this);
64         _version = inObj._version;
65         return *this;
67 #endif
69 void TestObject::test(void)  {
70     void (^b)(void) = ^{ recovered = _version; };
71     void (^b2)(void) = Block_copy(b);
72     b2();
73     Block_release(b2);
78 void testRoutine() {
79     TestObject one;
81     
82     one.test();
84     
85     
87 int main(int argc, char *argv[]) {
88     testRoutine();
89     if (recovered == 1) {
90         printf("%s: success\n", argv[0]);
91         exit(0);
92     }
93     printf("%s: *** didn't recover byref block variable\n", argv[0]);
94     exit(1);