public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Manuel López-Ibáñez" <lopezibanez@gmail.com>
To: Dodji Seketeli <dodji@redhat.com>
Cc: Gcc Patch List <gcc-patches@gcc.gnu.org>,
	"Joseph S. Myers" <joseph@codesourcery.com>,
		Jason Merrill <jason@redhat.com>,
	Marek Polacek <polacek@redhat.com>
Subject: Re: [RFC PATCH] parse #pragma GCC diagnostic in libcpp
Date: Sun, 27 Sep 2015 12:03:00 -0000	[thread overview]
Message-ID: <CAESRpQCuwhdGL8Jb62EsPT9VHxSAzfedOCNRYO=ZSB9TxFU0kg@mail.gmail.com> (raw)
In-Reply-To: <86fv22msyc.fsf@redhat.com>

On 25 September 2015 at 17:14, Dodji Seketeli <dodji@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.

I could not make it work by touching directive_result.type. However,
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. But if we register the pragma in the FE to
ignore it, then we get

cc1plus: internal compiler error: #pragma GCC diagnostic is already registered

Cheers,

Manuel.

  reply	other threads:[~2015-09-26 22:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-29  4:43 Manuel López-Ibáñez
2015-08-21 17:44 ` Manuel López-Ibáñez
2015-09-20 18:23   ` Manuel López-Ibáñez
2015-09-23 23:43     ` Joseph Myers
2015-09-25 15:58 ` Dodji Seketeli
2015-09-27 12:03   ` Manuel López-Ibáñez [this message]
2015-09-27 14:45     ` Dodji Seketeli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAESRpQCuwhdGL8Jb62EsPT9VHxSAzfedOCNRYO=ZSB9TxFU0kg@mail.gmail.com' \
    --to=lopezibanez@gmail.com \
    --cc=dodji@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=polacek@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).