[PATCH] Fix C/43211 ICE with incomplete type in function argument

Andrew Pinski pinskia@gmail.com
Fri Mar 19 18:23:00 GMT 2010


The problem here is that we create a function type which has an
error_mark_node as one of the function arguments which confuse the
gimplifier.  The fix is simple, we should just have a variable length
function which solves this issue and allows for the middle-end to work
without any more problems.

OK?  Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Thanks,
Andrew Pinski

ChangeLog:

* c-decl.c (grokparms): Set arg_types to NULL_TREE if there was an error.

* gcc.dg/pr43211.c: New test.
* gcc.dg/pr18809-1.c: Don't expect an error when calling foo.
-------------- next part --------------
Index: testsuite/gcc.dg/pr18809-1.c
===================================================================
--- testsuite/gcc.dg/pr18809-1.c	(revision 157556)
+++ testsuite/gcc.dg/pr18809-1.c	(working copy)
@@ -7,4 +7,4 @@ void foo(enum E e) {}   /* { dg-error "f
 			/* { dg-warning "declared" "declared" { target *-*-* } 6 } */
 			/* { dg-warning "scope" "scope" { target *-*-* } 6 } */
 			/* { dg-error "incomplete" "incomplete" { target *-*-* } 6 } */
-void bar() { foo(0); }  /* { dg-error "formal" } */
+void bar() { foo(0); }
Index: testsuite/gcc.dg/pr43211.c
===================================================================
--- testsuite/gcc.dg/pr43211.c	(revision 0)
+++ testsuite/gcc.dg/pr43211.c	(revision 0)
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+struct T;
+
+struct S {
+  void (*bar)(struct S);
+};
+
+void bar(struct T t) {} /* { dg-error "" }  */
+
+void foo(struct S *s)
+{
+  s->bar = bar;
+}
+
Index: c-decl.c
===================================================================
--- c-decl.c	(revision 157556)
+++ c-decl.c	(working copy)
@@ -6118,6 +6118,7 @@ grokparms (struct c_arg_info *arg_info, 
 
 		  TREE_VALUE (typelt) = error_mark_node;
 		  TREE_TYPE (parm) = error_mark_node;
+		  arg_types = NULL_TREE;
 		}
 	      else if (VOID_TYPE_P (type))
 		{
@@ -6138,6 +6139,7 @@ grokparms (struct c_arg_info *arg_info, 
 	      error (errmsg);
 	      TREE_VALUE (typelt) = error_mark_node;
 	      TREE_TYPE (parm) = error_mark_node;
+	      arg_types = NULL_TREE;
 	    }
 
 	  if (DECL_NAME (parm) && TREE_USED (parm))


More information about the Gcc-patches mailing list