forked from OSchip/llvm-project
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:
parent
37d3825022
commit
0b11ef2ef0
|
@ -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();
|
||||
|
|
|
@ -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'}}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue