]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/91566 (ICE in gfc_constructor_copy, at fortran/constructor.c:103)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 14 Sep 2019 16:39:41 +0000 (16:39 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 14 Sep 2019 16:39:41 +0000 (16:39 +0000)
2019-09-14  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-14  Steven G. Kargl  <kargl@gcc.gnu.org>

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

From-SVN: r275715

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

index 3ff20a25f6f73e0dae8fd568efe29d6be98461cd..d07ad3025c7e0a398818d137f7c1cd9336ef4142 100644 (file)
@@ -1,3 +1,9 @@
+2019-09-14  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-14  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/91642
index ee159b19ee1940ae38d38efeab5543a40d7f7954..30924c1f049dc292c935710466cee274e4fd114b 100644 (file)
@@ -4808,8 +4808,12 @@ 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);
+      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 f5d620a9ce0b4d37b9b99f8e1df9252269456197..38a599068e93b0d7669cb6a33d85e12342f212d0 100644 (file)
@@ -1,3 +1,8 @@
+2019-09-14  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/91566
+       * gfortran.dg/pr91566.f90: New test.
+
 2019-09-14  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/91642
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