+2018-10-30 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/85896
+ * simplify.c (simplify_min_max): Do not convert the type of the
+ return expression.
+
2017-10-28 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/54613
simplify_min_max (gfc_expr *expr, int sign)
{
gfc_actual_arglist *arg, *last, *extremum;
- gfc_intrinsic_sym * specific;
last = NULL;
extremum = NULL;
- specific = expr->value.function.isym;
arg = expr->value.function.actual;
if (expr->value.function.actual->next != NULL)
return NULL;
- /* Convert to the correct type and kind. */
- if (expr->ts.type != BT_UNKNOWN)
- return gfc_convert_constant (expr->value.function.actual->expr,
- expr->ts.type, expr->ts.kind);
-
- if (specific->ts.type != BT_UNKNOWN)
- return gfc_convert_constant (expr->value.function.actual->expr,
- specific->ts.type, specific->ts.kind);
-
return gfc_copy_expr (expr->value.function.actual->expr);
}
--- /dev/null
+! { dg-do run }
+! Make sure this is evaluated correctly even though max
+! has been declared integer.
+! Original test case by Gerhard Steinmetz.
+program main
+ integer :: max
+ character(len=1), parameter :: c = max('a','b')
+ character(len=1), parameter :: d = min('a','b')
+ if (c /= 'b' .or. d /= 'a') stop 1
+end program main