diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp --- a/clang/lib/Parse/ParseObjc.cpp +++ b/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: diff --git a/clang/test/Parser/gh64065-nocrash.m b/clang/test/Parser/gh64065-nocrash.m new file mode 100644 --- /dev/null +++ b/clang/test/Parser/gh64065-nocrash.m @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// expected-error@+4 {{missing '@end'}} +// expected-note@+3 {{class started here}} +// expected-error@+2 {{missing '@end'}} +// expected-note@+1 {{class started here}} +@interface Roo@interface