===================================================================
@@ -408,7 +408,23 @@ gfc_resolve_array_spec (gfc_array_spec *as, int ch
return true;
}
+/* Strip away any parentheses around an expression. The argument is
+ assumed to be non-NULL. */
+static void
+strip_parens (gfc_expr *e)
+{
+ gfc_expr *r;
+
+ r = e;
+
+ while (r->expr_type == EXPR_OP && r->value.op.op == INTRINSIC_PARENTHESES)
+ r = r->value.op.op1;
+
+ if (r != e)
+ gfc_replace_expr (e, gfc_copy_expr (r));
+}
+
/* Match a single array element specification. The return values as
well as the upper and lower bounds of the array spec are filled
in according to what we see on the input. The caller makes sure
@@ -457,6 +473,7 @@ match_array_element_spec (gfc_array_spec *as)
if (!gfc_expr_check_typed (*upper, gfc_current_ns, false))
return AS_UNKNOWN;
+ strip_parens (*upper);
if (((*upper)->expr_type == EXPR_CONSTANT
&& (*upper)->ts.type != BT_INTEGER) ||
((*upper)->expr_type == EXPR_FUNCTION
@@ -489,6 +506,7 @@ match_array_element_spec (gfc_array_spec *as)
if (!gfc_expr_check_typed (*upper, gfc_current_ns, false))
return AS_UNKNOWN;
+ strip_parens (*upper);
if (((*upper)->expr_type == EXPR_CONSTANT
&& (*upper)->ts.type != BT_INTEGER) ||
((*upper)->expr_type == EXPR_FUNCTION