public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Roger Sayle <roger@nextmovesoftware.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] PR c/104506: Tolerate error_mark_node in useless_type_conversion_p.
Date: Fri, 18 Feb 2022 13:41:00 -0800	[thread overview]
Message-ID: <CA+=Sn1kz+uB4P0C6Z37Af=fFckdZo-Nf3XqmW2dOtEVAMHkCkg@mail.gmail.com> (raw)
In-Reply-To: <CA+=Sn1=AgJ4hLX0gG_3DKbqF85nzgwsiKFuZEVFRUcSBt1Rbew@mail.gmail.com>

On Mon, Feb 14, 2022 at 11:39 PM Andrew Pinski <pinskia@gmail.com> wrote:
>
> On Mon, Feb 14, 2022 at 11:33 PM Richard Biener
> <richard.guenther@gmail.com> wrote:
> >
> > On Tue, Feb 15, 2022 at 12:58 AM Andrew Pinski via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> > >
> > > On Mon, Feb 14, 2022 at 4:54 AM Roger Sayle <roger@nextmovesoftware.com> wrote:
> > > >
> > > >
> > > >
> > > > This simple fix to the middle-end, resolves PR c/104506, by adding an
> > > >
> > > > explicit check for error_mark_node to useless_type_conversion_p.  I first
> > > >
> > > > trying fixing this in the C front-end, but the type is valid at the point
> > > >
> > > > that the NOP_EXPR is created, so the poisoned type leaks to the middle-end.
> > > >
> > > > Returning either true or false from useless_type_conversion_p avoids the
> > > >
> > > > ICE-after-error.  Apologies to Andrew Pinski, I hadn't noticed that he'd
> > > >
> > > > assigned this PR to himself until after my regression testing had finished.
> > > >
> > > >
> > > >
> > > > This patch has been tested on x86_64-pc-linux-gnu with make bootstrap and
> > > >
> > > > make -k check with no new failures.  Ok for mainline?
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > 2022-02-14  Roger Sayle  <roger@nextmovesoftware.com>
> > > >
> > > >
> > > >
> > > > gcc/ChangeLog
> > > >
> > > > PR c/104506
> > > >
> > > > * gimple-expr.cc (useless_type_conversion_p): Add a check for
> > > >
> > > > error_mark_node.
> > >
> > > I came up with a different patch (attached) which just changes
> > > tree_ssa_useless_type_conversion rather than useless_type_conversion_p
> > > which I was going to submit but had an issue with my build machine.
> > > I did it this way as it was similar to how
> > > STRIP_NOPS/tree_nop_conversion was done already.
> > >
> > > Also from my description of the patch
> > >     STRIP_USELESS_TYPE_CONVERSION is mostly used inside the gimplifier
> > >     and the places where it is used outside of the gimplifier would not
> > >     be adding too much overhead.
> > >
> > > Though I think Richard Biener's patch is better really. It would be
> > > interesting to see how the C++ front-end handles this case, I remember
> > > it using integer_type_node in some locations after an error for a
> > > type.
> >
> > If the fix to the C frontend doesn't work out I'd indeed prefer your variant.
> > Nit:
> >
> > +  outer_type = TREE_TYPE (expr);
> > +  inner_type = TREE_TYPE (TREE_OPERAND (expr, 0));
> > +
> > +  if (!inner_type || inner_type == error_mark_node)
> > +    return false;
> >
> > unless we get to a case where inner_type == NULL I would not bother
> > checking that.
>
> Understood, I will remove it, I was just copying exactly what was done
> in tree_nop_conversion really. The history on the null check seems to
> date to 2000 without any explanation really.

Finally submitted it as
https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590595.html

Thanks,
Andrew


>
> Thanks,
> Andrew Pinski
>
> >
> > As said, that TREE_TYPE (error_mark_node) is not a type is IMHO bad
> > for error recovery.  Maybe we really need ERROR_TYPE here.
> >
> > > Thanks,
> > > Andrew Pinski
> > >
> > > >
> > > >
> > > >
> > > > gcc/testsuite/ChangeLog
> > > >
> > > > PR c/104506
> > > >
> > > > * gcc.dg/pr104506.c: New test case.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Roger
> > > >
> > > > --
> > > >
> > > >

      reply	other threads:[~2022-02-18 21:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-14 12:54 Roger Sayle
2022-02-14 15:31 ` Richard Biener
2022-02-14 15:34   ` Richard Biener
2022-02-14 23:57 ` Andrew Pinski
2022-02-15  7:32   ` Richard Biener
2022-02-15  7:39     ` Andrew Pinski
2022-02-18 21:41       ` Andrew Pinski [this message]

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='CA+=Sn1kz+uB4P0C6Z37Af=fFckdZo-Nf3XqmW2dOtEVAMHkCkg@mail.gmail.com' \
    --to=pinskia@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    --cc=roger@nextmovesoftware.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).