1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %s -fsyntax-only -Wobjc-cocoa-api -verify
2 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc -x objective-c %s.fixed -fsyntax-only
4 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %t.m -fixit -Wobjc-cocoa-api
5 // RUN: diff %s.fixed %t.m
7 typedef signed char BOOL;
8 #define nil ((void*) 0)
14 @interface NSString : NSObject
15 + (id)stringWithString:(NSString *)string;
16 - (id)initWithString:(NSString *)aString;
19 @interface NSArray : NSObject
20 - (id)objectAtIndex:(unsigned long)index;
21 - (id)objectAtIndexedSubscript:(int)index;
24 @interface NSArray (NSArrayCreation)
26 + (id)arrayWithObject:(id)anObject;
27 + (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
28 + (id)arrayWithObjects:(id)firstObj, ...;
29 + (id)arrayWithArray:(NSArray *)array;
31 - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
32 - (id)initWithObjects:(id)firstObj, ...;
33 - (id)initWithArray:(NSArray *)array;
35 - (id)objectAtIndex:(unsigned long)index;
38 @interface NSMutableArray : NSArray
39 - (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
40 - (void)setObject:(id)object atIndexedSubscript:(int)index;
43 @interface NSDictionary : NSObject
44 - (id)objectForKeyedSubscript:(id)key;
47 @interface NSDictionary (NSDictionaryCreation)
49 + (id)dictionaryWithObject:(id)object forKey:(id)key;
50 + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
51 + (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...;
52 + (id)dictionaryWithDictionary:(NSDictionary *)dict;
53 + (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
55 - (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
56 - (id)initWithObjectsAndKeys:(id)firstObject, ...;
57 - (id)initWithDictionary:(NSDictionary *)otherDictionary;
58 - (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
60 - (id)objectForKey:(id)aKey;
63 @interface NSMutableDictionary : NSDictionary
64 - (void)setObject:(id)anObject forKey:(id)aKey;
65 - (void)setObject:(id)object forKeyedSubscript:(id)key;
68 @interface NSNumber : NSObject
71 @interface NSNumber (NSNumberCreation)
72 + (NSNumber *)numberWithInt:(int)value;
76 #define PAIR(x) @#x, [NSNumber numberWithInt:(x)]
77 #define TWO(x) ((x), (x))
80 NSString *str = M([NSString stringWithString:@"foo"]); // expected-warning {{redundant}}
81 str = [[NSString alloc] initWithString:@"foo"]; // expected-warning {{redundant}}
82 NSArray *arr = [NSArray arrayWithArray:@[str]]; // expected-warning {{redundant}}
83 NSDictionary *dict = [NSDictionary dictionaryWithDictionary:@{str: arr}]; // expected-warning {{redundant}}