From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100986 invoked by alias); 7 Oct 2016 08:45:29 -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 100928 invoked by uid 89); 7 Oct 2016 08:45:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=nuts X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Oct 2016 08:45:23 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CC0DE60C7 for ; Fri, 7 Oct 2016 08:45:21 +0000 (UTC) Received: from redhat.com (ovpn-204-132.brq.redhat.com [10.40.204.132]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u978jJ4o000766 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Fri, 7 Oct 2016 04:45:21 -0400 Date: Fri, 07 Oct 2016 08:45:00 -0000 From: Marek Polacek To: GCC Patches Subject: Re: PATCH to fix bogus -Wimplicit-fallthrough warning (PR c++/77803) Message-ID: <20161007084518.GC3223@redhat.com> References: <20160930213150.GH3223@redhat.com> <20161001051750.GA308@x4> <20161001141721.GK3223@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161001141721.GK3223@redhat.com> User-Agent: Mutt/1.7.0 (2016-08-17) X-SW-Source: 2016-10/txt/msg00458.txt.bz2 Ping. On Sat, Oct 01, 2016 at 04:17:22PM +0200, Marek Polacek wrote: > On Sat, Oct 01, 2016 at 07:17:50AM +0200, Markus Trippelsdorf wrote: > > On 2016.09.30 at 23:31 +0200, Marek Polacek wrote: > > > This PR reports a bogus -Wimplicit-fallthrough warning on the attached test. > > > The problem is that last_stmt_in_scope should for GIMPLE_TRY, if the last > > > statement of the eval part can't fallthrough, return this statement and don't > > > warn. And the same should be true for FALLTHROUGH (). This patch fixes it. > > > > > > Bootstrapped/regtested on x86_64-linux, ok for trunk? > > > > Try to compile the testcase without the fallthrough attribute... > > Nuts. Forgot that gimple_call_internal_p doesn't handle NULL. > > Bootstrapped/regtested on x86_64-linux and ppc64-linux, ok for trunk? > > 2016-10-01 Marek Polacek > > PR c++/77803 > * gimplify.c (last_stmt_in_scope): Add check for FALLTHROUGH (). > > * g++.dg/warn/Wimplicit-fallthrough-1.C: New test. > > diff --git gcc/gimplify.c gcc/gimplify.c > index 66bb8be..a60d947 100644 > --- gcc/gimplify.c > +++ gcc/gimplify.c > @@ -1687,6 +1687,8 @@ last_stmt_in_scope (gimple *stmt) > stmt = gimple_seq_last_stmt (gimple_try_eval (try_stmt)); > gimple *last_eval = last_stmt_in_scope (stmt); > if (gimple_stmt_may_fallthru (last_eval) > + && (last_eval == NULL > + || !gimple_call_internal_p (last_eval, IFN_FALLTHROUGH)) > && gimple_try_kind (try_stmt) == GIMPLE_TRY_FINALLY) > { > stmt = gimple_seq_last_stmt (gimple_try_cleanup (try_stmt)); > diff --git gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-1.C gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-1.C > index e69de29..053ed68 100644 > --- gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-1.C > +++ gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-1.C > @@ -0,0 +1,33 @@ > +// PR c++/77803 > +// { dg-do compile { target c++11 } } > +// { dg-options "-Wimplicit-fallthrough" } > + > +struct A {}; > +int a; > + > +void > +fn1 () > +{ > + switch (0) { > + case 0: > + { > + A b; > + [[fallthrough]]; > + } > + default: > + a = 0; > + } > +} > + > +void > +fn2 () > +{ > + switch (0) { > + case 0: > + { > + A b; // { dg-warning "statement may fall through" } > + } > + default: > + a = 0; > + } > +} > > Marek Marek