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