diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2019-01-06 12:48:58 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2019-01-06 12:48:58 +0000 |
commit | 13b1afe4defcc3eeaa50fe10eb2f2768e95696ec (patch) | |
tree | 26134927b3fb6c16bc2861226c82eda9a4723674 /gcc/fortran/simplify.c | |
parent | 8f4813c1b7e2e567dbeeb5f46ce3ecd7c702bef7 (diff) | |
download | gcc-13b1afe4defcc3eeaa50fe10eb2f2768e95696ec.zip gcc-13b1afe4defcc3eeaa50fe10eb2f2768e95696ec.tar.gz gcc-13b1afe4defcc3eeaa50fe10eb2f2768e95696ec.tar.bz2 |
re PR fortran/88658 (Intrinsic MAX1 returns a REAL result, should be INTEGER.)
2019-01-06 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/88658
* gfortran.h: Add macro gfc_real_4_kind
* simplify.c (simplify_min_max): Special case for the types of
AMAX0, AMIN0, MAX1 and MIN1, which actually change the types of
their arguments.
2019-01-06 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/88658
* gfortran.dg/min_max_type_2.f90: New test.
From-SVN: r267609
Diffstat (limited to 'gcc/fortran/simplify.c')
-rw-r--r-- | gcc/fortran/simplify.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 2231390..fdaf3cb 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -4963,6 +4963,8 @@ static gfc_expr * simplify_min_max (gfc_expr *expr, int sign) { gfc_actual_arglist *arg, *last, *extremum; + gfc_expr *tmp, *ret; + const char *fname; last = NULL; extremum = NULL; @@ -4995,7 +4997,27 @@ simplify_min_max (gfc_expr *expr, int sign) if (expr->value.function.actual->next != NULL) return NULL; - return gfc_copy_expr (expr->value.function.actual->expr); + /* Handle special cases of specific functions (min|max)1 and + a(min|max)0. */ + + tmp = expr->value.function.actual->expr; + fname = expr->value.function.isym->name; + + if ((tmp->ts.type != BT_INTEGER || tmp->ts.kind != gfc_integer_4_kind) + && (strcmp (fname, "min1") == 0 || strcmp (fname, "max1") == 0)) + { + ret = gfc_convert_constant (tmp, BT_INTEGER, gfc_integer_4_kind); + } + else if ((tmp->ts.type != BT_REAL || tmp->ts.kind != gfc_real_4_kind) + && (strcmp (fname, "amin0") == 0 || strcmp (fname, "amax0") == 0)) + { + ret = gfc_convert_constant (tmp, BT_REAL, gfc_real_4_kind); + } + else + ret = gfc_copy_expr (tmp); + + return ret; + } |