From patchwork Thu May 10 07:58:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 911306 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-477469-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="kniILLHi"; dkim-atps=neutral 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 40hQZf07zDz9s3q for ; Thu, 10 May 2018 17:58:17 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:cc:message-id:date:mime-version:content-type; q=dns; s=default; b=q1iRBLvNs3EfT15/8P8nRFf2xs2crdtkJcY8r2Stgq5frugnK0 /rqAkHfpalAizIgYRQTFTfn5USVedy12tnDAiZowGlwcOsEErBmgLExNXpVAleG/ m0FTkw0sw80UQASQpEmtwwJ825CMr4Lp7YBDgTGmluipy7p0TYknDLOUg= 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:from :subject:to:cc:message-id:date:mime-version:content-type; s= default; bh=dHC4iMaRok0CxALHUEKeAfSzor0=; b=kniILLHiCctRn9BbwFm/ aGQYMrj9yVUKVM6QnTo6aRqaPjPL0K4XVoT0iVnKNUiUMfVkQ9YbHABBdg8Q4YRY g717Sq0aSKv7YxlAzgxDw5lSbvMvZ0bHFd2iLxn14QJNQoKdEuXm7g+FKhOFhrMU UXu5c3Ac9MlfRzjciF3Wpj8= Received: (qmail 117903 invoked by alias); 10 May 2018 07:58:10 -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 117871 invoked by uid 89); 10 May 2018 07:58:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1712 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 May 2018 07:58:06 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0F123AD52; Thu, 10 May 2018 07:58:04 +0000 (UTC) From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] Do not ICE for incomplete types in ICF (PR ipa/85607). To: gcc-patches@gcc.gnu.org Cc: Jan Hubicka Message-ID: Date: Thu, 10 May 2018 09:58:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi. It's removal of an assert at place where we calculate hash of a type. For incomplete types, let's skip it. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Martin gcc/ChangeLog: 2018-05-09 Martin Liska PR ipa/85607 * ipa-icf.c (sem_item::add_type): Do not ICE for incomplete types. gcc/testsuite/ChangeLog: 2018-05-09 Martin Liska PR ipa/85607 * g++.dg/ipa/pr85606.C: New test. --- gcc/ipa-icf.c | 5 ++++- gcc/testsuite/g++.dg/ipa/pr85606.C | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ipa/pr85606.C diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index f974d9f769f..7ecd0380fb7 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -1580,7 +1580,10 @@ sem_item::add_type (const_tree type, inchash::hash &hstate) } else if (RECORD_OR_UNION_TYPE_P (type)) { - gcc_checking_assert (COMPLETE_TYPE_P (type)); + /* Incomplete types must be skipped here. */ + if (!COMPLETE_TYPE_P (type)) + return; + hashval_t *val = optimizer->m_type_hash_cache.get (type); if (!val) diff --git a/gcc/testsuite/g++.dg/ipa/pr85606.C b/gcc/testsuite/g++.dg/ipa/pr85606.C new file mode 100644 index 00000000000..b47aba2167d --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr85606.C @@ -0,0 +1,14 @@ +// { dg-do compile } +/* { dg-options "-O2" } */ + +class A; // { dg-message "forward declaration of 'class A'" } + +A *a; // { dg-warning "'a' has incomplete type" } + +int +main (int argc, char **argv) +{ + delete a; // { dg-warning "delete" "warn" } + // { dg-message "note" "note" { target *-*-* } .-1 } + return 0; +}