2013-05-16 03:03:04 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wsign-conversion %s
|
|
|
|
// rdar://13855394
|
|
|
|
|
2013-05-16 06:25:03 +08:00
|
|
|
typedef unsigned int NSUInteger;
|
|
|
|
|
2013-05-16 03:03:04 +08:00
|
|
|
@interface NSObject
|
|
|
|
- new;
|
2013-05-16 06:25:03 +08:00
|
|
|
- (NSUInteger)hash;
|
2013-05-16 03:03:04 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface X : NSObject
|
2013-05-16 06:25:03 +08:00
|
|
|
@property NSUInteger uint;
|
2013-05-16 03:03:04 +08:00
|
|
|
@end
|
|
|
|
|
2013-05-16 06:25:03 +08:00
|
|
|
@interface NSArray : NSObject
|
|
|
|
|
|
|
|
- (NSUInteger)count;
|
|
|
|
- (id)objectAtIndex:(NSUInteger)index;
|
|
|
|
- (id)objectAtIndexedSubscript:(NSUInteger)index;
|
|
|
|
|
2013-05-16 03:03:04 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
void foo() {
|
|
|
|
X *x = [X new];
|
|
|
|
signed int sint = -1;
|
2013-05-16 06:25:03 +08:00
|
|
|
[x setUint:sint]; // expected-warning {{implicit conversion changes signedness: 'int' to 'NSUInteger'}}
|
|
|
|
x.uint = sint; // expected-warning {{implicit conversion changes signedness: 'int' to 'NSUInteger'}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// rdar://13855682
|
|
|
|
void Test1() {
|
|
|
|
signed int si = -1;
|
|
|
|
NSArray *array;
|
|
|
|
|
|
|
|
(void)((NSObject*)array[si]).hash; // expected-warning {{implicit conversion changes signedness: 'int' to 'NSUInteger'}}
|
|
|
|
|
|
|
|
(void)[((NSObject*)array[si]) hash]; // expected-warning {{implicit conversion changes signedness: 'int' to 'NSUInteger'}}
|
|
|
|
(void)array[si]; // expected-warning {{implicit conversion changes signedness: 'int' to 'NSUInteger'}}
|
2013-05-16 03:03:04 +08:00
|
|
|
}
|