xref: /llvm-project/compiler-rt/test/BlocksRuntime/rettypepromotion.c (revision 2946cd701067404b99c39fb29dc9c74bd7193eb3)
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 /*
7  *  rettypepromotion.c
8  *  testObjects
9  *
10  *  Created by Blaine Garst on 11/3/08.
11  *
12  */
13 
14 // CONFIG error:
15 // C++ and C give different errors so we don't check for an exact match.
16 // The error is that enum's are defined to be ints, always, even if defined with explicit long values
17 
18 
19 #include <stdio.h>
20 #include <stdlib.h>
21 
22 enum { LESS = -1, EQUAL, GREATER };
23 
24 void sortWithBlock(long (^comp)(void *arg1, void *arg2)) {
25 }
26 
main(int argc,char * argv[])27 int main(int argc, char *argv[]) {
28     sortWithBlock(^(void *arg1, void *arg2) {
29         if (random()) return LESS;
30         if (random()) return EQUAL;
31         if (random()) return GREATER;
32     });
33     printf("%s: Success\n", argv[0]);
34     return 0;
35 }
36