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}}
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}}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits