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 #include <Block.h> 78c1441f8SAlexey Samsonov #include <stdio.h> 88c1441f8SAlexey Samsonov 98c1441f8SAlexey Samsonov // CONFIG rdar://6225809 108c1441f8SAlexey Samsonov // fixed in 5623 118c1441f8SAlexey Samsonov main(int argc,char * argv[])128c1441f8SAlexey Samsonovint main(int argc, char *argv[]) { 138c1441f8SAlexey Samsonov __block int a = 42; 148c1441f8SAlexey Samsonov int* ap = &a; // just to keep the address on the stack. 158c1441f8SAlexey Samsonov 168c1441f8SAlexey Samsonov void (^b)(void) = ^{ 178c1441f8SAlexey Samsonov //a; // workaround, a should be implicitly imported 188c1441f8SAlexey Samsonov Block_copy(^{ 198c1441f8SAlexey Samsonov a = 2; 208c1441f8SAlexey Samsonov }); 218c1441f8SAlexey Samsonov }; 228c1441f8SAlexey Samsonov 238c1441f8SAlexey Samsonov Block_copy(b); 248c1441f8SAlexey Samsonov 258c1441f8SAlexey Samsonov if(&a == ap) { 268c1441f8SAlexey Samsonov printf("**** __block heap storage should have been created at this point\n"); 278c1441f8SAlexey Samsonov return 1; 288c1441f8SAlexey Samsonov } 298c1441f8SAlexey Samsonov printf("%s: Success\n", argv[0]); 308c1441f8SAlexey Samsonov return 0; 318c1441f8SAlexey Samsonov } 32