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 // nullblockisa.m
88c1441f8SAlexey Samsonov // testObjects
98c1441f8SAlexey Samsonov //
108c1441f8SAlexey Samsonov // Created by Blaine Garst on 9/24/08.
118c1441f8SAlexey Samsonov //
128c1441f8SAlexey Samsonov // CONFIG rdar://6244520
138c1441f8SAlexey Samsonov
148c1441f8SAlexey Samsonov
158c1441f8SAlexey Samsonov
168c1441f8SAlexey Samsonov #include <stdio.h>
178c1441f8SAlexey Samsonov #include <stdlib.h>
188c1441f8SAlexey Samsonov #include <Block_private.h>
198c1441f8SAlexey Samsonov
208c1441f8SAlexey Samsonov
218c1441f8SAlexey Samsonov void check(void (^b)(void)) {
228c1441f8SAlexey Samsonov struct _custom {
238c1441f8SAlexey Samsonov struct Block_layout layout;
248c1441f8SAlexey Samsonov struct Block_byref *innerp;
258c1441f8SAlexey Samsonov } *custom = (struct _custom *)(void *)(b);
268c1441f8SAlexey Samsonov //printf("block is at %p, size is %lx, inner is %p\n", (void *)b, Block_size(b), innerp);
278c1441f8SAlexey Samsonov if (custom->innerp->isa != (void *)NULL) {
288c1441f8SAlexey Samsonov printf("not a NULL __block isa\n");
298c1441f8SAlexey Samsonov exit(1);
308c1441f8SAlexey Samsonov }
318c1441f8SAlexey Samsonov return;
328c1441f8SAlexey Samsonov }
338c1441f8SAlexey Samsonov
main(int argc,char * argv[])348c1441f8SAlexey Samsonov int main(int argc, char *argv[]) {
358c1441f8SAlexey Samsonov
368c1441f8SAlexey Samsonov __block int i;
378c1441f8SAlexey Samsonov
388c1441f8SAlexey Samsonov check(^{ printf("%d\n", ++i); });
398c1441f8SAlexey Samsonov printf("%s: success\n", argv[0]);
408c1441f8SAlexey Samsonov return 0;
418c1441f8SAlexey Samsonov }
428c1441f8SAlexey Samsonov
43