[PATCH] Lex: Don't lex after getting EOF when handling _Pragma
David Majnemer
david.majnemer at gmail.com
Thu Aug 14 13:49:21 PDT 2014
Hi rsmith,
The error recovery path in _Pragma attempted to lex past the non-string
literal token and then lex past a closing right paren if it exists.
However, this path wasn't careful in the face of EOF.
This fixes PR20662.
http://reviews.llvm.org/D4914
Files:
lib/Lex/Pragma.cpp
test/Preprocessor/_Pragma.c
Index: lib/Lex/Pragma.cpp
===================================================================
--- lib/Lex/Pragma.cpp
+++ lib/Lex/Pragma.cpp
@@ -193,7 +193,7 @@
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::eof) && Tok.isNot(tok::r_paren))
Lex(Tok);
if (Tok.is(tok::r_paren))
Lex(Tok);
Index: test/Preprocessor/_Pragma.c
===================================================================
--- test/Preprocessor/_Pragma.c
+++ test/Preprocessor/_Pragma.c
@@ -11,3 +11,5 @@
#ifdef macro
#error #define invalid
#endif
+
+_Pragma( // expected-error {{_Pragma takes a parenthesized string literal}}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4914.12525.patch
Type: text/x-patch
Size: 774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140814/b50a38ae/attachment.bin>
More information about the cfe-commits
mailing list