| 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 |
| 5 | |
| 6 | // CONFIG rdar://6414583 |
| 7 | |
| 8 | // a smaller case of byrefcopyint |
| 9 | |
| 10 | #include <Block.h> |
| 11 | #include <dispatch/dispatch.h> |
| 12 | #include <stdio.h> |
| 13 | |
| 14 | int main(int argc, char *argv[]) { |
| 15 | __block int c = 1; |
| 16 | |
| 17 | //printf("&c = %p - c = %i\n", &c, c); |
| 18 | |
| 19 | int i; |
| 20 | for(i =0; i < 2; i++) { |
| 21 | dispatch_block_t block = Block_copy(^{ c = i; }); |
| 22 | |
| 23 | block(); |
| 24 | // printf("%i: &c = %p - c = %i\n", i, &c, c); |
| 25 | |
| 26 | Block_release(block); |
| 27 | } |
| 28 | printf(format: "%s: success\n" , argv[0]); |
| 29 | return 0; |
| 30 | } |
| 31 | |