+2016-12-13 Janus Weil <janus@gcc.gnu.org>
+
+ PR fortran/78798
+ * gfortran.h (gfc_is_constant_expr, gfc_is_formal_arg,
+ gfc_is_compile_time_shape): Return bool instead of int.
+ * array.c (gfc_is_compile_time_shape): Ditto.
+ * expr.c (gfc_is_constant_expr): Ditto.
+ * resolve.c (gfc_is_formal_arg): Ditto. Make formal_arg_flag bool.
+
2016-12-13 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/77785
/* Find out if an array shape is known at compile time. */
-int
+bool
gfc_is_compile_time_shape (gfc_array_spec *as)
{
- int i;
-
if (as->type != AS_EXPLICIT)
- return 0;
+ return false;
- for (i = 0; i < as->rank; i++)
+ for (int i = 0; i < as->rank; i++)
if (!gfc_is_constant_expr (as->lower[i])
|| !gfc_is_constant_expr (as->upper[i]))
- return 0;
+ return false;
- return 1;
+ return true;
}
/* Determine if an expression is constant in the sense of F08:7.1.12.
- * This function expects that the expression has already been simplified.
- * FIXME: Return a bool, not an int. */
+ * This function expects that the expression has already been simplified. */
-int
+bool
gfc_is_constant_expr (gfc_expr *e)
{
gfc_constructor *c;
gfc_actual_arglist *arg;
if (e == NULL)
- return 1;
+ return true;
switch (e->expr_type)
{
|| gfc_is_constant_expr (e->value.op.op2)));
case EXPR_VARIABLE:
- return 0;
+ return false;
case EXPR_FUNCTION:
case EXPR_PPC:
{
for (arg = e->value.function.actual; arg; arg = arg->next)
if (!gfc_is_constant_expr (arg->expr))
- return 0;
+ return false;
}
if (e->value.function.isym
|| e->value.function.isym->pure
|| e->value.function.isym->inquiry
|| e->value.function.isym->transformational))
- return 1;
+ return true;
- return 0;
+ return false;
case EXPR_CONSTANT:
case EXPR_NULL:
- return 1;
+ return true;
case EXPR_SUBSTRING:
return e->ref == NULL || (gfc_is_constant_expr (e->ref->u.ss.start)
for (; c; c = gfc_constructor_next (c))
if (!gfc_is_constant_expr (c->expr))
- return 0;
+ return false;
- return 1;
+ return true;
default:
gfc_internal_error ("gfc_is_constant_expr(): Unknown expression type");
- return 0;
+ return false;
}
}
gfc_expr *gfc_build_conversion (gfc_expr *);
void gfc_free_ref_list (gfc_ref *);
void gfc_type_convert_binary (gfc_expr *, int);
-int gfc_is_constant_expr (gfc_expr *);
+bool gfc_is_constant_expr (gfc_expr *);
bool gfc_simplify_expr (gfc_expr *, int);
int gfc_has_vector_index (gfc_expr *);
bool find_forall_index (gfc_expr *, gfc_symbol *, int);
bool gfc_resolve_index (gfc_expr *, int);
bool gfc_resolve_dim_arg (gfc_expr *);
-int gfc_is_formal_arg (void);
+bool gfc_is_formal_arg (void);
void gfc_resolve_substring_charlen (gfc_expr *);
match gfc_iso_c_sub_interface(gfc_code *, gfc_symbol *);
gfc_expr *gfc_expr_to_initialize (gfc_expr *);
tree gfc_conv_array_initializer (tree type, gfc_expr *);
bool spec_size (gfc_array_spec *, mpz_t *);
bool spec_dimen_size (gfc_array_spec *, int, mpz_t *);
-int gfc_is_compile_time_shape (gfc_array_spec *);
+bool gfc_is_compile_time_shape (gfc_array_spec *);
bool gfc_ref_dimen_size (gfc_array_ref *, int dimen, mpz_t *, mpz_t *);
static int omp_workshare_flag;
-/* Nonzero if we are processing a formal arglist. The corresponding function
+/* True if we are processing a formal arglist. The corresponding function
resets the flag each time that it is read. */
-static int formal_arg_flag = 0;
+static bool formal_arg_flag = false;
/* True if we are resolving a specification expression. */
static bool specification_expr = false;
static bool inquiry_argument = false;
-int
+bool
gfc_is_formal_arg (void)
{
return formal_arg_flag;
sym->attr.always_explicit = 1;
}
- formal_arg_flag = 1;
+ formal_arg_flag = true;
for (f = proc->formal; f; f = f->next)
{
}
}
}
- formal_arg_flag = 0;
+ formal_arg_flag = false;
}
an error for host associated variables in the specification
expression for an array_valued function. */
if (sym->attr.function && sym->as)
- formal_arg_flag = 1;
+ formal_arg_flag = true;
saved_specification_expr = specification_expr;
specification_expr = true;
gfc_resolve_array_spec (sym->as, check_constant);
specification_expr = saved_specification_expr;
- formal_arg_flag = 0;
+ formal_arg_flag = false;
/* Resolve formal namespaces. */
if (sym->formal_ns && sym->formal_ns != gfc_current_ns