This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR middle-end/22028


Hi!

Apparently my PR c/21536 fix causes ICE on some invalid testcases.
error_mark_node has no TYPE_MAIN_VARIANT and so leads to either
checking failures (with checking enabled) or crashes (otherwise).
error_mark_node is checked afterwards anyway, so just moving the
check earlier fixes it.
Ok for HEAD and 4.0 once it reopens?

2005-06-20  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/22028
	* gimplify.c (gimplify_type_sizes): Check for type == error_mark_node
	earlier in the function.

	* gcc.dg/20050620-1.c: New test.

--- gcc/gimplify.c.jj	2005-06-20 12:38:45.000000000 +0200
+++ gcc/gimplify.c	2005-06-20 13:47:26.000000000 +0200
@@ -4484,15 +4484,14 @@ gimplify_type_sizes (tree type, tree *li
 {
   tree field, t;
 
-  if (type == NULL)
+  if (type == NULL || type == error_mark_node)
     return;
 
   /* We first do the main variant, then copy into any other variants.  */
   type = TYPE_MAIN_VARIANT (type);
 
   /* Avoid infinite recursion.  */
-  if (TYPE_SIZES_GIMPLIFIED (type)
-      || type == error_mark_node)
+  if (TYPE_SIZES_GIMPLIFIED (type))
     return;
 
   TYPE_SIZES_GIMPLIFIED (type) = 1;
--- gcc/testsuite/gcc.dg/20050620-1.c.jj	2005-06-20 13:53:30.000000000 +0200
+++ gcc/testsuite/gcc.dg/20050620-1.c	2005-06-20 13:51:55.000000000 +0200
@@ -0,0 +1,15 @@
+/* PR middle-end/22028 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void
+foo (void)
+{
+  struct { int i[]; } u;	/* { dg-error "flexible array member" } */
+}
+
+void
+bar (void)
+{
+  struct { struct a b; } c;	/* { dg-error "has incomplete type" } */
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]