[cfe-commits] r51895 - in /cfe/trunk: lib/Parse/ParseObjc.cpp test/Sema/objc-try-catch.m
Steve Naroff
snaroff at apple.com
Mon Jun 2 22:36:55 PDT 2008
Author: snaroff
Date: Tue Jun 3 00:36:54 2008
New Revision: 51895
URL: http://llvm.org/viewvc/llvm-project?rev=51895&view=rev
Log:
Fix parser bug/FIXME with @catch.
<rdar://problem/5980846> clang on xcode: error: declarator requires an identifier (for @catch)
Added:
cfe/trunk/test/Sema/objc-try-catch.m
Modified:
cfe/trunk/lib/Parse/ParseObjc.cpp
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=51895&r1=51894&r2=51895&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue Jun 3 00:36:54 2008
@@ -1193,15 +1193,19 @@
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();
Added: cfe/trunk/test/Sema/objc-try-catch.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/objc-try-catch.m?rev=51895&view=auto
==============================================================================
--- cfe/trunk/test/Sema/objc-try-catch.m (added)
+++ cfe/trunk/test/Sema/objc-try-catch.m Tue Jun 3 00:36:54 2008
@@ -0,0 +1,37 @@
+// RUN: clang -fsyntax-only -verify %s
+typedef signed char BOOL;
+typedef struct _NSZone NSZone;
+
+ at class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+
+ at protocol NSObject
+- (BOOL)isEqual:(id)object;
+ at end
+
+ at protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+ at end
+
+ at protocol NSCoding
+- (void)encodeWithCoder:(NSCoder *)aCoder;
+ at end
+
+ at interface NSObject <NSObject> {}
+ at end
+
+ at class NSData, NSArray, NSDictionary, NSCharacterSet, NSData, NSURL, NSError, NSLocale;
+
+ at interface NSException : NSObject <NSCopying, NSCoding> {}
+ at end
+
+ at class ASTNode, XCRefactoringParser, Transform, TransformInstance, XCRefactoringSelectionInfo;
+
+ at interface XCRefactoringTransformation : NSObject {}
+ at end
+
+ at implementation XCRefactoringTransformation
+- (NSDictionary *)setUpInfoForTransformKey:(NSString *)transformKey outError:(NSError **)outError; {
+ @try {}
+ // the exception name is optional (weird)
+ @catch (NSException *) {}
+}
More information about the cfe-commits
mailing list