Objective-C: More cases of -Wsign-conversion not

working on new Objective-C array subscripting
syntax. // rdar://13855682

llvm-svn: 181940
This commit is contained in:
Fariborz Jahanian 2013-05-15 22:25:03 +00:00
parent 37d3825022
commit 0b11ef2ef0
2 changed files with 28 additions and 8 deletions

View File

@ -5135,11 +5135,13 @@ void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC) {
// Now continue drilling into this expression.
if (PseudoObjectExpr * POE = dyn_cast<PseudoObjectExpr>(E)) {
Expr *Result = POE->getResultExpr();
if (const OpaqueValueExpr *OVE = dyn_cast_or_null<OpaqueValueExpr>(Result))
return AnalyzeImplicitConversions(S, OVE->getSourceExpr(), CC);
if (POE->getResultExpr())
E = POE->getResultExpr();
}
if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(E))
return AnalyzeImplicitConversions(S, OVE->getSourceExpr(), CC);
// Skip past explicit casts.
if (isa<ExplicitCastExpr>(E)) {
E = cast<ExplicitCastExpr>(E)->getSubExpr()->IgnoreParenImpCasts();

View File

@ -1,21 +1,39 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wsign-conversion %s
// rdar://13855394
typedef unsigned int NSUInteger;
@interface NSObject
- new;
- (NSUInteger)hash;
@end
@interface X : NSObject
@property unsigned int uint;
@property NSUInteger uint;
@end
@implementation X
@synthesize uint;
@interface NSArray : NSObject
- (NSUInteger)count;
- (id)objectAtIndex:(NSUInteger)index;
- (id)objectAtIndexedSubscript:(NSUInteger)index;
@end
void foo() {
X *x = [X new];
signed int sint = -1;
[x setUint:sint]; // expected-warning {{implicit conversion changes signedness: 'int' to 'unsigned int'}}
x.uint = sint; // expected-warning {{implicit conversion changes signedness: 'int' to 'unsigned int'}}
[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'}}
}