From patchwork Sun Nov 20 01:25:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 23367 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp931833wrr; Sat, 19 Nov 2022 17:26:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Gu/9OendaHMTUgJtBqruNHFafC+7Lff2Ojkc+XLoSB6tAs3BgrEXE4oxzWORMTaLd7dS+ X-Received: by 2002:a17:907:d092:b0:7ad:7e85:8056 with SMTP id vc18-20020a170907d09200b007ad7e858056mr10780452ejc.40.1668907609249; Sat, 19 Nov 2022 17:26:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668907609; cv=none; d=google.com; s=arc-20160816; b=S0UfDAsAXJ1UfUVSEMQP59BGtNKjQHcAyxr+lL0+msDdAEMke78d4cke5Ln46bxFr6 RQflcXQUBZbcnT1ZXKYlI54vKecZJeEuvkaTpbsK24qAbN2URL+iYc+SNBm6UdpiMzio fcJO5xJTE1REh7QHRLRc+0O4IWW06dWKe88JUZQsJNGFUrQNBlmpSsI7TMNcdf2tElDj UjAeb5+wFogWoOS6z3xj7VszUQ2GQqsizkECV0nzRhyrHeFcZvS5qA6sgkOHsSEl72zI /euOqnWgDaz6igv6svP77+TgnIYBiJ5ImkGz89b3iF46JJcybDT//6aFJW7qvai/XBn7 Wc+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=C2LbcZdsrsQxrn9a8f001tQ2F2oaJjT+q0MIiywSiBA=; b=E0NK7/yzZcMkKynG/jqVmdxcMTSj6b38jrow3xe7a3uviajJNg3LLQb5PFY17+zrb5 aZOz0N+sCbpA5DtdgsKS2oIw466+VtDECQKOeg29l/3Q2MCgh+xgJIO/SnOiBsfcujjo cu4GEtqKw1qYUu26eAAyyFwEUivwiFo2OdIa69bATrv6r49Cz5+SmVmoq2JPQC263aMm ugzqrnhOGK6tk67XRSdKYcIg6xrcbxzJ1Z6OTExOIeGxUu7aD/X9XQkf13h6es3ejeKa ayUm9wsLvfFSJ6qYE6OnsNQXdMWxpV/YfJtqZl+LyWDr4p37KSCAVPtYvNQMayPK+Yyx URQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=WcH74KBt; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f10-20020a056402194a00b004588172def1si5607266edz.410.2022.11.19.17.26.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Nov 2022 17:26:49 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=WcH74KBt; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EBC88388B6B1 for ; Sun, 20 Nov 2022 01:26:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EBC88388B6B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668907608; bh=C2LbcZdsrsQxrn9a8f001tQ2F2oaJjT+q0MIiywSiBA=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=WcH74KBtvA/iOjVOmFeTN7s+qmy085VoDO7w1wEkkyFebusWW2eXAVwu+FFdju4YD pBDSz1D3UkZMz53oSAeXS4vod5ck7iUBjXdYOqbkI7XtkqPorZURBkPIqpgKkmXOFy kmfs79SzJK1fAfatKjfdJhQ7axrFHQW4hZ3aAwSE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id 506EF388B698 for ; Sun, 20 Nov 2022 01:25:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 506EF388B698 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AJN0svi008214 for ; Sat, 19 Nov 2022 17:25:29 -0800 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3kxyhrsaeu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sat, 19 Nov 2022 17:25:29 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 19 Nov 2022 17:25:27 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Sat, 19 Nov 2022 17:25:27 -0800 Received: from linux.wrightpinski.org.com (unknown [10.69.242.198]) by maili.marvell.com (Postfix) with ESMTP id 288345B6938; Sat, 19 Nov 2022 17:25:27 -0800 (PST) To: CC: Andrew Pinski Subject: [PATCH] Fix PR 106560: Another ICE after conflicting types of redeclaration Date: Sat, 19 Nov 2022 17:25:04 -0800 Message-ID: <1668907504-29652-1-git-send-email-apinski@marvell.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Proofpoint-GUID: vHG-EwhjbAXEPGGLpdBAkSWf-0cPjvDO X-Proofpoint-ORIG-GUID: vHG-EwhjbAXEPGGLpdBAkSWf-0cPjvDO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-18_08,2022-11-18_01,2022-06-22_01 X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: apinski--- via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: apinski@marvell.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749976465429762131?= X-GMAIL-MSGID: =?utf-8?q?1749976465429762131?= From: Andrew Pinski This another one of these ICE after error issues with the gimplifier and a fallout from r12-3278-g823685221de986af. The problem here is gimplify_modify_expr does not check if either from or to was an error operand. This adds the check and fixes the ICE. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * gimplify.cc (gimplify_modify_expr): If either *from_p or *to_p were error_operand return early. gcc/testsuite/ChangeLog: * gcc.dg/redecl-23.c: New test. * gcc.dg/redecl-24.c: New test. * gcc.dg/redecl-25.c: New test. --- gcc/gimplify.cc | 3 +++ gcc/testsuite/gcc.dg/redecl-23.c | 6 ++++++ gcc/testsuite/gcc.dg/redecl-24.c | 6 ++++++ gcc/testsuite/gcc.dg/redecl-25.c | 9 +++++++++ 4 files changed, 24 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/redecl-23.c create mode 100644 gcc/testsuite/gcc.dg/redecl-24.c create mode 100644 gcc/testsuite/gcc.dg/redecl-25.c diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index c62a966e918..02415cb1b5c 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -6054,6 +6054,9 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, location_t loc = EXPR_LOCATION (*expr_p); gimple_stmt_iterator gsi; + if (error_operand_p (*from_p) || error_operand_p (*to_p)) + return GS_ERROR; + gcc_assert (TREE_CODE (*expr_p) == MODIFY_EXPR || TREE_CODE (*expr_p) == INIT_EXPR); diff --git a/gcc/testsuite/gcc.dg/redecl-23.c b/gcc/testsuite/gcc.dg/redecl-23.c new file mode 100644 index 00000000000..425721df2ff --- /dev/null +++ b/gcc/testsuite/gcc.dg/redecl-23.c @@ -0,0 +1,6 @@ +/* We used to ICE in the gimplifier, PR 106560. */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ +void **a; /* { dg-note "" } */ +void b() { void **c = a; } +a; /* { dg-error "" } */ diff --git a/gcc/testsuite/gcc.dg/redecl-24.c b/gcc/testsuite/gcc.dg/redecl-24.c new file mode 100644 index 00000000000..f0f7a723ab8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/redecl-24.c @@ -0,0 +1,6 @@ +/* We used to ICE in the gimplifier, PR 106560 */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ +void **a, **b; /* { dg-note "" } */ +c(){b = a;} +a = /* { dg-error "" } */ diff --git a/gcc/testsuite/gcc.dg/redecl-25.c b/gcc/testsuite/gcc.dg/redecl-25.c new file mode 100644 index 00000000000..4232e19d9a7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/redecl-25.c @@ -0,0 +1,9 @@ +/* We used to ICE in the gimplifier, PR 106560 */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ +void **a; /* { dg-note "" } */ +void b() { + void **c; + c = a /* { dg-error "" } */ +} +a; /* { dg-error "" } */