r207883 - Fix PR 19630, don't crash when file ends with whitespace.
Richard Trieu
rtrieu at google.com
Fri May 2 16:40:33 PDT 2014
Author: rtrieu
Date: Fri May 2 18:40:32 2014
New Revision: 207883
URL: http://llvm.org/viewvc/llvm-project?rev=207883&view=rev
Log:
Fix PR 19630, don't crash when file ends with whitespace.
Added:
cfe/trunk/test/Parser/eof.cpp
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=207883&r1=207882&r2=207883&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri May 2 18:40:32 2014
@@ -4834,7 +4834,8 @@ void Parser::ParseDirectDeclarator(Decla
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);
Added: cfe/trunk/test/Parser/eof.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/eof.cpp?rev=207883&view=auto
==============================================================================
--- cfe/trunk/test/Parser/eof.cpp (added)
+++ cfe/trunk/test/Parser/eof.cpp Fri May 2 18:40:32 2014
@@ -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
More information about the cfe-commits
mailing list