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. // Now continue drilling into this expression.
if (PseudoObjectExpr * POE = dyn_cast<PseudoObjectExpr>(E)) { if (PseudoObjectExpr * POE = dyn_cast<PseudoObjectExpr>(E)) {
Expr *Result = POE->getResultExpr(); if (POE->getResultExpr())
if (const OpaqueValueExpr *OVE = dyn_cast_or_null<OpaqueValueExpr>(Result)) E = POE->getResultExpr();
return AnalyzeImplicitConversions(S, OVE->getSourceExpr(), CC);
} }
if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(E))
return AnalyzeImplicitConversions(S, OVE->getSourceExpr(), CC);
// Skip past explicit casts. // Skip past explicit casts.
if (isa<ExplicitCastExpr>(E)) { if (isa<ExplicitCastExpr>(E)) {
E = cast<ExplicitCastExpr>(E)->getSubExpr()->IgnoreParenImpCasts(); E = cast<ExplicitCastExpr>(E)->getSubExpr()->IgnoreParenImpCasts();

View File

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