xref: /aosp_15_r20/external/compiler-rt/test/BlocksRuntime/k-and-r.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 //  -*- mode:C; c-basic-offset:4; tab-width:4; intent-tabs-mode:nil;  -*-
8*7c3d14c8STreehugger Robot // CONFIG error: incompatible block pointer types assigning
9*7c3d14c8STreehugger Robot 
10*7c3d14c8STreehugger Robot #import <stdio.h>
11*7c3d14c8STreehugger Robot #import <stdlib.h>
12*7c3d14c8STreehugger Robot 
main(int argc,char * argv[])13*7c3d14c8STreehugger Robot int main(int argc, char *argv[]) {
14*7c3d14c8STreehugger Robot #ifndef __cplusplus
15*7c3d14c8STreehugger Robot     char (^rot13)();
16*7c3d14c8STreehugger Robot     rot13 = ^(char c) { return (char)(((c - 'a' + 13) % 26) + 'a'); };
17*7c3d14c8STreehugger Robot     char n = rot13('a');
18*7c3d14c8STreehugger Robot     char c = rot13('p');
19*7c3d14c8STreehugger Robot     if ( n != 'n' || c != 'c' ) {
20*7c3d14c8STreehugger Robot         printf("%s: rot13('a') returned %c, rot13('p') returns %c\n", argv[0], n, c);
21*7c3d14c8STreehugger Robot         exit(1);
22*7c3d14c8STreehugger Robot     }
23*7c3d14c8STreehugger Robot #else
24*7c3d14c8STreehugger Robot // yield characteristic error message for C++
25*7c3d14c8STreehugger Robot #error incompatible block pointer types assigning
26*7c3d14c8STreehugger Robot #endif
27*7c3d14c8STreehugger Robot #ifndef __clang__
28*7c3d14c8STreehugger Robot // yield characteristic error message for C++
29*7c3d14c8STreehugger Robot #error incompatible block pointer types assigning
30*7c3d14c8STreehugger Robot #endif
31*7c3d14c8STreehugger Robot     printf("%s: success\n", argv[0]);
32*7c3d14c8STreehugger Robot     exit(0);
33*7c3d14c8STreehugger Robot }
34