From 8ca595775fd652428a172c438bebc7580b5125ed Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Thu, 14 Aug 2014 19:47:06 +0000 Subject: [PATCH] Don't Lex past EOF when lexing _Pragma Fixes PR20662. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215672 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Lex/Pragma.cpp | 2 +- test/Preprocessor/_Pragma.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp index 356ab2bc9b..af65bbfc9b 100644 --- a/lib/Lex/Pragma.cpp +++ b/lib/Lex/Pragma.cpp @@ -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); diff --git a/test/Preprocessor/_Pragma.c b/test/Preprocessor/_Pragma.c index 15725a4222..120e754cb9 100644 --- a/test/Preprocessor/_Pragma.c +++ b/test/Preprocessor/_Pragma.c @@ -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}} -- 2.40.0