| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify -Wsign-conversion %s |
| 2 |
|
| 3 |
typedef unsigned int NSUInteger; |
| 4 |
|
| 5 |
@interface NSObject |
| 6 |
- new; |
| 7 |
- (NSUInteger)hash; |
| 8 |
@end |
| 9 |
|
| 10 |
@interface X : NSObject |
| 11 |
@property NSUInteger uint; |
| 12 |
@end |
| 13 |
|
| 14 |
@interface NSArray : NSObject |
| 15 |
|
| 16 |
- (NSUInteger)count; |
| 17 |
- (id)objectAtIndex:(NSUInteger)index; |
| 18 |
- (id)objectAtIndexedSubscript:(NSUInteger)index; |
| 19 |
|
| 20 |
@end |
| 21 |
|
| 22 |
void foo(void) { |
| 23 |
X *x = [X new]; |
| 24 |
signed int sint = -1; |
| 25 |
[x setUint:sint]; // expected-warning {{implicit conversion changes signedness: 'int' to 'NSUInteger'}} |
| 26 |
x.uint = sint; // expected-warning {{implicit conversion changes signedness: 'int' to 'NSUInteger'}} |
| 27 |
} |
| 28 |
|
| 29 |
void Test1(void) { |
| 30 |
signed int si = -1; |
| 31 |
NSArray *array; |
| 32 |
|
| 33 |
(void)((NSObject*)array[si]).hash; // expected-warning {{implicit conversion changes signedness: 'int' to 'NSUInteger'}} |
| 34 |
|
| 35 |
(void)[((NSObject*)array[si]) hash]; // expected-warning {{implicit conversion changes signedness: 'int' to 'NSUInteger'}} |
| 36 |
(void)array[si]; // expected-warning {{implicit conversion changes signedness: 'int' to 'NSUInteger'}} |
| 37 |
} |