Mike Stump | 58919e1 | 2009-03-04 13:17:22 +0000 | [diff] [blame] | 1 | // RUN: clang %s -emit-llvm -o %t -fblocks -f__block |
| 2 | #include <stdio.h> |
| 3 | |
Mike Stump | 58a8514 | 2009-03-04 22:48:06 +0000 | [diff] [blame^] | 4 | void test1() { |
| 5 | __block int a; |
| 6 | int b=2; |
| 7 | a=1; |
| 8 | printf("a is %d, b is %d\n", a, b); |
| 9 | ^{ a = 10; printf("a is %d, b is %d\n", a, b); }(); |
| 10 | printf("a is %d, b is %d\n", a, b); |
| 11 | a = 1; |
| 12 | printf("a is %d, b is %d\n", a, b); |
| 13 | } |
| 14 | |
| 15 | |
| 16 | void test2() { |
| 17 | __block int a; |
| 18 | a=1; |
| 19 | printf("a is %d\n", a); |
| 20 | ^{ |
| 21 | ^{ |
| 22 | a = 10; |
| 23 | }(); |
| 24 | }(); |
| 25 | printf("a is %d\n", a); |
| 26 | a = 1; |
| 27 | printf("a is %d\n", a); |
| 28 | } |
| 29 | |
Mike Stump | 58919e1 | 2009-03-04 13:17:22 +0000 | [diff] [blame] | 30 | int main() { |
Mike Stump | 58a8514 | 2009-03-04 22:48:06 +0000 | [diff] [blame^] | 31 | test1(); |
| 32 | test2(); |
| 33 | return 0; |
Mike Stump | 58919e1 | 2009-03-04 13:17:22 +0000 | [diff] [blame] | 34 | } |