https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114012

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |anlauf at gcc dot 
gnu.org

--- Comment #2 from anlauf at gcc dot gnu.org ---
The following patch fixes the redundant procedure invocation:

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 118dfd7c9b2..581b3786dea 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -6691,6 +6692,10 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
                            {
                              tree efield;

+                             /* Evaluate arguments just once.  */
+                             if (e->expr_type != EXPR_VARIABLE)
+                               parmse.expr = save_expr (parmse.expr);
+
                              /* Set the _data field.  */
                              tmp = gfc_class_data_get (var);
                              efield = fold_convert (TREE_TYPE (tmp),

Reply via email to