From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1314) id B0870384233A; Fri, 18 Nov 2022 17:03:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0870384233A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668791003; bh=k2pMlp+1TiSEI6toFWGFdJyiAkUPt/E0TrnwnYdI+cU=; h=From:To:Subject:Date:From; b=ucMgawtZeduRsaeT24mmwdYzB1nxou1gExzkOMl0c/7JEFDdoE/kt8sGlAgIWeJGZ vmqBjsr6QRENerVTE+/7yMqipWUbGqDQ6SkxfCF0vRTqgXzeu3lcsPepTGx8Muqqog ET0OymzZyXUoramtLFBZJBtrwT747QLffKel+MQw= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Andrew Pinski To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4144] Fix PR middle-end/107705: ICE after reclaration error X-Act-Checkin: gcc X-Git-Author: Andrew Pinski X-Git-Refname: refs/heads/trunk X-Git-Oldrev: bd0c9d9e706adaeea0d96152daade0a6819a8715 X-Git-Newrev: ceba66ee230bb96b0889fc8ec7333c7ffae96d6e Message-Id: <20221118170323.B0870384233A@sourceware.org> Date: Fri, 18 Nov 2022 17:03:23 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ceba66ee230bb96b0889fc8ec7333c7ffae96d6e commit r13-4144-gceba66ee230bb96b0889fc8ec7333c7ffae96d6e Author: Andrew Pinski Date: Thu Nov 17 22:03:08 2022 +0000 Fix PR middle-end/107705: ICE after reclaration error 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. Diff: --- gcc/function.cc | 3 +++ gcc/testsuite/gcc.dg/redecl-22.c | 9 +++++++++ 2 files changed, 12 insertions(+) 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 "" } +}