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]

Re: [PATCH] Fix infinite recursion in C front end during bad struct parsing. (ping)


Carlos O'Donell wrote:
> Ping?
> 
> http://gcc.gnu.org/ml/gcc-patches/2006-04/msg00161.html

This is OK, but I think we can make it a bit tidier.

In particular, modify update_alignment_for_field so that it returns
immediately if TREE_TYPE (field) is error_mark_node.  (In general, we
try to make routines robust in the face of error_mark_node, since it can
appear "anywhere".)

Then, you will not need this hunk:

   else if (TREE_CODE (rli->t) != RECORD_TYPE)
     {
-      place_union_field (rli, field);
+      if (bad_type)
+	{
+	  /* Place the field at the start of the union.  */
+	  DECL_FIELD_OFFSET (field) = size_zero_node;
+	  DECL_FIELD_BIT_OFFSET (field) = bitsize_zero_node;
+	  SET_DECL_OFFSET_ALIGN (field, BIGGEST_ALIGNMENT);
+	}
+      else
+	place_union_field (rli, field);
       return;
     }

because place_union_field will do the right thing.  Then, you will also
not need the bad_type variable, because it will have only one use; you
can just check "TREE_TYPE (field) == error_mark_node" here:

+  else if (bad_type)
+    {
+      /* Place this field at the current allocation position, so we
+	 maintain monotonicity.  */
+      DECL_FIELD_OFFSET (field) = rli->offset;
+      DECL_FIELD_BIT_OFFSET (field) = rli->bitpos;
+      SET_DECL_OFFSET_ALIGN (field, rli->offset_align);
+      return;
+    }

Please make those changes, retest, and commit.

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


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