Fix PR middle-end/107705: ICE after reclaration error
authorAndrew Pinski <apinski@marvell.com>
Thu, 17 Nov 2022 22:03:08 +0000 (22:03 +0000)
committerAndrew Pinski <apinski@marvell.com>
Fri, 18 Nov 2022 17:02:06 +0000 (17:02 +0000)
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
gcc/testsuite/gcc.dg/redecl-22.c [new file with mode: 0644]

index 361aa5f..9c8773b 100644 (file)
@@ -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 (file)
index 0000000..7758570
--- /dev/null
@@ -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 "" }
+}