Fix PR 19630, don't crash when file ends with whitespace.

llvm-svn: 207883
This commit is contained in:
Richard Trieu 2014-05-02 23:40:32 +00:00
parent b2faa59976
commit a1342406f2
2 changed files with 15 additions and 1 deletions

View File

@ -4834,7 +4834,8 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
LLVM_BUILTIN_TRAP;
if (D.getContext() == Declarator::MemberContext)
Diag(Tok, diag::err_expected_member_name_or_semi)
<< D.getDeclSpec().getSourceRange();
<< (D.getDeclSpec().isEmpty() ? SourceRange()
: D.getDeclSpec().getSourceRange());
else if (getLangOpts().CPlusPlus) {
if (Tok.is(tok::period) || Tok.is(tok::arrow))
Diag(Tok, diag::err_invalid_operator_on_type) << Tok.is(tok::arrow);

13
clang/test/Parser/eof.cpp Normal file
View File

@ -0,0 +1,13 @@
// RUN: not %clang_cc1 %s -fsyntax-only 2>&1 | FileCheck %s
// CHECK: error: expected member name or ';' after declaration specifiers
// CHECK: error: expected '}'
// CHECK: note: to match this '{'
// CHECK: error: expected ';' after class
// CHECK: error: anonymous structs and classes must be class members
// CHECK: 4 errors generated.
// Do not add anything to the end of this file. This requires the whitespace
// plus EOF after the template keyword.
class { template