]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/69739 (ICE during array result, allocatable assignment)
authorPaul Thomas <pault@gcc.gnu.org>
Mon, 6 Nov 2017 11:48:32 +0000 (11:48 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Mon, 6 Nov 2017 11:48:32 +0000 (11:48 +0000)
2017-11-06  Paul Thomas  <pault@gcc.gnu.org>

Backported from trunk
PR fortran/69739
* trans-expr.c (gfc_map_intrinsic_function): Return false for
bounds without the DIM argument instead of ICEing.

2017-11-06  Paul Thomas  <pault@gcc.gnu.org>

Backported from trunk
PR fortran/69739
* gfortran.dg/pr69739.f90: New test.

From-SVN: r254448

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr69739.f90 [new file with mode: 0644]

index ae8a9faa478ce92572a4c8b7adf1e8b1c29a3a3c..bc8c8bbf323ab383731f266e9462f56e7edbf037 100644 (file)
@@ -1,3 +1,10 @@
+2017-11-06  Paul Thomas  <pault@gcc.gnu.org>
+
+       Backported from trunk
+       PR fortran/69739
+       * trans-expr.c (gfc_map_intrinsic_function): Return false for
+       bounds without the DIM argument instead of ICEing.
+
 2017-11-01  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/82796
index c899d639741a7d97bb5ce038bb895e20fe85e204..f1b7bfd9d6b1c1fb41255bfcc3a044748cc4672f 100644 (file)
@@ -4150,9 +4150,7 @@ gfc_map_intrinsic_function (gfc_expr *expr, gfc_interface_mapping *mapping)
       if (arg2 && arg2->expr_type == EXPR_CONSTANT)
        d = mpz_get_si (arg2->value.integer) - 1;
       else
-       /* TODO: If the need arises, this could produce an array of
-          ubound/lbounds.  */
-       gcc_unreachable ();
+       return false;
 
       if (expr->value.function.isym->id == GFC_ISYM_LBOUND)
        {
index 4b8b8e6c1cb5f6e670b510ead3c70075182af317..baab709cee50ed2df559558eb208b3dcc458cd04 100644 (file)
@@ -1,3 +1,9 @@
+2017-11-06  Paul Thomas  <pault@gcc.gnu.org>
+
+       Backported from trunk
+       PR fortran/69739
+       * gfortran.dg/pr69739.f90: New test.
+
 2017-11-01  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/82796
diff --git a/gcc/testsuite/gfortran.dg/pr69739.f90 b/gcc/testsuite/gfortran.dg/pr69739.f90
new file mode 100644 (file)
index 0000000..f5e2359
--- /dev/null
@@ -0,0 +1,39 @@
+! { dg-do run }
+!
+! Test the fix for PR69739 in which the statement
+! R = operate(A, X) caused an ICE.
+!
+! Contributed by John  <jwmwalrus@gmail.com>
+!
+module test
+
+  implicit none
+  type, public :: sometype
+    real :: a    =  0.
+  end type
+contains
+
+  function dosomething(A) result(r)
+    type(sometype), intent(IN) :: A(:,:,:)
+    integer :: N
+    real, allocatable ::   R(:), X(:)
+
+    N = PRODUCT(UBOUND(A))
+    allocate (R(N),X(N))
+    X = [(real(N), N = 1, size(X, 1))]
+    R = operate(A, X)
+  end function
+
+  function operate(A, X)
+    type(sometype), intent(IN) :: A(:,:,:)
+    real, intent(IN) :: X(:)
+    real :: operate(1:PRODUCT(UBOUND(A)))
+
+    operate = x
+  end function
+end module test
+
+  use test
+  type(sometype) :: a(2, 2, 2)
+  if (any(int (dosomething(a)) .ne. [1,2,3,4,5,6])) call abort
+end