[cfe-commits] r61975 - in /cfe/trunk: lib/Parse/ParseObjc.cpp test/Parser/objc-quirks.m
Chris Lattner
sabre at nondot.org
Thu Jan 8 20:34:14 PST 2009
Author: lattner
Date: Thu Jan 8 22:34:13 2009
New Revision: 61975
URL: http://llvm.org/viewvc/llvm-project?rev=61975&view=rev
Log:
Fix rdar://6480479 - [parser] infinite loop on invalid input
Modified:
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/test/Parser/objc-quirks.m
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=61975&r1=61974&r2=61975&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Jan 8 22:34:13 2009
@@ -255,6 +255,12 @@
// 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();
Modified: cfe/trunk/test/Parser/objc-quirks.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-quirks.m?rev=61975&r1=61974&r2=61975&view=diff
==============================================================================
--- cfe/trunk/test/Parser/objc-quirks.m (original)
+++ cfe/trunk/test/Parser/objc-quirks.m Thu Jan 8 22:34:13 2009
@@ -2,3 +2,9 @@
// FIXME: This is a horrible error message here. Fix.
int @"s" = 5; // expected-error {{prefix attribute must be}}
+
+
+// rdar://6480479
+ at interface A
+}; // expected-error {{missing @end}} expected-error {{expected external declaration}}
+
More information about the cfe-commits
mailing list