This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: Limit array element alignment to less than size.
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: sje at cup dot hp dot com (Steve Ellcey)
- Cc: mark at codesourcery dot com, gcc-patches at gcc dot gnu dot org
- Date: Mon, 3 Oct 2005 13:01:49 -0400 (EDT)
- Subject: Re: PATCH: Limit array element alignment to less than size.
>
> > Steve Ellcey wrote:
> >
> > > + if (TYPE_SIZE_UNIT (element)
> > > + && host_integerp (TYPE_SIZE_UNIT (element), 1)
> > > + && tree_low_cst (TYPE_SIZE_UNIT (element), 1) > 0
> > > + && (HOST_WIDE_INT) TYPE_ALIGN_UNIT (element)
> > > + > tree_low_cst (TYPE_SIZE_UNIT (element), 1))
> > > + error ("alignment of array elements is greater than element size");
> >
> > Why do this arithmetic using HOST_WIDE_INTs?
> >
> > Won't this work:
> >
> > if (TREE_CODE (TYPE_SIZE_UNIT (element)) == INTEGER_CST
> > && TREE_CODE (TYPE_ALIGN_UNIT (element)) == INTEGER_CST
> > && int_cst_lt (TYPE_SIZE_UNIT (element), TYPE_ALIGN_UNIT (element))
> > error (...)
> >
> > If that works, that patch is approved.
>
> This doesn't work for me because TYPE_ALIGN_UNIT returns an unsigned
> integer value, not a tree. I assume you meant tree_int_cst_lt, I don't
> see a routine with the name int_cst_lt.
The function is called compare_tree_int.
Thanks,
Andrew Pinski