diff options
author | Harald Anlauf <anlauf@gmx.de> | 2020-10-16 22:17:46 +0200 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2020-10-16 22:17:46 +0200 |
commit | 02629b116eed7c6911ef0eb2ef97e1883e9fb1de (patch) | |
tree | 93f23a96b872c6f78d8cd527b4e10fdd04a45e2c /gcc/fortran | |
parent | 3e8d8f3b883cbcc19974f6b2438f54b05769a76c (diff) | |
download | gcc-02629b116eed7c6911ef0eb2ef97e1883e9fb1de.zip gcc-02629b116eed7c6911ef0eb2ef97e1883e9fb1de.tar.gz gcc-02629b116eed7c6911ef0eb2ef97e1883e9fb1de.tar.bz2 |
PR fortran/95979 - ICE in get_kind, at fortran/simplify.c:129
Simplification of the elemental intrinsic INDEX with constant array-valued
arguments failed with an ICE or did not reduce to a constant array, depending
also on the presence of the optional KIND argument. Add a further attempt of
simplification in the case of elemental intrinsics, and make sure the KIND
argument is not removed prematurely during simplification of INDEX.
gcc/fortran/ChangeLog:
PR fortran/95979
* expr.c (gfc_check_init_expr): Fix check of return code from
gfc_intrinsic_func_interface.
* intrinsic.c (gfc_intrinsic_func_interface): Add further attempt
of simplification of elemental intrinsics with array arguments.
* iresolve.c (gfc_resolve_index_func): Keep optional KIND argument
for simplification of elemental use of INDEX.
gcc/testsuite/ChangeLog:
PR fortran/95979
* gfortran.dg/index_4.f90: New test.
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/expr.c | 2 | ||||
-rw-r--r-- | gcc/fortran/intrinsic.c | 5 | ||||
-rw-r--r-- | gcc/fortran/iresolve.c | 6 |
3 files changed, 7 insertions, 6 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index b87ae3d..32d905a 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -2904,7 +2904,7 @@ gfc_check_init_expr (gfc_expr *e) && (e->value.function.isym->conversion == 1); if (!conversion && (!gfc_is_intrinsic (sym, 0, e->where) - || (m = gfc_intrinsic_func_interface (e, 0)) != MATCH_YES)) + || (m = gfc_intrinsic_func_interface (e, 0)) == MATCH_NO)) { gfc_error ("Function %qs in initialization expression at %L " "must be an intrinsic function", diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index ef33587..f4dfcf7 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -5038,6 +5038,11 @@ got_specific: if (!sym->module) gfc_intrinsic_symbol (sym); + /* Have another stab at simplification since elemental intrinsics with array + actual arguments would be missed by the calls above to do_simplify. */ + if (isym->elemental) + gfc_simplify_expr (expr, 1); + return MATCH_YES; } diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c index c2a4865..994a9af 100644 --- a/gcc/fortran/iresolve.c +++ b/gcc/fortran/iresolve.c @@ -1296,11 +1296,7 @@ gfc_resolve_index_func (gfc_expr *f, gfc_actual_arglist *a) f->ts.type = BT_INTEGER; if (kind) - { - f->ts.kind = mpz_get_si ((kind)->value.integer); - a_back->next = NULL; - gfc_free_actual_arglist (a_kind); - } + f->ts.kind = mpz_get_si ((kind)->value.integer); else f->ts.kind = gfc_default_integer_kind; |