This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Don't let calls with error_mark_node args get through to gimplification in C (PR c/41842)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 27 Oct 2009 11:36:50 +0100
- Subject: [PATCH] Don't let calls with error_mark_node args get through to gimplification in C (PR c/41842)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
Unlike the C++ FE, the C FE happily passes a call with error_mark_node
arguments to the gimplifier, which, because it can be used then in a place
which isn't fb_mayfail, ICEs on it. The following patch fixes it.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.4?
2009-10-27 Jakub Jelinek <jakub@redhat.com>
PR c/41842
* c-typeck.c (convert_arguments): Return -1 if any of the arguments is
error_mark_node.
* gcc.dg/pr41842.c: New test.
--- gcc/c-typeck.c.jj 2009-10-26 14:01:33.000000000 +0100
+++ gcc/c-typeck.c 2009-10-27 09:11:24.000000000 +0100
@@ -2673,6 +2673,7 @@ convert_arguments (tree typelist, VEC(tr
{
tree typetail, val;
unsigned int parmnum;
+ bool error_args = false;
const bool type_generic = fundecl
&& lookup_attribute ("type generic", TYPE_ATTRIBUTES(TREE_TYPE (fundecl)));
bool type_generic_remove_excess_precision = false;
@@ -2942,6 +2943,8 @@ convert_arguments (tree typelist, VEC(tr
parmval = default_conversion (val);
VEC_replace (tree, values, parmnum, parmval);
+ if (parmval == error_mark_node)
+ error_args = true;
if (typetail)
typetail = TREE_CHAIN (typetail);
@@ -2955,7 +2958,7 @@ convert_arguments (tree typelist, VEC(tr
return -1;
}
- return parmnum;
+ return error_args ? -1 : (int) parmnum;
}
/* This is the entry point used by the parser to build unary operators
--- gcc/testsuite/gcc.dg/pr41842.c.jj 2009-10-27 09:15:31.000000000 +0100
+++ gcc/testsuite/gcc.dg/pr41842.c 2009-10-27 09:16:16.000000000 +0100
@@ -0,0 +1,8 @@
+/* PR c/41842 */
+/* { dg-do compile } */
+
+void
+f ()
+{
+ char x[g (h)]; /* { dg-error "undeclared|for each function" } */
+}
Jakub