Fix <rdar://problem/6640991> Exception handling executes wrong clause (Daniel, please verify).
Also necessary to fix:
<rdar://problem/6632061> [sema] non object types should not be allowed in @catch statements
<rdar://problem/6252237> [sema] qualified id should be disallowed in @catch statements
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65964 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index 193a73f..3637d14 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -1285,7 +1285,7 @@
SourceLocation AtCatchFinallyLoc = ConsumeToken();
if (Tok.isObjCAtKeyword(tok::objc_catch)) {
- OwningStmtResult FirstPart(Actions);
+ DeclTy *FirstPart = 0;
ConsumeToken(); // consume catch
if (Tok.is(tok::l_paren)) {
ConsumeParen();
@@ -1294,17 +1294,14 @@
DeclSpec DS;
ParseDeclarationSpecifiers(DS);
// 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);
- if (DeclaratorInfo.getIdentifier()) {
- DeclTy *aBlockVarDecl = Actions.ActOnDeclarator(CurScope,
- DeclaratorInfo, 0);
- FirstPart =
- Actions.ActOnDeclStmt(aBlockVarDecl,
- DS.getSourceRange().getBegin(),
- DeclaratorInfo.getSourceRange().getEnd());
- }
+ // optional. As a result, we need to use "PrototypeContext", because
+ // we must accept either 'declarator' or 'abstract-declarator' here.
+ Declarator ParmDecl(DS, Declarator::PrototypeContext);
+ ParseDeclarator(ParmDecl);
+
+ // Inform the actions module about the parameter declarator, so it
+ // gets added to the current scope.
+ FirstPart = Actions.ActOnParamDeclarator(CurScope, ParmDecl);
} else
ConsumeToken(); // consume '...'
SourceLocation RParenLoc = ConsumeParen();
@@ -1317,7 +1314,7 @@
if (CatchBody.isInvalid())
CatchBody = Actions.ActOnNullStmt(Tok.getLocation());
CatchStmts = Actions.ActOnObjCAtCatchStmt(AtCatchFinallyLoc,
- RParenLoc, move(FirstPart), move(CatchBody),
+ RParenLoc, FirstPart, move(CatchBody),
move(CatchStmts));
} else {
Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after)