if (op->expr_type == EXPR_CONSTANT)
return eval (op, result);
+ if (op->expr_type != EXPR_ARRAY)
+ return ARITH_NOT_REDUCED;
+
rc = ARITH_OK;
head = gfc_constructor_copy (op->value.constructor);
for (c = gfc_constructor_first (head); c; c = gfc_constructor_next (c))
{
- if (c->expr->expr_type == EXPR_OP && c->expr->ts.type == BT_UNKNOWN)
- rc = ARITH_INVALID_TYPE;
- else
- rc = reduce_unary (eval, c->expr, &r);
+ rc = reduce_unary (eval, c->expr, &r);
if (rc != ARITH_OK)
break;
if (c->expr->expr_type == EXPR_CONSTANT)
rc = eval (c->expr, op2, &r);
- else if (c->expr->expr_type == EXPR_OP && c->expr->ts.type == BT_UNKNOWN)
- rc = ARITH_INVALID_TYPE;
+ else if (c->expr->expr_type != EXPR_ARRAY)
+ rc = ARITH_NOT_REDUCED;
else
rc = reduce_binary_ac (eval, c->expr, op2, &r);
if (c->expr->expr_type == EXPR_CONSTANT)
rc = eval (op1, c->expr, &r);
- else if (c->expr->expr_type == EXPR_OP && c->expr->ts.type == BT_UNKNOWN)
- rc = ARITH_INVALID_TYPE;
+ else if (c->expr->expr_type != EXPR_ARRAY)
+ rc = ARITH_NOT_REDUCED;
else
rc = reduce_binary_ca (eval, op1, c->expr, &r);
c && d;
c = gfc_constructor_next (c), d = gfc_constructor_next (d))
{
- if ((c->expr->expr_type == EXPR_OP && c->expr->ts.type == BT_UNKNOWN)
- || (d->expr->expr_type == EXPR_OP && d->expr->ts.type == BT_UNKNOWN))
- rc = ARITH_INVALID_TYPE;
- else
- rc = reduce_binary (eval, c->expr, d->expr, &r);
+ rc = reduce_binary (eval, c->expr, d->expr, &r);
if (rc != ARITH_OK)
break;
if (op1->expr_type == EXPR_ARRAY && op2->expr_type == EXPR_CONSTANT)
return reduce_binary_ac (eval, op1, op2, result);
+ if (op1->expr_type != EXPR_ARRAY || op2->expr_type != EXPR_ARRAY)
+ return ARITH_NOT_REDUCED;
+
return reduce_binary_aa (eval, op1, op2, result);
}
else
rc = reduce_binary (eval.f3, op1, op2, &result);
- if (rc == ARITH_INVALID_TYPE)
+ if (rc == ARITH_INVALID_TYPE || rc == ARITH_NOT_REDUCED)
goto runtime;
/* Something went wrong. */
Assumptions are made about the numbering of the interface_op enums. */
#define GFC_INTRINSIC_OPS GFC_INTRINSIC_END
-/* Arithmetic results. */
+/* Arithmetic results. ARITH_NOT_REDUCED is used to keep track of expressions
+ that were not reduced by the arithmetic evaluation code. */
enum arith
{ ARITH_OK = 1, ARITH_OVERFLOW, ARITH_UNDERFLOW, ARITH_NAN,
ARITH_DIV0, ARITH_INCOMMENSURATE, ARITH_ASYMMETRIC, ARITH_PROHIBIT,
- ARITH_WRONGCONCAT, ARITH_INVALID_TYPE
+ ARITH_WRONGCONCAT, ARITH_INVALID_TYPE, ARITH_NOT_REDUCED
};
/* Statements. */
--- /dev/null
+! { dg-do compile }
+!
+! Test the fix for the following:
+! PR fortran/93483
+! PR fortran/107216
+! PR fortran/107219
+!
+! Contributed by G.Steinmetz
+
+program p
+ real, parameter :: r0(*) = +[real :: +(1) ]
+ real, parameter :: r1(*) = +[real :: +[1] ]
+ real, parameter :: r2(*) = -[real :: [(1)]]
+ real, parameter :: r3(*) = +[real :: [-(1)]]
+ real, parameter :: r4(*) = -[real :: [[(1)]]]
+ real, parameter :: r5(*) = -[real :: -[1, 2]]
+ real, parameter :: r6(*) = +[real :: +[1, 2]]
+ real, parameter :: r7(*) = [real :: 1, 2] * [real :: 1, (2)]
+ real, parameter :: r8(*) = [real :: 1, (2)] * [real :: 1, 2]
+ real, parameter :: r9(*) = +[real :: 1, 2] * [real :: 1, (2)]
+ real, parameter :: rr(*) = -[real :: 1, (2)] * [real :: 1, 2]
+end