| 1 | // |
| 2 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 3 | // See https://llvm.org/LICENSE.txt for license information. |
| 4 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 5 | |
| 6 | // -*- mode:C; c-basic-offset:4; tab-width:4; intent-tabs-mode:nil; -*- |
| 7 | // CONFIG error: incompatible block pointer types assigning |
| 8 | |
| 9 | #import <stdio.h> |
| 10 | #import <stdlib.h> |
| 11 | |
| 12 | int main(int argc, char *argv[]) { |
| 13 | #ifndef __cplusplus |
| 14 | char (^rot13)(); |
| 15 | rot13 = ^(char c) { return (char)(((c - 'a' + 13) % 26) + 'a'); }; |
| 16 | char n = rot13('a'); |
| 17 | char c = rot13('p'); |
| 18 | if ( n != 'n' || c != 'c' ) { |
| 19 | printf(format: "%s: rot13('a') returned %c, rot13('p') returns %c\n" , argv[0], n, c); |
| 20 | exit(status: 1); |
| 21 | } |
| 22 | #else |
| 23 | // yield characteristic error message for C++ |
| 24 | #error incompatible block pointer types assigning |
| 25 | #endif |
| 26 | #ifndef __clang__ |
| 27 | // yield characteristic error message for C++ |
| 28 | #error incompatible block pointer types assigning |
| 29 | #endif |
| 30 | printf(format: "%s: success\n" , argv[0]); |
| 31 | exit(status: 0); |
| 32 | } |
| 33 | |