I've updated the patch to address the first case mentioned by Hubert. The 
behaviour with this patch will now be the same as the current trunk


http://reviews.llvm.org/D8308

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

Index: lib/Lex/Pragma.cpp
===================================================================
--- lib/Lex/Pragma.cpp
+++ lib/Lex/Pragma.cpp
@@ -190,9 +190,13 @@
   Lex(Tok);
   if (!tok::isStringLiteral(Tok.getKind())) {
     Diag(PragmaLoc, diag::err__Pragma_malformed);
-    // Skip this token, and the ')', if present.
+    // Skip bad tokens, and the ')', if present.
     if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eof))
       Lex(Tok);
+    while (Tok.isNot(tok::r_paren) &&
+           !Tok.isAtStartOfLine() &&
+           Tok.isNot(tok::eof))
+      Lex(Tok);
     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,8 @@
 #error #define invalid
 #endif
 
+_Pragma(unroll 1 // expected-error{{_Pragma takes a parenthesized string 
literal}}
+
+_Pragma(clang diagnostic push) // expected-error{{_Pragma takes a 
parenthesized string literal}}
+
 _Pragma( // expected-error{{_Pragma takes a parenthesized string literal}}

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: lib/Lex/Pragma.cpp
===================================================================
--- lib/Lex/Pragma.cpp
+++ lib/Lex/Pragma.cpp
@@ -190,9 +190,13 @@
   Lex(Tok);
   if (!tok::isStringLiteral(Tok.getKind())) {
     Diag(PragmaLoc, diag::err__Pragma_malformed);
-    // Skip this token, and the ')', if present.
+    // Skip bad tokens, and the ')', if present.
     if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eof))
       Lex(Tok);
+    while (Tok.isNot(tok::r_paren) &&
+           !Tok.isAtStartOfLine() &&
+           Tok.isNot(tok::eof))
+      Lex(Tok);
     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,8 @@
 #error #define invalid
 #endif
 
+_Pragma(unroll 1 // expected-error{{_Pragma takes a parenthesized string literal}}
+
+_Pragma(clang diagnostic push) // expected-error{{_Pragma takes a parenthesized string literal}}
+
 _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