From: Ted Kremenek Date: Tue, 20 Apr 2010 21:21:51 +0000 (+0000) Subject: Fix crash on invalid code where a @throw statement is not followed by a ';' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=02418c7f0cb8bb83f1a1a1fad9bf6104efa83e0e;p=clang Fix crash on invalid code where a @throw statement is not followed by a ';' git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101941 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 928ffb8afa..057907d112 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -1448,7 +1448,8 @@ Parser::OwningStmtResult Parser::ParseObjCThrowStmt(SourceLocation atLoc) { return StmtError(); } } - ConsumeToken(); // consume ';' + // consume ';' + ExpectAndConsume(tok::semi, diag::err_expected_semi_after, "@throw"); return Actions.ActOnObjCAtThrowStmt(atLoc, move(Res), CurScope); } diff --git a/test/SemaObjC/invalid-code.m b/test/SemaObjC/invalid-code.m index 2f297cf6e6..7a642fb107 100644 --- a/test/SemaObjC/invalid-code.m +++ b/test/SemaObjC/invalid-code.m @@ -12,3 +12,10 @@ void test1() { __PRETTY_FUNCTION__; // expected-warning{{expression result unused}} } @end + +// +// This previously triggered a crash because a ';' was expected after the @throw statement. +void foo() { + @throw (id)0 // expected-error{{expected ';' after @throw}} +} +