diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-09 04:34:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-09 04:34:13 +0000 |
commit | c7c9ab794792efe47c5f326421b8ff259a46a65d (patch) | |
tree | 8b077444160f1fcf6c7f1f67071d2c69aff9950a | |
parent | cc1b6e8fce4ac53dc78ed09a4a141e7d50767347 (diff) | |
download | bcm5719-llvm-c7c9ab794792efe47c5f326421b8ff259a46a65d.tar.gz bcm5719-llvm-c7c9ab794792efe47c5f326421b8ff259a46a65d.zip |
Fix rdar://6480479 - [parser] infinite loop on invalid input
llvm-svn: 61975
-rw-r--r-- | clang/lib/Parse/ParseObjc.cpp | 6 | ||||
-rw-r--r-- | clang/test/Parser/objc-quirks.m | 6 |
2 files changed, 12 insertions, 0 deletions
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(); diff --git a/clang/test/Parser/objc-quirks.m b/clang/test/Parser/objc-quirks.m index b726d9a8274..c5fe8bb1a18 100644 --- a/clang/test/Parser/objc-quirks.m +++ b/clang/test/Parser/objc-quirks.m @@ -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}} + |