]> granicus.if.org Git - clang/commitdiff
Fix rdar://6480479 - [parser] infinite loop on invalid input
authorChris Lattner <sabre@nondot.org>
Fri, 9 Jan 2009 04:34:13 +0000 (04:34 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 9 Jan 2009 04:34:13 +0000 (04:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61975 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseObjc.cpp
test/Parser/objc-quirks.m

index f52ecfb7fb127a7b19b86b728654398ed8a01076..90a14949667ad857115b0eff7ca3ac919dcd6229 100644 (file)
@@ -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();
index b726d9a8274fce10557c4f3aa766a8f46534beac..c5fe8bb1a1874604db9f14247bf582f457281933 100644 (file)
@@ -2,3 +2,9 @@
 
 // FIXME: This is a horrible error message here. Fix.
 int @"s" = 5;  // expected-error {{prefix attribute must be}}
+
+
+// rdar://6480479
+@interface A
+}; // expected-error {{missing @end}} expected-error {{expected external declaration}}
+