Manuel López-Ibáñez <lopeziba...@gmail.com> writes:

> On 25 September 2015 at 17:14, Dodji Seketeli <do...@redhat.com> wrote:
>> The caller of do_pragma(), which is destringize_and_run() then detects
>> that pfile->directive_result.type is set, and then puts the tokens of
>> the pragma back into the input stream again.  So next time the FE
>> requests more tokens, it's going to get the same pragma tokens.
>>
>> So, maybe you could alter pragma_entry::is_deferred; change it into a
>> flag which type is an enum that says how the the pragma is to be
>> handled; either internally and its tokens shouldn't be visible to the FE
>> (this is what the current pragma_entry::is_internal means), internally
>> and the tokens would be visible to the FE, or deferred.
>>
>> Then do do_pragma() would be adjusted to change the if (p->is_deferred)
>> clause to allow the third handling kind I just talked about.

[...]

> behaving as if the pragma was unknown did work:
>
> @@ -1414,11 +1435,11 @@ do_pragma (cpp_reader *pfile)
>         }
>      }
>
>    if (p)
>      {
> -      if (p->is_deferred)
> +      if (p->type == DEFERRED)
>         {
>           pfile->directive_result.src_loc = pragma_token_virt_loc;
>           pfile->directive_result.type = CPP_PRAGMA;
>           pfile->directive_result.flags = pragma_token->flags;
>           pfile->directive_result.val.pragma = p->u.ident;
> @@ -1439,11 +1460,12 @@ do_pragma (cpp_reader *pfile)
>           (*p->u.handler) (pfile);
>           if (p->allow_expansion)
>             pfile->state.prevent_expansion++;
>         }
>      }
> -  else if (pfile->cb.def_pragma)
> +
> +  if ((!p || p->type == INTERNAL_VISIBLE) && pfile->cb.def_pragma)
>      {
>        if (count == 1 || pfile->context->prev == NULL)
>         _cpp_backup_tokens (pfile, count);
>        else
>         {
>
> Yet, there is another problem. Now the FE sees the pragma and it warns
> with -Wunknown-pragma.

Couldn't we change the FE to make it not warn on pragma entries of type
INTERNAL_VISIBLE?

Thank you for looking into this.

-- 
                Dodji

Reply via email to