| 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 | // byrefcopystack.m |
| 8 | // testObjects |
| 9 | // |
| 10 | // Created by Blaine Garst on 5/13/08. |
| 11 | // |
| 12 | |
| 13 | |
| 14 | |
| 15 | #include <stdio.h> |
| 16 | #include <Block.h> |
| 17 | |
| 18 | // CONFIG rdar://6255170 |
| 19 | |
| 20 | void (^bumpi)(void); |
| 21 | int (^geti)(void); |
| 22 | |
| 23 | void setClosures() { |
| 24 | int __block i = 10; |
| 25 | bumpi = Block_copy(^{ ++i; }); |
| 26 | geti = Block_copy(^{ return i; }); |
| 27 | } |
| 28 | |
| 29 | int main(int argc, char *argv[]) { |
| 30 | setClosures(); |
| 31 | bumpi(); |
| 32 | int i = geti(); |
| 33 | |
| 34 | if (i != 11) { |
| 35 | printf(format: "*** %s didn't update i\n" , argv[0]); |
| 36 | return 1; |
| 37 | } |
| 38 | printf(format: "%s: success\n" , argv[0]); |
| 39 | return 0; |
| 40 | } |
| 41 | |