r215672 - Don't Lex past EOF when lexing _Pragma

Richard Smith richard at metafoo.co.uk
Fri Aug 15 16:32:08 PDT 2014


On Thu, Aug 14, 2014 at 12:47 PM, Reid Kleckner <reid at kleckner.net> wrote:

> Author: rnk
> Date: Thu Aug 14 14:47:06 2014
> New Revision: 215672
>
> URL: http://llvm.org/viewvc/llvm-project?rev=215672&view=rev
> Log:
> Don't Lex past EOF when lexing _Pragma
>
> Fixes PR20662.
>
> Modified:
>     cfe/trunk/lib/Lex/Pragma.cpp
>     cfe/trunk/test/Preprocessor/_Pragma.c
>
> Modified: cfe/trunk/lib/Lex/Pragma.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=215672&r1=215671&r2=215672&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Lex/Pragma.cpp (original)
> +++ cfe/trunk/lib/Lex/Pragma.cpp Thu Aug 14 14:47:06 2014
> @@ -193,7 +193,7 @@ void Preprocessor::Handle_Pragma(Token &
>    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::r_paren) && Tok.isNot(tok::eof))
>

This should probably also stop at EOD and EOM (tok::eod,
tok::annot_module_*).


>        Lex(Tok);
>      if (Tok.is(tok::r_paren))
>        Lex(Tok);
>
> Modified: cfe/trunk/test/Preprocessor/_Pragma.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/_Pragma.c?rev=215672&r1=215671&r2=215672&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/Preprocessor/_Pragma.c (original)
> +++ cfe/trunk/test/Preprocessor/_Pragma.c Thu Aug 14 14:47:06 2014
> @@ -11,3 +11,5 @@ _Pragma("message(\"foo \\\\\\\\ bar\")")
>  #ifdef macro
>  #error #define invalid
>  #endif
> +
> +_Pragma( // expected-error{{_Pragma takes a parenthesized string literal}}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140815/151bc8a8/attachment.html>


More information about the cfe-commits mailing list