Don't Lex past EOF when lexing _Pragma

Fixes PR20662.

llvm-svn: 215672
This commit is contained in:
Reid Kleckner 2014-08-14 19:47:06 +00:00
parent 4133b13bd2
commit 53e6a5d60c
2 changed files with 3 additions and 1 deletions

View File

@ -193,7 +193,7 @@ void Preprocessor::Handle_Pragma(Token &Tok) {
if (!tok::isStringLiteral(Tok.getKind())) {
Diag(PragmaLoc, diag::err__Pragma_malformed);
// Skip this token, and the ')', if present.
if (Tok.isNot(tok::r_paren))
if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eof))
Lex(Tok);
if (Tok.is(tok::r_paren))
Lex(Tok);

View File

@ -11,3 +11,5 @@ _Pragma("message(\"foo \\\\\\\\ bar\")") // expected-warning {{foo \\ bar}}
#ifdef macro
#error #define invalid
#endif
_Pragma( // expected-error{{_Pragma takes a parenthesized string literal}}