From: Steve Naroff Date: Tue, 7 Apr 2009 22:56:58 +0000 (+0000) Subject: Fix [sema] crash on invalid. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=93a259500186fa7270f66cb460c5f5728e5680ae;p=clang Fix [sema] crash on invalid. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68568 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 05c919cbea..8a942c7702 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -1294,8 +1294,14 @@ Parser::OwningStmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) { FirstPart = Actions.ActOnParamDeclarator(CurScope, ParmDecl); } else ConsumeToken(); // consume '...' - SourceLocation RParenLoc = ConsumeParen(); + + SourceLocation RParenLoc; + if (Tok.is(tok::r_paren)) + RParenLoc = ConsumeParen(); + else // Skip over garbage, until we get to ')'. Eat the ')'. + SkipUntil(tok::r_paren, true, false); + OwningStmtResult CatchBody(Actions, true); if (Tok.is(tok::l_brace)) CatchBody = ParseCompoundStatementBody(); diff --git a/test/SemaObjC/exception-go-boom.m b/test/SemaObjC/exception-go-boom.m new file mode 100644 index 0000000000..32dc82dba0 --- /dev/null +++ b/test/SemaObjC/exception-go-boom.m @@ -0,0 +1,9 @@ +// RUN: clang-cc %s -verify -fsyntax-only + +// Note: NSException is not declared. +void f0(id x) { + @try { + } @catch (NSException *x) { // expected-warning{{type specifier missing, defaults to 'int'}} expected-error{{@catch parameter is not an Objective-C class type}} + } +} +