[Sanitizer] Add rudimentary support for wide-character strings to scanf/printf interc...
[blocksruntime.git] / test / BlocksRuntime / byrefcopycopy.c
blobd6fafc152e1da79bbd4eacef46ee8bd0baca914e
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 // CONFIG rdar://6255170
9 #include <stdio.h>
10 #include <stdbool.h>
11 #include <stdlib.h>
12 #include <Block.h>
13 #include <Block_private.h>
14 #include <assert.h>
17 int
18 main(int argc, char *argv[])
20 __block int var = 0;
21 int shouldbe = 0;
22 void (^b)(void) = ^{ var++; /*printf("var is at %p with value %d\n", &var, var);*/ };
23 __typeof(b) _b;
24 //printf("before copy...\n");
25 b(); ++shouldbe;
26 size_t i;
28 for (i = 0; i < 10; i++) {
29 _b = Block_copy(b); // make a new copy each time
30 assert(_b);
31 ++shouldbe;
32 _b(); // should still update the stack
33 Block_release(_b);
36 //printf("after...\n");
37 b(); ++shouldbe;
39 if (var != shouldbe) {
40 printf("Hmm, var is %d but should be %d\n", var, shouldbe);
41 return 1;
43 printf("%s: Success!!\n", argv[0]);
45 return 0;