[PATCH] Improved error recovery for _Pragma
Rachel Craik
rcraik at ca.ibm.com
Fri Mar 13 19:29:16 PDT 2015
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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8308.21979.patch
Type: text/x-patch
Size: 1138 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150314/346ae6c6/attachment.bin>
More information about the cfe-commits
mailing list