re PR fortran/91566 (ICE in gfc_constructor_copy, at fortran/constructor.c:103)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 13 Sep 2019 20:19:40 +0000 (20:19 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 13 Sep 2019 20:19:40 +0000 (20:19 +0000)
2019-09-13  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/91566
* simplify.c (gfc_simplify_merge): Need to simplify expression
after insertation of parenthesis.

2019-09-13  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/91566
* gfortran.dg/pr91566.f90:

From-SVN: r275704

gcc/fortran/ChangeLog
gcc/fortran/simplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr91566.f90 [new file with mode: 0644]

index a396418118d24bdcb8325278b3aa3c271420d499..6f2ba754726b0b94a3597311430795cbcc8189e8 100644 (file)
@@ -1,3 +1,9 @@
+2019-09-13  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/91566
+       * simplify.c (gfc_simplify_merge): Need to simplify expression
+       after insertation of parenthesis.
+
 2019-09-13  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        PR fortran/91716
index 023eedb749cbe2c453a70e5e94bacdfcf3a31d8a..3d2fc0d956fffabda9aa19733ea2b7a6c6a005e1 100644 (file)
@@ -4780,8 +4780,13 @@ gfc_simplify_merge (gfc_expr *tsource, gfc_expr *fsource, gfc_expr *mask)
   gfc_constructor *tsource_ctor, *fsource_ctor, *mask_ctor;
 
   if (mask->expr_type == EXPR_CONSTANT)
-    return gfc_get_parentheses (gfc_copy_expr (mask->value.logical
-                                              ? tsource : fsource));
+    {
+      result = gfc_copy_expr (mask->value.logical ? tsource : fsource);
+      /* Parenthesis is needed to get lower bounds of 1.  */
+      result = gfc_get_parentheses (result);
+      gfc_simplify_expr (result, 1);
+      return result;
+    }
 
   if (!mask->rank || !is_constant_array_expr (mask)
       || !is_constant_array_expr (tsource) || !is_constant_array_expr (fsource))
index 62766c215566101078cd362546ecffab57bbb360..8bb7e7af3de55ead24a19009f234e38d381ae658 100644 (file)
@@ -1,3 +1,8 @@
+2019-09-13  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/91566
+       * gfortran.dg/pr91566.f90:
+
 2019-09-13  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        PR fortran/91716
diff --git a/gcc/testsuite/gfortran.dg/pr91566.f90 b/gcc/testsuite/gfortran.dg/pr91566.f90
new file mode 100644 (file)
index 0000000..fdb35b4
--- /dev/null
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! Code contributed by Gerhard Steinmetz
+program p
+   call q
+   call r
+end program p
+
+subroutine q
+   print *, -merge([3,4], 0, [.false.,.true.])
+end
+
+subroutine r
+   print *, 2 + merge([3,4], 0, [.false.,.true.])
+end