1// RUN: %clang_cc1 -Wno-objc-root-class %s -verify 2// RUN: %clang_cc1 -xobjective-c++ -Wno-objc-root-class %s -verify 3 4#define YES __objc_yes 5#define NO __objc_no 6 7@interface NSNumber 8+(instancetype)numberWithChar:(char)value; 9+(instancetype)numberWithInt:(int)value; 10+(instancetype)numberWithDouble:(double)value; 11+(instancetype)numberWithBool:(unsigned char)value; 12+(instancetype)numberWithUnsignedLong:(unsigned long)value; 13+(instancetype)numberWithLongLong:(long long) value; 14+(instancetype)numberWithUnsignedInt:(unsigned)value; 15@end 16 17@interface NSString 18@end 19 20@interface NSDictionary 21+ (instancetype)dictionaryWithObjects:(const id[])objects 22 forKeys:(const id[])keys 23 count:(unsigned long)cnt; 24@end 25 26void test(void) { 27 NSDictionary *t1 = @{ 28 @"foo" : @0, // expected-note 2 {{previous equal key is here}} 29 @"foo" : @0, // expected-warning{{duplicate key in dictionary literal}} 30 @("foo") : @0, // expected-warning{{duplicate key in dictionary literal}} 31 @"foo\0" : @0, 32 33 @1 : @0, // expected-note + {{previous equal key is here}} 34 @YES : @0, // expected-warning{{duplicate key in dictionary literal}} 35 @'\1' : @0, // expected-warning{{duplicate key in dictionary literal}} 36 @1 : @0, // expected-warning{{duplicate key in dictionary literal}} 37 @1ul : @0, // expected-warning{{duplicate key in dictionary literal}} 38 @1ll : @0, // expected-warning{{duplicate key in dictionary literal}} 39#ifdef __cplusplus 40 @true : @0, // expected-warning{{duplicate key in dictionary literal}} 41#endif 42 @1.0 : @0, // FIXME: should warn 43 44 @-1 : @0, // expected-note + {{previous equal key is here}} 45 @4294967295u : @0, // no warning 46 @-1ll : @0, // expected-warning{{duplicate key in dictionary literal}} 47 @(NO-YES) : @0, // expected-warning{{duplicate key in dictionary literal}} 48 }; 49} 50 51#ifdef __cplusplus 52template <class... Ts> void variadic(Ts... ts) { 53 NSDictionary *nd = @{ 54 ts : @0 ..., 55 @0 : ts ... // expected-warning 2 {{duplicate key in dictionary literal}} expected-note 2 {{previous equal key is here}} 56 }; 57} 58 59void call_variadic() { 60 variadic(@0, @1, @2); // expected-note {{in instantiation}} 61} 62#endif 63