[Patch, fortran] PR94246 - [9/10 Regression] valgrind error for ./gfortran.dg/bessel_5.f90 since r9-1566-g87c789f1c0b2df41

Paul Richard Thomas paul.richard.thomas@gmail.com
Thu Mar 26 11:20:42 GMT 2020


This turned out to be relatively trivial, following a fair amount of
head scratching:-(

Regtests on FC31/x64_86 - OK for both branches?

Paul

2020-03-26  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/94246
    * expr.c (scalarize_intrinsic_call): Remove the error checking.
    Make a copy of the expression to be simplified and only replace
    the original if the simplification succeeds.

2020-03-26  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/94246
    * gfortran.dg/bessel_5_redux.f90 : New test.

diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 79e00b4112a..1106341df91 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -2296,9 +2296,8 @@ scalarize_intrinsic_call (gfc_expr *e, bool init_flag)
   gfc_constructor_base ctor;
   gfc_constructor *args[5] = {};  /* Avoid uninitialized warnings.  */
   gfc_constructor *ci, *new_ctor;
-  gfc_expr *expr, *old;
+  gfc_expr *expr, *old, *p;
   int n, i, rank[5], array_arg;
-  int errors = 0;

   if (e == NULL)
     return false;
@@ -2366,8 +2365,6 @@ scalarize_intrinsic_call (gfc_expr *e, bool init_flag)
       n++;
     }

-  gfc_get_errors (NULL, &errors);
-
   /* Using the array argument as the master, step through the array
      calling the function for each element and advancing the array
      constructors together.  */
@@ -2401,8 +2398,12 @@ scalarize_intrinsic_call (gfc_expr *e, bool init_flag)
       /* Simplify the function calls.  If the simplification fails, the
      error will be flagged up down-stream or the library will deal
      with it.  */
-      if (errors == 0)
-    gfc_simplify_expr (new_ctor->expr, 0);
+      p = gfc_copy_expr (new_ctor->expr);
+
+      if (!gfc_simplify_expr (p, init_flag))
+    gfc_free_expr (p);
+      else
+    gfc_replace_expr (new_ctor->expr, p);

       for (i = 0; i < n; i++)
     if (args[i])
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bessel_5_redux.f90
Type: text/x-fortran
Size: 1896 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20200326/bd8f2660/attachment.bin>


More information about the Fortran mailing list