85 lines · plain
1// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %s -fsyntax-only -Wobjc-cocoa-api -verify2// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc -x objective-c %s.fixed -fsyntax-only3// RUN: cp %s %t.m4// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %t.m -fixit -Wobjc-cocoa-api5// RUN: diff %s.fixed %t.m6 7typedef signed char BOOL;8#define nil ((void*) 0)9 10@interface NSObject11+ (id)alloc;12@end13 14@interface NSString : NSObject15+ (id)stringWithString:(NSString *)string;16- (id)initWithString:(NSString *)aString;17@end18 19@interface NSArray : NSObject20- (id)objectAtIndex:(unsigned long)index;21- (id)objectAtIndexedSubscript:(int)index;22@end23 24@interface NSArray (NSArrayCreation)25+ (id)array;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;30 31- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;32- (id)initWithObjects:(id)firstObj, ...;33- (id)initWithArray:(NSArray *)array;34 35- (id)objectAtIndex:(unsigned long)index;36@end37 38@interface NSMutableArray : NSArray39- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;40- (void)setObject:(id)object atIndexedSubscript:(int)index;41@end42 43@interface NSDictionary : NSObject44- (id)objectForKeyedSubscript:(id)key;45@end46 47@interface NSDictionary (NSDictionaryCreation)48+ (id)dictionary;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;54 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;59 60- (id)objectForKey:(id)aKey;61@end62 63@interface NSMutableDictionary : NSDictionary64- (void)setObject:(id)anObject forKey:(id)aKey;65- (void)setObject:(id)object forKeyedSubscript:(id)key;66@end67 68@interface NSNumber : NSObject69@end70 71@interface NSNumber (NSNumberCreation)72+ (NSNumber *)numberWithInt:(int)value;73@end74 75#define M(x) (x)76#define PAIR(x) @#x, [NSNumber numberWithInt:(x)]77#define TWO(x) ((x), (x))78 79void foo(void) {80 NSString *str = M(@"foo"); // expected-warning {{redundant}}81 str = @"foo"; // expected-warning {{redundant}}82 NSArray *arr = @[str]; // expected-warning {{redundant}}83 NSDictionary *dict = @{str: arr}; // expected-warning {{redundant}}84}85