aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/frontend-passes.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fortran/frontend-passes.c')
-rw-r--r--gcc/fortran/frontend-passes.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c
index b6f6b4c..cabfd28 100644
--- a/gcc/fortran/frontend-passes.c
+++ b/gcc/fortran/frontend-passes.c
@@ -62,7 +62,7 @@ gfc_namespace *current_ns;
void
gfc_run_passes (gfc_namespace *ns)
{
- if (optimize)
+ if (gfc_option.flag_frontend_optimize)
{
expr_size = 20;
expr_array = XNEWVEC(gfc_expr **, expr_size);
@@ -283,6 +283,20 @@ create_var (gfc_expr * e)
return result;
}
+/* Warn about function elimination. */
+
+static void
+warn_function_elimination (gfc_expr *e)
+{
+ if (e->expr_type != EXPR_FUNCTION)
+ return;
+ if (e->value.function.esym)
+ gfc_warning ("Removing call to function '%s' at %L",
+ e->value.function.esym->name, &(e->where));
+ else if (e->value.function.isym)
+ gfc_warning ("Removing call to function '%s' at %L",
+ e->value.function.isym->name, &(e->where));
+}
/* Callback function for the code walker for doing common function
elimination. This builds up the list of functions in the expression
and goes through them to detect duplicates, which it then replaces
@@ -315,6 +329,10 @@ cfe_expr_0 (gfc_expr **e, int *walk_subtrees,
{
if (newvar == NULL)
newvar = create_var (*(expr_array[i]));
+
+ if (gfc_option.warn_function_elimination)
+ warn_function_elimination (*(expr_array[j]));
+
gfc_free (*(expr_array[j]));
*(expr_array[j]) = gfc_copy_expr (newvar);
}