xref: /aosp_15_r20/external/compiler-rt/test/BlocksRuntime/copynull.c (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot //
2*7c3d14c8STreehugger Robot //                     The LLVM Compiler Infrastructure
3*7c3d14c8STreehugger Robot //
4*7c3d14c8STreehugger Robot // This file is distributed under the University of Illinois Open Source
5*7c3d14c8STreehugger Robot // License. See LICENSE.TXT for details.
6*7c3d14c8STreehugger Robot 
7*7c3d14c8STreehugger Robot /*
8*7c3d14c8STreehugger Robot  *  copynull.c
9*7c3d14c8STreehugger Robot  *  testObjects
10*7c3d14c8STreehugger Robot  *
11*7c3d14c8STreehugger Robot  *  Created by Blaine Garst on 10/15/08.
12*7c3d14c8STreehugger Robot  *
13*7c3d14c8STreehugger Robot  */
14*7c3d14c8STreehugger Robot 
15*7c3d14c8STreehugger Robot #import <stdio.h>
16*7c3d14c8STreehugger Robot #import <Block.h>
17*7c3d14c8STreehugger Robot #import <Block_private.h>
18*7c3d14c8STreehugger Robot 
19*7c3d14c8STreehugger Robot // CONFIG rdar://6295848
20*7c3d14c8STreehugger Robot 
main(int argc,char * argv[])21*7c3d14c8STreehugger Robot int main(int argc, char *argv[]) {
22*7c3d14c8STreehugger Robot 
23*7c3d14c8STreehugger Robot     void (^block)(void) = (void (^)(void))0;
24*7c3d14c8STreehugger Robot     void (^blockcopy)(void) = Block_copy(block);
25*7c3d14c8STreehugger Robot 
26*7c3d14c8STreehugger Robot     if (blockcopy != (void (^)(void))0) {
27*7c3d14c8STreehugger Robot         printf("whoops, somehow we copied NULL!\n");
28*7c3d14c8STreehugger Robot         return 1;
29*7c3d14c8STreehugger Robot     }
30*7c3d14c8STreehugger Robot     // make sure we can also
31*7c3d14c8STreehugger Robot     Block_release(blockcopy);
32*7c3d14c8STreehugger Robot     // and more secretly
33*7c3d14c8STreehugger Robot     //_Block_destroy(blockcopy);
34*7c3d14c8STreehugger Robot 
35*7c3d14c8STreehugger Robot     printf("%s: success\n", argv[0]);
36*7c3d14c8STreehugger Robot     return 0;
37*7c3d14c8STreehugger Robot }
38