xref: /llvm-project/compiler-rt/test/BlocksRuntime/copynull.c (revision 2946cd701067404b99c39fb29dc9c74bd7193eb3)
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  *  copynull.c
88c1441f8SAlexey Samsonov  *  testObjects
98c1441f8SAlexey Samsonov  *
108c1441f8SAlexey Samsonov  *  Created by Blaine Garst on 10/15/08.
118c1441f8SAlexey Samsonov  *
128c1441f8SAlexey Samsonov  */
138c1441f8SAlexey Samsonov 
148c1441f8SAlexey Samsonov #import <stdio.h>
158c1441f8SAlexey Samsonov #import <Block.h>
168c1441f8SAlexey Samsonov #import <Block_private.h>
178c1441f8SAlexey Samsonov 
188c1441f8SAlexey Samsonov // CONFIG rdar://6295848
198c1441f8SAlexey Samsonov 
main(int argc,char * argv[])208c1441f8SAlexey Samsonov int main(int argc, char *argv[]) {
218c1441f8SAlexey Samsonov 
228c1441f8SAlexey Samsonov     void (^block)(void) = (void (^)(void))0;
238c1441f8SAlexey Samsonov     void (^blockcopy)(void) = Block_copy(block);
248c1441f8SAlexey Samsonov 
258c1441f8SAlexey Samsonov     if (blockcopy != (void (^)(void))0) {
268c1441f8SAlexey Samsonov         printf("whoops, somehow we copied NULL!\n");
278c1441f8SAlexey Samsonov         return 1;
288c1441f8SAlexey Samsonov     }
298c1441f8SAlexey Samsonov     // make sure we can also
308c1441f8SAlexey Samsonov     Block_release(blockcopy);
318c1441f8SAlexey Samsonov     // and more secretly
328c1441f8SAlexey Samsonov     //_Block_destroy(blockcopy);
338c1441f8SAlexey Samsonov 
348c1441f8SAlexey Samsonov     printf("%s: success\n", argv[0]);
358c1441f8SAlexey Samsonov     return 0;
368c1441f8SAlexey Samsonov }
37