18c1441f8SAlexey Samsonov // 2*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 3*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 4*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 58c1441f8SAlexey Samsonov 68c1441f8SAlexey Samsonov // 78c1441f8SAlexey Samsonov // byrefcopystack.m 88c1441f8SAlexey Samsonov // testObjects 98c1441f8SAlexey Samsonov // 108c1441f8SAlexey Samsonov // Created by Blaine Garst on 5/13/08. 118c1441f8SAlexey Samsonov // 128c1441f8SAlexey Samsonov 138c1441f8SAlexey Samsonov 148c1441f8SAlexey Samsonov 158c1441f8SAlexey Samsonov #include <stdio.h> 168c1441f8SAlexey Samsonov #include <Block.h> 178c1441f8SAlexey Samsonov 188c1441f8SAlexey Samsonov // CONFIG rdar://6255170 198c1441f8SAlexey Samsonov 208c1441f8SAlexey Samsonov void (^bumpi)(void); 218c1441f8SAlexey Samsonov int (^geti)(void); 228c1441f8SAlexey Samsonov setClosures()238c1441f8SAlexey Samsonovvoid setClosures() { 248c1441f8SAlexey Samsonov int __block i = 10; 258c1441f8SAlexey Samsonov bumpi = Block_copy(^{ ++i; }); 268c1441f8SAlexey Samsonov geti = Block_copy(^{ return i; }); 278c1441f8SAlexey Samsonov } 288c1441f8SAlexey Samsonov main(int argc,char * argv[])298c1441f8SAlexey Samsonovint main(int argc, char *argv[]) { 308c1441f8SAlexey Samsonov setClosures(); 318c1441f8SAlexey Samsonov bumpi(); 328c1441f8SAlexey Samsonov int i = geti(); 338c1441f8SAlexey Samsonov 348c1441f8SAlexey Samsonov if (i != 11) { 358c1441f8SAlexey Samsonov printf("*** %s didn't update i\n", argv[0]); 368c1441f8SAlexey Samsonov return 1; 378c1441f8SAlexey Samsonov } 388c1441f8SAlexey Samsonov printf("%s: success\n", argv[0]); 398c1441f8SAlexey Samsonov return 0; 408c1441f8SAlexey Samsonov } 41