]> granicus.if.org Git - clang/commitdiff
Don't Lex past EOF when lexing _Pragma
authorReid Kleckner <reid@kleckner.net>
Thu, 14 Aug 2014 19:47:06 +0000 (19:47 +0000)
committerReid Kleckner <reid@kleckner.net>
Thu, 14 Aug 2014 19:47:06 +0000 (19:47 +0000)
Fixes PR20662.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215672 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/Pragma.cpp
test/Preprocessor/_Pragma.c

index 356ab2bc9b31b05fe9765296425c2685d90d5272..af65bbfc9b19fa60f22b46a88c4feecfa1d4a4e5 100644 (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);
index 15725a422299fe2caf0993fa3192b99ef86ba00d..120e754cb986831425fc22087a835b23d134fd49 100644 (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}}