diff options
-rw-r--r-- | lib/Parse/ParseObjc.cpp | 18 | ||||
-rw-r--r-- | test/Sema/objc-try-catch.m | 37 |
2 files changed, 48 insertions, 7 deletions
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 6a07503737..933a7a606c 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -1193,15 +1193,19 @@ Parser::StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) { if (Tok.isNot(tok::ellipsis)) { DeclSpec DS; ParseDeclarationSpecifiers(DS); - // FIXME: Is BlockContext right? - Declarator DeclaratorInfo(DS, Declarator::BlockContext); + // For some odd reason, the name of the exception variable is + // optional. As a result, we need to use PrototypeContext. + Declarator DeclaratorInfo(DS, Declarator::PrototypeContext); ParseDeclarator(DeclaratorInfo); - DeclTy *aBlockVarDecl = Actions.ActOnDeclarator(CurScope, + if (DeclaratorInfo.getIdentifier()) { + DeclTy *aBlockVarDecl = Actions.ActOnDeclarator(CurScope, DeclaratorInfo, 0); - StmtResult stmtResult = - Actions.ActOnDeclStmt(aBlockVarDecl, DS.getSourceRange().getBegin(), - DeclaratorInfo.getSourceRange().getEnd()); - FirstPart = stmtResult.isInvalid ? 0 : stmtResult.Val; + StmtResult stmtResult = + Actions.ActOnDeclStmt(aBlockVarDecl, + DS.getSourceRange().getBegin(), + DeclaratorInfo.getSourceRange().getEnd()); + FirstPart = stmtResult.isInvalid ? 0 : stmtResult.Val; + } } else ConsumeToken(); // consume '...' SourceLocation RParenLoc = ConsumeParen(); diff --git a/test/Sema/objc-try-catch.m b/test/Sema/objc-try-catch.m new file mode 100644 index 0000000000..e4c20b7343 --- /dev/null +++ b/test/Sema/objc-try-catch.m @@ -0,0 +1,37 @@ +// RUN: clang -fsyntax-only -verify %s +typedef signed char BOOL; +typedef struct _NSZone NSZone; + +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; + +@protocol NSObject +- (BOOL)isEqual:(id)object; +@end + +@protocol NSCopying +- (id)copyWithZone:(NSZone *)zone; +@end + +@protocol NSCoding +- (void)encodeWithCoder:(NSCoder *)aCoder; +@end + +@interface NSObject <NSObject> {} +@end + +@class NSData, NSArray, NSDictionary, NSCharacterSet, NSData, NSURL, NSError, NSLocale; + +@interface NSException : NSObject <NSCopying, NSCoding> {} +@end + +@class ASTNode, XCRefactoringParser, Transform, TransformInstance, XCRefactoringSelectionInfo; + +@interface XCRefactoringTransformation : NSObject {} +@end + +@implementation XCRefactoringTransformation +- (NSDictionary *)setUpInfoForTransformKey:(NSString *)transformKey outError:(NSError **)outError; { + @try {} + // the exception name is optional (weird) + @catch (NSException *) {} +} |