[PATCH] Fix PR64137

Richard Biener rguenther@suse.de
Tue Dec 2 08:51:00 GMT 2014


On Mon, 1 Dec 2014, Richard Biener wrote:

> On Mon, 1 Dec 2014, FX wrote:
> 
> > Your change is OK (we don’t want to use the type of the result, but the type of the argument indeed).
> > 
> > 
> > > Index: gcc/fortran/trans-intrinsic.c
> > > ===================================================================
> > > --- gcc/fortran/trans-intrinsic.c	(revision 218211)
> > > +++ gcc/fortran/trans-intrinsic.c	(working copy)
> > > @@ -3729,7 +3729,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * s
> > >      possible value is HUGE in both cases.  */
> > >   if (op == GT_EXPR)
> > >     tmp = fold_build1_loc (input_location, NEGATE_EXPR, TREE_TYPE (tmp), tmp);
> > > -  if (op == GT_EXPR && expr->ts.type == BT_INTEGER)
> > > +  if (op == GT_EXPR && arrayexpr->ts.type == BT_INTEGER)
> > >     tmp = fold_build2_loc (input_location, MINUS_EXPR, TREE_TYPE (tmp), tmp,
> > > 			   build_int_cst (type, 1));
> > 
> > 
> > Logic would dictate that it is "build_int_cst (TREE_TYPE (tmp), 1)” 
> > instead of "build_int_cst (type, 1)” in that last line. Probably doesn’t 
> > matter much, as it will be all folded into the same value anyway, but 
> > could you test and commit that change together, while you’re at it?
> 
> Sure, will re-test and commit tomorrow.

The following is what I have applied after bootstrap & regtest on
x86_64-unknown-linux-gnu.

Richard.

2014-12-02  Richard Biener  <rguenther@suse.de>

	PR fortran/64137
	* trans-intrinsic.c (gfc_conv_intrinsic_minmaxloc): Check
	proper expressions type, use proper type for computing
	-Huge - 1.

Index: gcc/fortran/trans-intrinsic.c
===================================================================
--- gcc/fortran/trans-intrinsic.c	(revision 218225)
+++ gcc/fortran/trans-intrinsic.c	(working copy)
@@ -3729,9 +3729,9 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * s
      possible value is HUGE in both cases.  */
   if (op == GT_EXPR)
     tmp = fold_build1_loc (input_location, NEGATE_EXPR, TREE_TYPE (tmp), tmp);
-  if (op == GT_EXPR && expr->ts.type == BT_INTEGER)
+  if (op == GT_EXPR && arrayexpr->ts.type == BT_INTEGER)
     tmp = fold_build2_loc (input_location, MINUS_EXPR, TREE_TYPE (tmp), tmp,
-			   build_int_cst (type, 1));
+			   build_int_cst (TREE_TYPE (tmp), 1));
 
   gfc_add_modify (&se->pre, limit, tmp);
 


More information about the Gcc-patches mailing list