1 // RUN: %clang_cc1 -fsyntax-only -verify -Wattributes %s 2 3 typedef long NSInteger; 4 typedef unsigned long NSUInteger; 5 typedef signed char BOOL; 6 7 @interface NSNumber 8 @end 9 @interface NSNumber (NSNumberCreation) 10 + (NSNumber *)numberWithChar:(char)value; 11 + (NSNumber *)numberWithUnsignedChar:(unsigned char)value; 12 + (NSNumber *)numberWithShort:(short)value; 13 + (NSNumber *)numberWithUnsignedShort:(unsigned short)value; 14 + (NSNumber *)numberWithInt:(int)value; 15 + (NSNumber *)numberWithUnsignedInt:(unsigned int)value; 16 + (NSNumber *)numberWithLong:(long)value; 17 + (NSNumber *)numberWithUnsignedLong:(unsigned long)value; 18 + (NSNumber *)numberWithLongLong:(long long)value; 19 + (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; 20 + (NSNumber *)numberWithFloat:(float)value; 21 + (NSNumber *)numberWithDouble:(double)value; 22 + (NSNumber *)numberWithBool:(BOOL)value; 23 + (NSNumber *)numberWithInteger:(NSInteger)value; 24 + (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value; 25 @end 26 27 typedef struct { 28 int x, y, z; 29 } point; 30 31 void testStruct() { 32 point p = { 0, 0, 0 }; 33 id boxed = @(p); // expected-error {{illegal type 'point' used in a boxed expression}} 34 } 35 36 void testPointers() { 37 void *null = 0; 38 id boxed_null = @(null); // expected-error {{illegal type 'void *' used in a boxed expression}} 39 int numbers[] = { 0, 1, 2 }; 40 id boxed_numbers = @(numbers); // expected-error {{illegal type 'int *' used in a boxed expression}} 41 } 42 43 void testInvalid() { 44 @(not_defined); // expected-error {{use of undeclared identifier 'not_defined'}} 45 } 46 47 enum MyEnum { 48 ME_foo 49 }; 50 51 enum ForwE; 52 53 void testEnum(void *p) { 54 enum MyEnum myen; 55 id box = @(myen); 56 box = @(ME_foo); 57 box = @(*(enum ForwE*)p); // expected-error {{incomplete type 'enum ForwE' used in a boxed expression}} 58 } 59 60 // rdar://13333205 61 @class NSMutableDictionary; 62 63 @interface NSMutableArray 64 + (NSMutableArray*) array; 65 @end 66 67 NSMutableDictionary* mBars; 68 69 __attribute((objc_root_class)) @interface rdar13333205 @end 70 71 @implementation rdar13333205 72 - (void) insertBar:(id)preset ofKind:(id) kind atIndex:(int)index { 73 NSMutableArray* presetArray = mBars[kind] ?: [NSMutableArray array]; // expected-error {{expected method to read dictionary element not found on object of type 'NSMutableDictionary *'}} 74 } 75 @end 76