public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: <apinski@marvell.com>
To: <gcc-patches@gcc.gnu.org>
Cc: Andrew Pinski <apinski@marvell.com>
Subject: [PATCH 2/2] Fix PR middle-end/107705: ICE after reclaration error
Date: Thu, 17 Nov 2022 19:25:11 -0800	[thread overview]
Message-ID: <1668741911-1727-2-git-send-email-apinski@marvell.com> (raw)
In-Reply-To: <1668741911-1727-1-git-send-email-apinski@marvell.com>

From: Andrew Pinski <apinski@marvell.com>

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


  reply	other threads:[~2022-11-18  3:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-18  3:25 [PATCH 1/2] Fix PRs 106764, 106765, and 107307, all ICE after invalid re-declaration apinski
2022-11-18  3:25 ` apinski [this message]
2022-11-18  8:45   ` [PATCH 2/2] Fix PR middle-end/107705: ICE after reclaration error Richard Biener
2022-11-18  8:46 ` [PATCH 1/2] Fix PRs 106764, 106765, and 107307, all ICE after invalid re-declaration Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1668741911-1727-2-git-send-email-apinski@marvell.com \
    --to=apinski@marvell.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).