xref: /aosp_15_r20/external/compiler-rt/test/BlocksRuntime/constassign.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 //  constassign.c
9*7c3d14c8STreehugger Robot //  bocktest
10*7c3d14c8STreehugger Robot //
11*7c3d14c8STreehugger Robot //  Created by Blaine Garst on 3/21/08.
12*7c3d14c8STreehugger Robot //
13*7c3d14c8STreehugger Robot // shouldn't be able to assign to a const pointer
14*7c3d14c8STreehugger Robot // CONFIG error: assignment of read-only
15*7c3d14c8STreehugger Robot 
16*7c3d14c8STreehugger Robot #import <stdio.h>
17*7c3d14c8STreehugger Robot 
foo(void)18*7c3d14c8STreehugger Robot void foo(void) { printf("I'm in foo\n"); }
bar(void)19*7c3d14c8STreehugger Robot void bar(void) { printf("I'm in bar\n"); }
20*7c3d14c8STreehugger Robot 
main(int argc,char * argv[])21*7c3d14c8STreehugger Robot int main(int argc, char *argv[]) {
22*7c3d14c8STreehugger Robot     void (*const fptr)(void) = foo;
23*7c3d14c8STreehugger Robot     void (^const  blockA)(void) = ^ { printf("hello\n"); };
24*7c3d14c8STreehugger Robot     blockA = ^ { printf("world\n"); } ;
25*7c3d14c8STreehugger Robot     fptr = bar;
26*7c3d14c8STreehugger Robot     printf("%s: success\n", argv[0]);
27*7c3d14c8STreehugger Robot     return 0;
28*7c3d14c8STreehugger Robot }
29