[cfe-commits] r98613 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Frontend/CompilerInstance.cpp lib/Parse/ParseObjc.cpp test/Parser/missing-end.m
Douglas Gregor
dgregor at apple.com
Mon Mar 15 23:04:47 PDT 2010
Author: dgregor
Date: Tue Mar 16 01:04:47 2010
New Revision: 98613
URL: http://llvm.org/viewvc/llvm-project?rev=98613&view=rev
Log:
Don't consume tokens past the end-of-file in an @interface. Fixes
<rdar://problem/7735566>.
Added:
cfe/trunk/test/Parser/missing-end.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Parse/ParseObjc.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=98613&r1=98612&r2=98613&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Tue Mar 16 01:04:47 2010
@@ -183,6 +183,7 @@
def err_objc_missing_end : Error<"missing @end">;
def warn_objc_protocol_qualifier_missing_id : Warning<
"protocol qualifiers without 'id' is archaic">;
+def err_objc_unknown_at : Error<"expected an Objective-C directive after '@'">;
def err_objc_illegal_visibility_spec : Error<
"illegal visibility specification">;
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=98613&r1=98612&r2=98613&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue Mar 16 01:04:47 2010
@@ -294,6 +294,8 @@
getFrontendOpts().DebugCodeCompletionPrinter,
getFrontendOpts().ShowMacrosInCodeCompletion,
llvm::outs()));
+ if (!CompletionConsumer)
+ return;
if (CompletionConsumer->isOutputBinary() &&
llvm::sys::Program::ChangeStdoutToBinary()) {
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=98613&r1=98612&r2=98613&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue Mar 16 01:04:47 2010
@@ -375,6 +375,10 @@
AtEnd.setBegin(AtLoc);
AtEnd.setEnd(Tok.getLocation());
break;
+ } else if (DirectiveKind == tok::objc_not_keyword) {
+ Diag(Tok, diag::err_objc_unknown_at);
+ SkipUntil(tok::semi);
+ continue;
}
// Eat the identifier.
Added: cfe/trunk/test/Parser/missing-end.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/missing-end.m?rev=98613&view=auto
==============================================================================
--- cfe/trunk/test/Parser/missing-end.m (added)
+++ cfe/trunk/test/Parser/missing-end.m Tue Mar 16 01:04:47 2010
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+ at interface AAA
+{
+}
+@ x// expected-error{{expected an Objective-C directive after '@'}}
+// expected-error{{missing @end}}
More information about the cfe-commits
mailing list