[PATCH] D156277: [Parser][ObjC] Stop parsing on eof

Ding Fei via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 25 16:45:50 PDT 2023


danix800 created this revision.
danix800 added a project: clang.
Herald added a project: All.
danix800 requested review of this revision.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/64065


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156277

Files:
  clang/lib/Parse/ParseObjc.cpp
  clang/test/Parser/gh64065-nocrash.m


Index: clang/test/Parser/gh64065-nocrash.m
===================================================================
--- /dev/null
+++ clang/test/Parser/gh64065-nocrash.m
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// expected-error at +4 {{missing '@end'}}
+// expected-note at +3 {{class started here}}
+// expected-error at +2 {{missing '@end'}}
+// expected-note at +1 {{class started here}}
+ at interface Roo at interface
Index: clang/lib/Parse/ParseObjc.cpp
===================================================================
--- clang/lib/Parse/ParseObjc.cpp
+++ clang/lib/Parse/ParseObjc.cpp
@@ -745,7 +745,8 @@
           << FixItHint::CreateInsertion(AtLoc, "@end\n");
       Diag(CDecl->getBeginLoc(), diag::note_objc_container_start)
           << (int)Actions.getObjCContainerKind();
-      ConsumeToken();
+      if (!Tok.is(tok::eof))
+        ConsumeToken();
       break;
 
     case tok::objc_required:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156277.543985.patch
Type: text/x-patch
Size: 918 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230725/1cc59ef7/attachment-0001.bin>


More information about the cfe-commits mailing list