From patchwork Fri May 27 11:52:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 627092 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rGPXR08VGz9sf9 for ; Fri, 27 May 2016 21:52:52 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=nVNpmClQ; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=I7NSd2SKTyaXP2TMMpH75dAvcJKuhj/9kgZpsWR7ZkuW9czOJ8/TK mMWiF6upGiIbmAFEnSZrPOC//6hfL8GrSkivNLh8X+A/L07i1Fp5mCWf85lWcUE1 AWLBmz9c3PhcXKIW6wfZNSVaIgSsPVWZY4T+dcaOQTo8OYdlLJZBSw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=bNyzZhPlLmT2F4ZlSpsRCu48Pt8=; b=nVNpmClQLjTpaNEJIX19 T3HBi0Pvo1+5IKZ3eDgBZ5WXvpTbdF/GLUztLmE65P2luEqVAL6tLP4aBV+QoLrC RP4KWzE2dP7ts+x9EWegRQ9r41fv52QpcEzjMCfDWEkx1mcMaVDMuKRwDbQI87pK e2Z8XBUYJEwft6W8C7NW2vo= Received: (qmail 103571 invoked by alias); 27 May 2016 11:52:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 103556 invoked by uid 89); 27 May 2016 11:52:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=2016-05-27 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 27 May 2016 11:52:39 +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 A0F1180F92 for ; Fri, 27 May 2016 11:52:37 +0000 (UTC) Received: from redhat.com (ovpn-204-26.brq.redhat.com [10.40.204.26]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4RBqYIW018513 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Fri, 27 May 2016 07:52:37 -0400 Date: Fri, 27 May 2016 13:52:34 +0200 From: Marek Polacek To: GCC Patches Subject: Fix middle-end/71308 Message-ID: <20160527115234.GF3014@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.1 (2016-04-27) A stupid mistake of mine. When I introduced the should_remove_lhs_p call, I removed the check for LHS here, because should_remove_lhs_p checks that. Well, in this case the LHS was NULL, but gimple_call_fntype (stmt) had void type, so we went on and crashed on the SSA_NAME check. Sorry. But at least we have a test exercising this path. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2016-05-27 Marek Polacek PR middle-end/71308 * gimple-fold.c (gimple_fold_call): Check that LHS is not null. * g++.dg/torture/pr71308.C: New test. Marek diff --git gcc/gimple-fold.c gcc/gimple-fold.c index d6657e9..600aa72 100644 --- gcc/gimple-fold.c +++ gcc/gimple-fold.c @@ -3053,7 +3053,8 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace) == void_type_node)) gimple_call_set_fntype (stmt, TREE_TYPE (fndecl)); /* If the call becomes noreturn, remove the lhs. */ - if (gimple_call_noreturn_p (stmt) + if (lhs + && gimple_call_noreturn_p (stmt) && (VOID_TYPE_P (TREE_TYPE (gimple_call_fntype (stmt))) || should_remove_lhs_p (lhs))) { diff --git gcc/testsuite/g++.dg/torture/pr71308.C gcc/testsuite/g++.dg/torture/pr71308.C index e69de29..ff5cd95 100644 --- gcc/testsuite/g++.dg/torture/pr71308.C +++ gcc/testsuite/g++.dg/torture/pr71308.C @@ -0,0 +1,18 @@ +// PR middle-end/71308 +// { dg-do compile } + +class S +{ + void foo (); + virtual void bar () = 0; + virtual ~S (); +}; +inline void +S::foo () +{ + bar (); +}; +S::~S () +{ + foo (); +}