From cceafc4931f71dda346705d0a3c98ca34dfbc9a0 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Thu, 27 Oct 2011 20:06:32 +0000 Subject: [PATCH] objc: fix an ir-gen crash caused by recent property refactoring. // rdar://10327068 llvm-svn: 143139 --- clang/lib/Sema/SemaStmt.cpp | 2 +- clang/test/CodeGenObjC/arc-cond-stmt.m | 48 ++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 clang/test/CodeGenObjC/arc-cond-stmt.m diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 887dd3989402..f35b359f57eb 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -497,7 +497,7 @@ Sema::ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, Expr *Cond, return StmtError(); CondResult - = ConvertToIntegralOrEnumerationType(SwitchLoc, Cond, + = ConvertToIntegralOrEnumerationType(SwitchLoc, CondResult.take(), PDiag(diag::err_typecheck_statement_requires_integer), PDiag(diag::err_switch_incomplete_class_type) << Cond->getSourceRange(), diff --git a/clang/test/CodeGenObjC/arc-cond-stmt.m b/clang/test/CodeGenObjC/arc-cond-stmt.m new file mode 100644 index 000000000000..d8ee6bb084b5 --- /dev/null +++ b/clang/test/CodeGenObjC/arc-cond-stmt.m @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -o - %s +// rdar://10327068 + +@class NSString; + +@interface NSAssertionHandler { +} + ++ (NSAssertionHandler *)currentHandler; + +- (void)handleFailureInMethod:(SEL)selector object:(id)object file:(NSString *)fileName lineNumber:(int)line ,...; + +@end + +typedef enum +{ + MWRaceOrder_MeetName, + MWRaceOrder_MeetPosition, + MWRaceOrder_MeetDistance, + MWRaceOrder_Name, + MWRaceOrder_Position, + MWRaceOrder_Distance, + MWRaceOrder_Default = MWRaceOrder_Name, + MWRaceOrder_MeetDefault = MWRaceOrder_MeetName, +} MWRaceOrder; + +@interface MWViewMeetController +@property (nonatomic, assign) MWRaceOrder raceOrder; +@end + +@implementation MWViewMeetController + +- (int)orderSegment +{ + switch (self.raceOrder) + { + + default: + { [(NSAssertionHandler *)0 handleFailureInMethod:_cmd object:self file:(NSString*)0 lineNumber:192 ]; }; + break; + } + + return 0; +} + +@synthesize raceOrder; + +@end