public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Marek Polacek <polacek@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fix middle-end/67133, part 1
Date: Fri, 14 Aug 2015 13:19:00 -0000	[thread overview]
Message-ID: <CAFiYyc2P_d=h=QHGjoDi0uONLFbe3gmKPvcDcABwOsvSBHuZyw@mail.gmail.com> (raw)
In-Reply-To: <20150814112006.GR3335@redhat.com>

On Fri, Aug 14, 2015 at 1:20 PM, Marek Polacek <polacek@redhat.com> wrote:
> As outlined in the PR, this fixes one ICE.  The code in question here
> tries to determine whether OP can be derived as non-NULL.  In case the
> function has the nonnull attribute that applies to all the arguments,
> we want to see whether OP is in this argument list.  But nonnull only
> appertains to pointers.  Some ssa_names don't have a type so check for
> that first instead of segv before looking at its tree code.

Huh?  All but released SSA names have a type.  So this gets invoked on dead code
somehow?

RIchard.

>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2015-08-14  Marek Polacek  <polacek@redhat.com>
>
>         PR middle-end/67133
>         * gimple.c (infer_nonnull_range_by_attribute): Handle null TREE_TYPE.
>
>         * g++.dg/torture/pr67133.C: New test.
>
> diff --git gcc/gimple.c gcc/gimple.c
> index cca328a..1482eb4 100644
> --- gcc/gimple.c
> +++ gcc/gimple.c
> @@ -2678,14 +2678,16 @@ infer_nonnull_range_by_attribute (gimple stmt, tree op)
>           if (attrs == NULL_TREE)
>             return false;
>
> -         /* If "nonnull" applies to all the arguments, then ARG
> +         /* If "nonnull" applies to all the arguments, then OP
>              is non-null if it's in the argument list.  */
>           if (TREE_VALUE (attrs) == NULL_TREE)
>             {
>               for (unsigned int i = 0; i < gimple_call_num_args (stmt); i++)
>                 {
> -                 if (POINTER_TYPE_P (TREE_TYPE (gimple_call_arg (stmt, i)))
> -                     && operand_equal_p (op, gimple_call_arg (stmt, i), 0))
> +                 tree arg = gimple_call_arg (stmt, i);
> +                 if (TREE_TYPE (arg) != NULL_TREE
> +                     && POINTER_TYPE_P (TREE_TYPE (arg))
> +                     && operand_equal_p (op, arg, 0))
>                     return true;
>                 }
>               return false;
> diff --git gcc/testsuite/g++.dg/torture/pr67133.C gcc/testsuite/g++.dg/torture/pr67133.C
> index e69de29..0f23572 100644
> --- gcc/testsuite/g++.dg/torture/pr67133.C
> +++ gcc/testsuite/g++.dg/torture/pr67133.C
> @@ -0,0 +1,46 @@
> +// { dg-do compile }
> +// { dg-additional-options "-fisolate-erroneous-paths-attribute" }
> +
> +class A;
> +struct B {
> +  typedef A type;
> +};
> +template <typename> struct I : B {};
> +class C {
> +public:
> +  C(char *);
> +  int size();
> +};
> +template <typename> struct D;
> +template <typename _Tp, typename = D<_Tp>> class F {
> +  class G {
> +    template <typename> static _Tp *__test();
> +    typedef int _Del;
> +
> +  public:
> +    typedef decltype(__test<_Del>()) type;
> +  };
> +
> +public:
> +  typename I<_Tp>::type operator*() {
> +    typename G::type a = 0;
> +    return *a;
> +  }
> +};
> +class H {
> +  F<A> Out;
> +  H();
> +};
> +void fn1(void *, void *, int) __attribute__((__nonnull__));
> +class A {
> +  int OutBufEnd, OutBufCur;
> +
> +public:
> +  void operator<<(C p1) {
> +    int b, c = p1.size();
> +    if (OutBufEnd)
> +      fn1(&OutBufCur, &b, c);
> +  }
> +};
> +char* a;
> +H::H() { *Out << a; }
>
>         Marek

  reply	other threads:[~2015-08-14 13:14 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-14 11:51 Marek Polacek
2015-08-14 13:19 ` Richard Biener [this message]
2015-08-14 13:36   ` Marek Polacek
2015-08-14 14:54     ` Jeff Law
2015-08-14 15:33       ` Marek Polacek
2015-08-14 15:39         ` Jeff Law
2015-08-14 20:12           ` Marek Polacek
2015-08-14 20:36             ` Jeff Law
2015-08-14 21:48               ` Marek Polacek
2015-08-17 17:47                 ` Jeff Law
2015-08-17 18:01                   ` Marek Polacek
2015-08-18  8:47                   ` Richard Biener
2015-08-18 20:09                     ` Marek Polacek
2015-08-19  9:54                       ` Richard Biener
2015-08-19 10:39                         ` Marek Polacek
2015-08-19 14:25                       ` Jeff Law
2015-08-20  9:05                       ` Andreas Schwab
2015-08-20 10:50                         ` Marek Polacek
2015-08-20 10:58                           ` Andreas Schwab
2015-08-20 16:42                           ` Jeff Law
2015-08-20 16:59                             ` Marek Polacek
2015-08-20 16:59                               ` Jeff Law
2015-08-20 17:02                               ` Marek Polacek
2015-08-20 17:11                                 ` Jeff Law
2015-08-23 10:54                         ` Jan-Benedict Glaw
2015-08-24 15:55                           ` Jeff Law
2015-08-24 16:15                             ` Marek Polacek

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='CAFiYyc2P_d=h=QHGjoDi0uONLFbe3gmKPvcDcABwOsvSBHuZyw@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --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).