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 | // |
7 | // nestedimport.m |
8 | // testObjects |
9 | // |
10 | // Created by Blaine Garst on 6/24/08. |
11 | // |
12 | // pure C nothing more needed |
13 | // CONFIG |
14 | |
15 | |
16 | #include <stdio.h> |
17 | #include <stdlib.h> |
18 | |
19 | |
20 | int Global = 0; |
21 | |
22 | void callVoidVoid(void (^closure)(void)) { |
23 | closure(); |
24 | } |
25 | |
26 | int main(int argc, char *argv[]) { |
27 | int i = 1; |
28 | |
29 | void (^vv)(void) = ^{ |
30 | if (argc > 0) { |
31 | callVoidVoid(closure: ^{ Global = i; }); |
32 | } |
33 | }; |
34 | |
35 | i = 2; |
36 | vv(); |
37 | if (Global != 1) { |
38 | printf(format: "%s: error, Global not set to captured value\n" , argv[0]); |
39 | exit(status: 1); |
40 | } |
41 | printf(format: "%s: success\n" , argv[0]); |
42 | return 0; |
43 | } |
44 | |