brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1001 B · 2661eec Raw
33 lines · c
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-exception5 6//  -*- mode:C; c-basic-offset:4; tab-width:4; intent-tabs-mode:nil;  -*-7// CONFIG error: incompatible block pointer types assigning8 9#import <stdio.h>10#import <stdlib.h>11 12int main(int argc, char *argv[]) {13#ifndef __cplusplus14    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("%s: rot13('a') returned %c, rot13('p') returns %c\n", argv[0], n, c);20        exit(1);21    }22#else23// yield characteristic error message for C++24#error incompatible block pointer types assigning25#endif26#ifndef __clang__27// yield characteristic error message for C++28#error incompatible block pointer types assigning29#endif30    printf("%s: success\n", argv[0]);31    exit(0);32}33