1 // RUN: %clang_cc1 -fsyntax-only -verify -Wattributes -fpascal-strings %s
3 typedef long NSInteger;
4 typedef unsigned long NSUInteger;
5 typedef signed char BOOL;
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;
31 void testStruct(void) {
32 point p = { 0, 0, 0 };
33 id boxed = @(p); // expected-error {{illegal type 'point' used in a boxed expression}}
36 void testPointers(void) {
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}}
43 void testInvalid(void) {
44 @(not_defined); // expected-error {{use of undeclared identifier 'not_defined'}}
53 void testEnum(void *p) {
57 box = @(*(enum ForwE*)p); // expected-error {{incomplete type 'enum ForwE' used in a boxed expression}}
63 void testStringLiteral(void) {
67 s = @(u"abc"); // expected-error {{illegal type 'unsigned short *' used in a boxed expression}}
68 s = @(U"abc"); // expected-error {{illegal type 'unsigned int *' used in a boxed expression}}
69 s = @(L"abc"); // expected-error-re {{illegal type {{.*}} used in a boxed expression}}
70 s = @("\pabc"); // expected-error {{illegal type 'unsigned char *' used in a boxed expression}}
73 @class NSMutableDictionary;
75 @interface NSMutableArray
76 + (NSMutableArray*) array;
79 NSMutableDictionary* mBars;
81 __attribute((objc_root_class)) @interface rdar13333205 @end
83 @implementation rdar13333205
84 - (void) insertBar:(id)preset ofKind:(id) kind atIndex:(int)index {
85 NSMutableArray* presetArray = mBars[kind] ?: [NSMutableArray array]; // expected-error {{expected method to read dictionary element not found on object of type 'NSMutableDictionary *'}}