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: 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


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