63 lines · plain
1// RUN: %clang_cc1 -Wno-objc-root-class %s -verify2// RUN: %clang_cc1 -xobjective-c++ -Wno-objc-root-class %s -verify3 4#define YES __objc_yes5#define NO __objc_no6 7@interface NSNumber8+(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@end16 17@interface NSString18@end19 20@interface NSDictionary21+ (instancetype)dictionaryWithObjects:(const id[])objects22 forKeys:(const id[])keys23 count:(unsigned long)cnt;24@end25 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 __cplusplus40 @true : @0, // expected-warning{{duplicate key in dictionary literal}}41#endif42 @1.0 : @0, // FIXME: should warn43 44 @-1 : @0, // expected-note + {{previous equal key is here}}45 @4294967295u : @0, // no warning46 @-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 __cplusplus52template <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#endif63