]> granicus.if.org Git - clang/commitdiff
Fix <rdar://problem/6764172> [sema] crash on invalid.
authorSteve Naroff <snaroff@apple.com>
Tue, 7 Apr 2009 22:56:58 +0000 (22:56 +0000)
committerSteve Naroff <snaroff@apple.com>
Tue, 7 Apr 2009 22:56:58 +0000 (22:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68568 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseObjc.cpp
test/SemaObjC/exception-go-boom.m [new file with mode: 0644]

index 05c919cbea993a389c5f553e0c91ee1d602ad2fb..8a942c77027a08727e99a90daac0b2d1ece7b9e2 100644 (file)
@@ -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 (file)
index 0000000..32dc82d
--- /dev/null
@@ -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}}
+  }
+}
+