Don't consume tokens past the end-of-file in an @interface. Fixes

<rdar://problem/7735566>.

llvm-svn: 98613
This commit is contained in:
Douglas Gregor 2010-03-16 06:04:47 +00:00
parent 7d83d9b23c
commit 00a0cf70d9
4 changed files with 14 additions and 0 deletions

View File

@ -183,6 +183,7 @@ def err_objc_no_attributes_on_category : Error<
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">;

View File

@ -294,6 +294,8 @@ void CompilerInstance::createCodeCompletionConsumer() {
getFrontendOpts().DebugCodeCompletionPrinter,
getFrontendOpts().ShowMacrosInCodeCompletion,
llvm::outs()));
if (!CompletionConsumer)
return;
if (CompletionConsumer->isOutputBinary() &&
llvm::sys::Program::ChangeStdoutToBinary()) {

View File

@ -375,6 +375,10 @@ void Parser::ParseObjCInterfaceDeclList(DeclPtrTy interfaceDecl,
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.

View File

@ -0,0 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
@interface AAA
{
}
@ x// expected-error{{expected an Objective-C directive after '@'}}
// expected-error{{missing @end}}