[patch] Fix PR c/18809: ICE on incomplete type in function argument
Volker Reichelt
reichelt@igpm.rwth-aachen.de
Sat Dec 18 22:12:00 GMT 2004
Compiling the following invalid code snippet with the C frontend results
in an ICE:
===================================================================
void foo(enum E e) {}
void bar() { foo(0); }
===================================================================
PR18809.c:1: error: parameter 1 ('e') has incomplete type
PR18809.c: In function 'bar':
PR18809.c:2: internal compiler error: tree check: expected class 'type',
have 'exceptional' (error_mark) in convert_arguments, at c-typeck.c:2069
Since enum E is incomplete, the type of the parameter e is an
error_mark_node. Alas, convert_arguments does not check for an
error_mark_node resulting in an ICE.
The patch below fixes that by adding a check for error_mark_node.
If the test triggers, no conversion is performed for this argument.
The error message then reads:
PR18809.c:1: error: parameter 1 ('e') has incomplete type
PR18809.c: In function 'bar':
PR18809.c:2: error: type of formal parameter 1 is incomplete
Bootstrapped and regtested on i686-pc-linux-gnu.
Ok to commit?
The bug is not a regression, but since the patch is trivial, should
this go into 3.4 as well?
Regards,
Volker
2004-12-18 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c/18809
* c-typeck.c (convert_arguments): Check for error_mark_node.
===================================================================
--- gcc/gcc/c-typeck.c 10 Dec 2004 21:08:19 -0000 1.404
+++ gcc/gcc/c-typeck.c 18 Dec 2004 00:05:46 -0000
@@ -2066,7 +2066,7 @@ convert_arguments (tree typelist, tree v
/* Formal parm type is specified by a function prototype. */
tree parmval;
- if (!COMPLETE_TYPE_P (type))
+ if (type == error_mark_node || !COMPLETE_TYPE_P (type))
{
error ("type of formal parameter %d is incomplete", parmnum + 1);
parmval = val;
===================================================================
2004-12-18 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c/18809
* gcc.dg/pr18809-1.c: New test.
===================================================================
--- gcc/gcc/testsuite/gcc.dg/pr18809-1.c 2003-12-30 15:31:11.000000000 +0100
+++ gcc/gcc/testsuite/gcc.dg/pr18809-1.c 2004-12-18 02:48:32.000000000 +0100
@@ -0,0 +1,7 @@
+/* PR c/18809 */
+/* Origin: Andrew Pinksi <pinskia@gcc.gnu.org> */
+
+/* { dg-do compile } */
+
+void foo(enum E e) {} /* { dg-error "" } */
+void bar() { foo(0); } /* { dg-error "formal" } */
===================================================================
More information about the Gcc-patches
mailing list