xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/sign-conversion.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify -Wsign-conversion %s
2*f4a2713aSLionel Sambuc// rdar://13855394
3*f4a2713aSLionel Sambuc
4*f4a2713aSLionel Sambuctypedef unsigned int NSUInteger;
5*f4a2713aSLionel Sambuc
6*f4a2713aSLionel Sambuc@interface NSObject
7*f4a2713aSLionel Sambuc- new;
8*f4a2713aSLionel Sambuc- (NSUInteger)hash;
9*f4a2713aSLionel Sambuc@end
10*f4a2713aSLionel Sambuc
11*f4a2713aSLionel Sambuc@interface X : NSObject
12*f4a2713aSLionel Sambuc@property NSUInteger uint;
13*f4a2713aSLionel Sambuc@end
14*f4a2713aSLionel Sambuc
15*f4a2713aSLionel Sambuc@interface NSArray : NSObject
16*f4a2713aSLionel Sambuc
17*f4a2713aSLionel Sambuc- (NSUInteger)count;
18*f4a2713aSLionel Sambuc- (id)objectAtIndex:(NSUInteger)index;
19*f4a2713aSLionel Sambuc- (id)objectAtIndexedSubscript:(NSUInteger)index;
20*f4a2713aSLionel Sambuc
21*f4a2713aSLionel Sambuc@end
22*f4a2713aSLionel Sambuc
23*f4a2713aSLionel Sambucvoid foo() {
24*f4a2713aSLionel Sambuc    X *x = [X new];
25*f4a2713aSLionel Sambuc    signed int sint = -1;
26*f4a2713aSLionel Sambuc    [x setUint:sint];  // expected-warning {{implicit conversion changes signedness: 'int' to 'NSUInteger'}}
27*f4a2713aSLionel Sambuc    x.uint = sint; // expected-warning {{implicit conversion changes signedness: 'int' to 'NSUInteger'}}
28*f4a2713aSLionel Sambuc}
29*f4a2713aSLionel Sambuc
30*f4a2713aSLionel Sambuc// rdar://13855682
31*f4a2713aSLionel Sambucvoid Test1() {
32*f4a2713aSLionel Sambucsigned int si = -1;
33*f4a2713aSLionel SambucNSArray *array;
34*f4a2713aSLionel Sambuc
35*f4a2713aSLionel Sambuc(void)((NSObject*)array[si]).hash; // expected-warning {{implicit conversion changes signedness: 'int' to 'NSUInteger'}}
36*f4a2713aSLionel Sambuc
37*f4a2713aSLionel Sambuc(void)[((NSObject*)array[si]) hash]; // expected-warning {{implicit conversion changes signedness: 'int' to 'NSUInteger'}}
38*f4a2713aSLionel Sambuc(void)array[si]; // expected-warning {{implicit conversion changes signedness: 'int' to 'NSUInteger'}}
39*f4a2713aSLionel Sambuc}
40