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.
|
// 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();
|
||||||
|
|
|
@ -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'}}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue