1/*
2 * Copyright (c) 2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LLVM_LICENSE_HEADER@
5 */
6
7/*
8 *  rettypepromotion.c
9 *  testObjects
10 *
11 *  Created by Blaine Garst on 11/3/08.
12 *  Copyright 2008 __MyCompanyName__. All rights reserved.
13 *
14 */
15
16// TEST_CONFIG RUN=0
17/*
18TEST_BUILD_OUTPUT
19.*rettypepromotion.c: In function '.*main.*':
20.*rettypepromotion.c:48: error: incompatible block pointer types initializing 'int \(\^\)\(void \*, void \*\)', expected 'long int \(\^\)\(void \*, void \*\)'
21OR
22.*rettypepromotion.c: In function '.*main.*':
23.*rettypepromotion.c:48: error: cannot convert 'e \(\^\)\(void\*, void\*\)' to 'long int \(\^\)\(void\*, void\*\)' for argument '1' to 'void sortWithBlock\(long int \(\^\)\(void\*, void\*\)\)'
24OR
25.*rettypepromotion.c:44:19: error: incompatible block pointer types passing 'int \(\^\)\(void \*, void \*\)' to parameter of type 'long \(\^\)\(void \*, void \*\)'
26.*rettypepromotion.c:39:27: note: passing argument to parameter 'comp' here
27OR
28.*rettypepromotion.c:44:5: error: no matching function for call to 'sortWithBlock'
29.*rettypepromotion.c:39:6: note: candidate function not viable: no known conversion from 'e \(\^\)\(void \*, void \*\)' to 'long \(\^\)\(void \*, void \*\)' for 1st argument
30END
31 */
32
33#include <stdio.h>
34#include <stdlib.h>
35#include "test.h"
36
37typedef enum { LESS = -1, EQUAL, GREATER } e;
38
39void sortWithBlock(long (^comp)(void *arg1, void *arg2)) {
40    comp(0, 0);
41}
42
43int main() {
44    sortWithBlock(^(void *arg1 __unused, void *arg2 __unused) {
45        if (random()) return LESS;
46        if (random()) return EQUAL;
47        return GREATER;
48    });
49
50    succeed(__FILE__);
51}
52