if (!gfc_expr_check_typed (*upper, gfc_current_ns, false))
return AS_UNKNOWN;
+ gfc_try_simplify_expr (*upper, 0);
+
if (((*upper)->expr_type == EXPR_CONSTANT
&& (*upper)->ts.type != BT_INTEGER) ||
((*upper)->expr_type == EXPR_FUNCTION
if (!gfc_expr_check_typed (*upper, gfc_current_ns, false))
return AS_UNKNOWN;
+ gfc_try_simplify_expr (*upper, 0);
+
if (((*upper)->expr_type == EXPR_CONSTANT
&& (*upper)->ts.type != BT_INTEGER) ||
((*upper)->expr_type == EXPR_FUNCTION
}
+/* Try simplification of an expression via gfc_simplify_expr.
+ When an error occurs (arithmetic or otherwise), roll back. */
+
+bool
+gfc_try_simplify_expr (gfc_expr *e, int type)
+{
+ gfc_expr *n;
+ bool t, saved_div0;
+
+ if (e == NULL || e->expr_type == EXPR_CONSTANT)
+ return true;
+
+ saved_div0 = gfc_seen_div0;
+ gfc_seen_div0 = false;
+ n = gfc_copy_expr (e);
+ t = gfc_simplify_expr (n, type) && !gfc_seen_div0;
+ if (t)
+ gfc_replace_expr (e, n);
+ else
+ gfc_free_expr (n);
+ gfc_seen_div0 = saved_div0;
+ return t;
+}
+
+
/* Returns the type of an expression with the exception that iterator
variables are automatically integers no matter what else they may
be declared as. */
void gfc_type_convert_binary (gfc_expr *, int);
bool gfc_is_constant_expr (gfc_expr *);
bool gfc_simplify_expr (gfc_expr *, int);
+bool gfc_try_simplify_expr (gfc_expr *, int);
int gfc_has_vector_index (gfc_expr *);
gfc_expr *gfc_get_expr (void);
--- /dev/null
+! { dg-do compile }
+! PR fortran/103505 - this used to ICE in compare_bound_mpz_t
+! Testcase by G.Steinmetz
+
+program p
+ integer, parameter :: a((2.)) = [4,8] ! { dg-error "scalar INTEGER" }
+ integer, parameter :: z(1:(2.)) = [4,8] ! { dg-error "scalar INTEGER" }
+ print *, a(1:1) ! { dg-error "Syntax error" }
+end