llvm-project
30 строк · 699.0 Байт
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
14int main(int argc, char *argv[]) {15__block int c = 1;16
17//printf("&c = %p - c = %i\n", &c, c);18
19int i;20for(i =0; i < 2; i++) {21dispatch_block_t block = Block_copy(^{ c = i; });22
23block();24// printf("%i: &c = %p - c = %i\n", i, &c, c);
25
26Block_release(block);27}28printf("%s: success\n", argv[0]);29return 0;30}
31