r176539 - objective-C: don't crash after diagnosing
Fariborz Jahanian
fjahanian at apple.com
Tue Mar 5 16:37:40 PST 2013
Author: fjahanian
Date: Tue Mar 5 18:37:40 2013
New Revision: 176539
URL: http://llvm.org/viewvc/llvm-project?rev=176539&view=rev
Log:
objective-C: don't crash after diagnosing
using object subscripting without declaring objectForKeyedSubscript:
// rdar://13333205
Added:
cfe/trunk/test/SemaObjC/boxing-illegal.m
- copied, changed from r176490, cfe/trunk/test/SemaObjC/boxing-illegal-types.m
Removed:
cfe/trunk/test/SemaObjC/boxing-illegal-types.m
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=176539&r1=176538&r2=176539&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Mar 5 18:37:40 2013
@@ -547,7 +547,7 @@ ExprResult Sema::UsualUnaryConversions(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::DefaultArgumentPromotio
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
Removed: cfe/trunk/test/SemaObjC/boxing-illegal-types.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/boxing-illegal-types.m?rev=176538&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/boxing-illegal-types.m (original)
+++ cfe/trunk/test/SemaObjC/boxing-illegal-types.m (removed)
@@ -1,58 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wattributes %s
-
-typedef long NSInteger;
-typedef unsigned long NSUInteger;
-typedef signed char BOOL;
-
- at interface NSNumber
- at end
- at interface NSNumber (NSNumberCreation)
-+ (NSNumber *)numberWithChar:(char)value;
-+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
-+ (NSNumber *)numberWithShort:(short)value;
-+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
-+ (NSNumber *)numberWithInt:(int)value;
-+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
-+ (NSNumber *)numberWithLong:(long)value;
-+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
-+ (NSNumber *)numberWithLongLong:(long long)value;
-+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
-+ (NSNumber *)numberWithFloat:(float)value;
-+ (NSNumber *)numberWithDouble:(double)value;
-+ (NSNumber *)numberWithBool:(BOOL)value;
-+ (NSNumber *)numberWithInteger:(NSInteger)value;
-+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value;
- at end
-
-typedef struct {
- int x, y, z;
-} point;
-
-void testStruct() {
- point p = { 0, 0, 0 };
- id boxed = @(p); // expected-error {{illegal type 'point' used in a boxed expression}}
-}
-
-void testPointers() {
- void *null = 0;
- id boxed_null = @(null); // expected-error {{illegal type 'void *' used in a boxed expression}}
- int numbers[] = { 0, 1, 2 };
- id boxed_numbers = @(numbers); // expected-error {{illegal type 'int *' used in a boxed expression}}
-}
-
-void testInvalid() {
- @(not_defined); // expected-error {{use of undeclared identifier 'not_defined'}}
-}
-
-enum MyEnum {
- ME_foo
-};
-
-enum ForwE;
-
-void testEnum(void *p) {
- enum MyEnum myen;
- id box = @(myen);
- box = @(ME_foo);
- box = @(*(enum ForwE*)p); // expected-error {{incomplete type 'enum ForwE' used in a boxed expression}}
-}
Copied: cfe/trunk/test/SemaObjC/boxing-illegal.m (from r176490, cfe/trunk/test/SemaObjC/boxing-illegal-types.m)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/boxing-illegal.m?p2=cfe/trunk/test/SemaObjC/boxing-illegal.m&p1=cfe/trunk/test/SemaObjC/boxing-illegal-types.m&r1=176490&r2=176539&rev=176539&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/boxing-illegal-types.m (original)
+++ cfe/trunk/test/SemaObjC/boxing-illegal.m Tue Mar 5 18:37:40 2013
@@ -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
+ at class NSMutableDictionary;
+
+ at interface NSMutableArray
++ (NSMutableArray*) array;
+ at end
+
+NSMutableDictionary* mBars;
+
+__attribute((objc_root_class)) @interface rdar13333205 @end
+
+ at 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 *'}}
+}
+ at end
More information about the cfe-commits
mailing list