diff options
author | Harald Anlauf <anlauf@gmx.de> | 2022-11-15 21:20:20 +0100 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2022-11-16 21:13:16 +0100 |
commit | 713dcfc85ebbabaf74a1bcbac4ba1143519b31d6 (patch) | |
tree | b2920853c359e4720fe0b9c3c14f1ef6203c2c99 /gcc/fortran | |
parent | ac74b3f82b339569b34dc9d1330c2faf74a1c82a (diff) | |
download | gcc-713dcfc85ebbabaf74a1bcbac4ba1143519b31d6.zip gcc-713dcfc85ebbabaf74a1bcbac4ba1143519b31d6.tar.gz gcc-713dcfc85ebbabaf74a1bcbac4ba1143519b31d6.tar.bz2 |
Fortran: ICE in simplification of array expression involving power [PR107680]
gcc/fortran/ChangeLog:
PR fortran/107680
* arith.cc (arith_power): Check that operands are properly converted
before attempting to simplify.
gcc/testsuite/ChangeLog:
PR fortran/107680
* gfortran.dg/pr107680.f90: New test.
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/arith.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc index fc9224eb..c4ab75b 100644 --- a/gcc/fortran/arith.cc +++ b/gcc/fortran/arith.cc @@ -845,6 +845,13 @@ arith_power (gfc_expr *op1, gfc_expr *op2, gfc_expr **resultp) if (!gfc_numeric_ts (&op1->ts) || !gfc_numeric_ts (&op2->ts)) return ARITH_INVALID_TYPE; + /* The result type is derived from op1 and must be compatible with the + result of the simplification. Otherwise postpone simplification until + after operand conversions usually done by gfc_type_convert_binary. */ + if ((op1->ts.type == BT_INTEGER && op2->ts.type != BT_INTEGER) + || (op1->ts.type == BT_REAL && op2->ts.type == BT_COMPLEX)) + return ARITH_NOT_REDUCED; + rc = ARITH_OK; result = gfc_get_constant_expr (op1->ts.type, op1->ts.kind, &op1->where); |