This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: ibits
On Tue, Jan 02, 2007 at 12:48:34PM -0800, Steve Kargl wrote:
> On Tue, Jan 02, 2007 at 12:30:44PM -0800, Steve Kargl wrote:
> >
> > I'm guessing that the code in the Fortran frontend that translates
> > IBITS is missing a fold_convert such that ~(-1 << 32) is interpreted
> > as a 32-bit quantity.
> >
>
> This patch fixes the problem.
>
> Index: trans-intrinsic.c
> ===================================================================
> --- trans-intrinsic.c (revision 120314)
> +++ trans-intrinsic.c (working copy)
> @@ -2332,6 +2349,7 @@ gfc_conv_intrinsic_ibits (gfc_se * se, g
> type = TREE_TYPE (arg);
>
> mask = build_int_cst (NULL_TREE, -1);
> + mask = fold_convert (type, mask);
> mask = build2 (LSHIFT_EXPR, type, mask, arg3);
> mask = build1 (BIT_NOT_EXPR, type, mask);
>
A better patch is to simply use build_int_cst (type, -1)
instead of the fold_convert.
--
Steve