]> git.saurik.com Git - apple/objc4.git/blob - test/definitions.c
c35123431d006e8d40dc7a7f390197e5b96928d5
[apple/objc4.git] / test / definitions.c
1 // TEST_CONFIG
2
3 // DO NOT include anything else here
4 #include <objc/objc.h>
5 // DO NOT include anything else here
6 Class c = Nil;
7 SEL s;
8 IMP i;
9 id o = nil;
10 BOOL b = YES;
11 BOOL b2 = NO;
12 #if !__has_feature(objc_arc)
13 __strong void *p;
14 #endif
15 id __unsafe_unretained u;
16 id __weak w;
17
18 void fn(void) __unused;
19 void fn(void) {
20 id __autoreleasing a __unused;
21 }
22
23 #if __llvm__ && !__clang__
24 // llvm-gcc defines _NSConcreteGlobalBlock wrong
25 #else
26 // rdar://10118972 wrong type inference for blocks returning YES and NO
27 BOOL (^block1)(void) = ^{ return YES; };
28 BOOL (^block2)(void) = ^{ return NO; };
29 #endif
30
31 #include "test.h"
32
33 int main()
34 {
35 testassert(YES);
36 testassert(!NO);
37 #if __cplusplus
38 testwarn("rdar://12371870 -Wnull-conversion");
39 testassert(!(bool)nil);
40 testassert(!(bool)Nil);
41 #else
42 testassert(!nil);
43 testassert(!Nil);
44 #endif
45
46 #if __has_feature(objc_bool)
47 // YES[array] is disallowed for objc just as true[array] is for C++
48 #else
49 // this will fail if YES and NO do not have enough parentheses
50 int array[2] = { 888, 999 };
51 testassert(NO[array] == 888);
52 testassert(YES[array] == 999);
53 #endif
54
55 succeed(__FILE__);
56 }