This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix PR c/27420: ICE on invalid function definition
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 05 May 2006 13:43:45 +0200 (CEST)
- Subject: [patch] Fix PR c/27420: ICE on invalid function definition
The C frontend crashes on the following invalid code:
void foo();
void foo(struct A a) {}
PR27420.c:2: warning: 'struct A' declared inside parameter list
PR27420.c:2: warning: its scope is only this definition or declaration,
which is probably not what you want
PR27420.c:2: error: parameter 1 ('a') has incomplete type
PR27420.c:2: internal compiler error: tree check: expected class 'type',
have 'exceptional' (error_mark) in self_promoting_args_p, at c-common.c:3527
Please submit a full bug report, [etc.]
The problem is that self_promoting_args_p from c-common.c cannot deal
with args that have an error_mark_node as type. The ICE happens when
TYPE_MAIN_VARIANT is called for an error_mark_node.
The patch fixes the ICE by skipping erroneous args in self_promoting_args_p.
Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline?
Regards,
Volker
:ADDPATCH C:
2006-05-05 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c/27420
* c-common.c (self_promoting_args_p): Skip erroneous args.
===================================================================
--- gcc/gcc/c-common.c 2006-05-05 03:31:01 +0200
+++ gcc/gcc/c-common.c 2006-05-05 03:26:26 +0200
@@ -3518,6 +3518,9 @@ self_promoting_args_p (tree parms)
{
tree type = TREE_VALUE (t);
+ if (type == error_mark_node)
+ continue;
+
if (TREE_CHAIN (t) == 0 && type != void_type_node)
return 0;
===================================================================
2006-05-05 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c/27420
* gcc.dg/func-args-2.c: New test.
===================================================================
--- gcc/gcc/testsuite/gcc.dg/func-args-2.c 2003-09-23 19:59:22 +0200
+++ gcc/gcc/testsuite/gcc.dg/func-args-2.c 2006-05-05 03:37:21 +0200
@@ -0,0 +1,6 @@
+/* PR c/27420 */
+/* { dg-do compile } */
+/* { dg-options "-w" } */
+
+void foo();
+void foo(struct A a) {} /* { dg-error "incomplete type" } */
===================================================================