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