Hi rsmith,

It's not particularly safe to lex a token if you don't know what it is.
_Pragma error recovery attempted to lex tokens without being sure what
they might be.

http://reviews.llvm.org/D4939

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

Index: lib/Lex/Pragma.cpp
===================================================================
--- lib/Lex/Pragma.cpp
+++ lib/Lex/Pragma.cpp
@@ -192,9 +192,7 @@
   Lex(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) && Tok.isNot(tok::eof))
-      Lex(Tok);
+    // Skip this token if it's a ')'.
     if (Tok.is(tok::r_paren))
       Lex(Tok);
     return _PragmaLexing.failed();
Index: test/Preprocessor/_Pragma.c
===================================================================
--- test/Preprocessor/_Pragma.c
+++ test/Preprocessor/_Pragma.c
@@ -12,4 +12,6 @@
 #error #define invalid
 #endif
 
-_Pragma( // expected-error{{_Pragma takes a parenthesized string literal}}
+// expected-error@+2{{unterminated conditional directive}}
+// expected-error@+1{{expected value in expression}}
+#if _Pragma( // expected-error{{_Pragma takes a parenthesized string literal}}
Index: lib/Lex/Pragma.cpp
===================================================================
--- lib/Lex/Pragma.cpp
+++ lib/Lex/Pragma.cpp
@@ -192,9 +192,7 @@
   Lex(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) && Tok.isNot(tok::eof))
-      Lex(Tok);
+    // Skip this token if it's a ')'.
     if (Tok.is(tok::r_paren))
       Lex(Tok);
     return _PragmaLexing.failed();
Index: test/Preprocessor/_Pragma.c
===================================================================
--- test/Preprocessor/_Pragma.c
+++ test/Preprocessor/_Pragma.c
@@ -12,4 +12,6 @@
 #error #define invalid
 #endif
 
-_Pragma( // expected-error{{_Pragma takes a parenthesized string literal}}
+// expected-error@+2{{unterminated conditional directive}}
+// expected-error@+1{{expected value in expression}}
+#if _Pragma( // expected-error{{_Pragma takes a parenthesized string literal}}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to