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