definitions.c 1.1 KB

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