From c7c9ab794792efe47c5f326421b8ff259a46a65d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 9 Jan 2009 04:34:13 +0000 Subject: Fix rdar://6480479 - [parser] infinite loop on invalid input llvm-svn: 61975 --- clang/lib/Parse/ParseObjc.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'clang/lib/Parse/ParseObjc.cpp') diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp index f52ecfb7fb1..90a14949667 100644 --- a/clang/lib/Parse/ParseObjc.cpp +++ b/clang/lib/Parse/ParseObjc.cpp @@ -255,6 +255,12 @@ void Parser::ParseObjCInterfaceDeclList(DeclTy *interfaceDecl, // If we don't have an @ directive, parse it as a function definition. if (Tok.isNot(tok::at)) { + // The code below does not consume '}'s because it is afraid of eating the + // end of a namespace. Because of the way this code is structured, an + // erroneous r_brace would cause an infinite loop if not handled here. + if (Tok.is(tok::r_brace)) + break; + // FIXME: as the name implies, this rule allows function definitions. // We could pass a flag or check for functions during semantic analysis. ParseDeclarationOrFunctionDefinition(); -- cgit v1.2.3