From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id B8995385841C for ; Fri, 18 Nov 2022 03:25:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B8995385841C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=marvell.com 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 2AI1wNd3003432 for ; Thu, 17 Nov 2022 19:25:22 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=Dx3dxL1zMj0YOJdWCudEtQGTN3hAEvb9cXhIGVC7VVo=; b=EHRtzWW183EGJKvReFCqGZrIe1h/i6AJbIMJTWJPpIGgqC1qfn7z673Q/Uc0lCW0FB+F /JaYsF/LNIc8RwBBjOT6aMvltUOuV6bi5OayKmL+VqKstTbOhxwrKOWfhOwrCd/T2XGw jbhpxjs5PEOZxPGCv2nx1lBY8rsXW7SafRyJQ1t3tyFaoASsoK9PRO35wCXCERxmLJ/S hRA8T5nitocgwgo3ZAR5e+TCtGWx1jCjm4dnHBJs46DIjBOHpoclmvMOCIMVA0ndBQjD oKmjvpZYPTo/YPmuXL+YIazHGZiXew0+N4VE8H1N0zgt2fkL2+SmweetJxZHJOBbBj+l TQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3kx0ut8ayk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 17 Nov 2022 19:25:22 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 17 Nov 2022 19:25:20 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 17 Nov 2022 19:25:20 -0800 Received: from linux.wrightpinski.org.com (unknown [10.69.242.198]) by maili.marvell.com (Postfix) with ESMTP id 139C43F704E; Thu, 17 Nov 2022 19:25:18 -0800 (PST) From: To: CC: Andrew Pinski Subject: [PATCH 2/2] Fix PR middle-end/107705: ICE after reclaration error Date: Thu, 17 Nov 2022 19:25:11 -0800 Message-ID: <1668741911-1727-2-git-send-email-apinski@marvell.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1668741911-1727-1-git-send-email-apinski@marvell.com> References: <1668741911-1727-1-git-send-email-apinski@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: K4iVMwmIjg7TUgzK6bbhVzcwQGUIjhHQ X-Proofpoint-ORIG-GUID: K4iVMwmIjg7TUgzK6bbhVzcwQGUIjhHQ 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-17_06,2022-11-17_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 List-Id: From: Andrew Pinski The problem here is after we created a call expression in the C front-end, we replace the decl type with an error mark node. We then end up calling aggregate_value_p with the call expression with the decl with the error mark as the type and we ICE. The fix is to check the function type after we process the call expression inside aggregate_value_p to get it. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. Thanks, Andrew Pinski gcc/ChangeLog: PR middle-end/107705 * function.cc (aggregate_value_p): Return 0 if the function type was an error operand. gcc/testsuite/ChangeLog: * gcc.dg/redecl-22.c: New test. --- gcc/function.cc | 3 +++ gcc/testsuite/gcc.dg/redecl-22.c | 9 +++++++++ 2 files changed, 12 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/redecl-22.c diff --git a/gcc/function.cc b/gcc/function.cc index 361aa5f7ed1..9c8773bbc59 100644 --- a/gcc/function.cc +++ b/gcc/function.cc @@ -2090,6 +2090,9 @@ aggregate_value_p (const_tree exp, const_tree fntype) if (VOID_TYPE_P (type)) return 0; + if (error_operand_p (fntype)) + return 0; + /* If a record should be passed the same as its first (and only) member don't pass it as an aggregate. */ if (TREE_CODE (type) == RECORD_TYPE && TYPE_TRANSPARENT_AGGR (type)) diff --git a/gcc/testsuite/gcc.dg/redecl-22.c b/gcc/testsuite/gcc.dg/redecl-22.c new file mode 100644 index 00000000000..7758570fabe --- /dev/null +++ b/gcc/testsuite/gcc.dg/redecl-22.c @@ -0,0 +1,9 @@ +/* We used to ICE in the gimplifier, PR 107705 */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ +int f (void) +{ + int (*p) (void) = 0; // { dg-note "" } + return p (); + int p = 1; // { dg-error "" } +} -- 2.17.1