From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 88485 invoked by alias); 14 Aug 2015 13:14:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 88476 invoked by uid 89); 14 Aug 2015 13:14:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ig0-f177.google.com Received: from mail-ig0-f177.google.com (HELO mail-ig0-f177.google.com) (209.85.213.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 14 Aug 2015 13:14:12 +0000 Received: by igfj19 with SMTP id j19so12049942igf.0 for ; Fri, 14 Aug 2015 06:14:10 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.87.74 with SMTP id v10mr2642407igz.37.1439558050235; Fri, 14 Aug 2015 06:14:10 -0700 (PDT) Received: by 10.107.32.140 with HTTP; Fri, 14 Aug 2015 06:14:10 -0700 (PDT) In-Reply-To: <20150814112006.GR3335@redhat.com> References: <20150814112006.GR3335@redhat.com> Date: Fri, 14 Aug 2015 13:19:00 -0000 Message-ID: Subject: Re: [PATCH] Fix middle-end/67133, part 1 From: Richard Biener To: Marek Polacek Cc: GCC Patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00785.txt.bz2 On Fri, Aug 14, 2015 at 1:20 PM, Marek Polacek 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 > > 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 struct I : B {}; > +class C { > +public: > + C(char *); > + int size(); > +}; > +template struct D; > +template > class F { > + class G { > + template 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 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