]> granicus.if.org Git - clang/commitdiff
Don't consume tokens past the end-of-file in an @interface. Fixes
authorDouglas Gregor <dgregor@apple.com>
Tue, 16 Mar 2010 06:04:47 +0000 (06:04 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 16 Mar 2010 06:04:47 +0000 (06:04 +0000)
<rdar://problem/7735566>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98613 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticParseKinds.td
lib/Frontend/CompilerInstance.cpp
lib/Parse/ParseObjc.cpp
test/Parser/missing-end.m [new file with mode: 0644]

index 80a4eaee11208de5758ccddb71b6c365ab863e0d..9d001d48cc2a222ad363632673f8991768ad707f 100644 (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">;
index c43118ce56b02e257d939a8f315015da9fc653f9..3bc566192965115cd8006cef2bbd0cf02a382332 100644 (file)
@@ -294,6 +294,8 @@ void CompilerInstance::createCodeCompletionConsumer() {
                                  getFrontendOpts().DebugCodeCompletionPrinter,
                                  getFrontendOpts().ShowMacrosInCodeCompletion,
                                  llvm::outs()));
+  if (!CompletionConsumer)
+    return;
 
   if (CompletionConsumer->isOutputBinary() &&
       llvm::sys::Program::ChangeStdoutToBinary()) {
index 7ab0e71dc2356639db1b3294a134a9ac93c150b7..7b2b6e855bb73fec49931f812c4d4c1c4ba9c54d 100644 (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.
diff --git a/test/Parser/missing-end.m b/test/Parser/missing-end.m
new file mode 100644 (file)
index 0000000..fb26461
--- /dev/null
@@ -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}}