objective-C: don't crash after diagnosing

using object subscripting without declaring objectForKeyedSubscript:
// rdar://13333205


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176539 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Fariborz Jahanian 2013-03-06 00:37:40 +00:00
parent b4e82454b6
commit 75525c4cce
2 changed files with 19 additions and 2 deletions

View File

@ -547,7 +547,7 @@ ExprResult Sema::UsualUnaryConversions(Expr *E) {
// First, convert to an r-value.
ExprResult Res = DefaultFunctionArrayLvalueConversion(E);
if (Res.isInvalid())
return Owned(E);
return ExprError();
E = Res.take();
QualType Ty = E->getType();
@ -598,7 +598,7 @@ ExprResult Sema::DefaultArgumentPromotion(Expr *E) {
ExprResult Res = UsualUnaryConversions(E);
if (Res.isInvalid())
return Owned(E);
return ExprError();
E = Res.take();
// If this is a 'float' or '__fp16' (CVR qualified or typedef) promote to

View File

@ -56,3 +56,20 @@ void testEnum(void *p) {
box = @(ME_foo);
box = @(*(enum ForwE*)p); // expected-error {{incomplete type 'enum ForwE' used in a boxed expression}}
}
// rdar://13333205
@class NSMutableDictionary;
@interface NSMutableArray
+ (NSMutableArray*) array;
@end
NSMutableDictionary* mBars;
__attribute((objc_root_class)) @interface rdar13333205 @end
@implementation rdar13333205
- (void) insertBar:(id)preset ofKind:(id) kind atIndex:(int)index {
NSMutableArray* presetArray = mBars[kind] ?: [NSMutableArray array]; // expected-error {{expected method to read dictionary element not found on object of type 'NSMutableDictionary *'}}
}
@end