[cfe-commits] [PATCH] Disallow __has_include and __has_include_next outside of preprocessor directives

Aaron Ballman aaron at aaronballman.com
Tue Jan 15 15:49:25 PST 2013


1 & 2 -- I'll resolve; good catch.
3 -- if there's not a current lexer, we have no way to know we're
currently in a preprocessor directive (that I'm aware of).
4 -- I prefer not to move it up because the diagnostic uses LParenLoc;
I could use Tok.getLocation, but that wraps the Diag call.

~Aaron

On Tue, Jan 15, 2013 at 6:35 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> On Wed, Jan 16, 2013 at 1:12 AM, Aaron Ballman <aaron at aaronballman.com> wrote:
>> Yes, I prefer the way that looks -- new patch attached.  Note that it
>> does change another test in the test cases, but I think the change is
>> beneficial.
>
> +  // We only want to get the file name if we're currently within a
> +  // preprocessor directive.
> +  if (PP.getCurrentLexer() &&
> +      !PP.getCurrentLexer()->isParsingPreprocessorDirective()) {
>
> 1. Trailing whitespace.
>
> 2. The comment should say something like "These macros are only
> allowed in a PP directive."
>
> 3. What about the case when PP.getCurrentLexer() == 0?
>
> 4. You can move the check before LParenLoc is declared.
>
> Dmitri
>
> --
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-commits mailing list