[AA] Rename CaptureInfo -> CaptureAnalysis (NFC) (#116842)
[llvm-project.git] / compiler-rt / test / BlocksRuntime / byrefcopy.c
blobb1110c9968e27d77b47cbc5ee04fad3f74aa8806
1 //
2 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 // See https://llvm.org/LICENSE.txt for license information.
4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 // byrefcopy.m
8 // testObjects
9 //
10 // Created by Blaine Garst on 5/13/08.
13 #include <stdio.h>
14 #include <Block.h>
15 #include <Block_private.h>
17 // CONFIG
19 void callVoidVoid(void (^closure)(void)) {
20 closure();
23 int main(int argc, char *argv[]) {
24 int __block i = 10;
26 void (^block)(void) = ^{ ++i; };
27 //printf("original (old style) is %s\n", _Block_dump_old(block));
28 //printf("original (new style) is %s\n", _Block_dump(block));
29 void (^blockcopy)(void) = Block_copy(block);
30 //printf("copy is %s\n", _Block_dump(blockcopy));
31 // use a copy & see that it updates i
32 callVoidVoid(block);
34 if (i != 11) {
35 printf("*** %s didn't update i\n", argv[0]);
36 return 1;
38 printf("%s: success\n", argv[0]);
39 return 0;