From: kargl Date: Tue, 24 Nov 2015 18:58:28 +0000 (+0000) Subject: 2015-11-24 Steven G. Kargl X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=15bb708a2381ae13f24903e20061f90b0cbca178;p=thirdparty%2Fgcc.git 2015-11-24 Steven G. Kargl PR fortran/68486 * simplify.c (gfc_simplify_cshift): Allow all EXPR_*. 2015-11-24 Steven G. Kargl PR fortran/68486 * gfortran.dg/simplify_cshift_3.f90 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230832 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0c812017b7db..adc39bb5b8c0 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2015-11-24 Steven G. Kargl + + PR fortran/68486 + * simplify.c (gfc_simplify_cshift): Allow all EXPR_*. + 2015-11-22 Steven G. Kargl PR fortran/68486 diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index b9c403918959..c699aedc06a5 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -1805,23 +1805,13 @@ gfc_simplify_cshift (gfc_expr *array, gfc_expr *shift, gfc_expr *dim) else dm = 1; - /* Copy array into 'a', simplify it, and then test for a constant array. - An unexpected expr_type causes an ICE. */ - switch (array->expr_type) - { - case EXPR_VARIABLE: - case EXPR_ARRAY: - case EXPR_OP: - a = gfc_copy_expr (array); - gfc_simplify_expr (a, 0); - if (!is_constant_array_expr (a)) - { - gfc_free_expr (a); - return NULL; - } - break; - default: - gcc_unreachable (); + /* Copy array into 'a', simplify it, and then test for a constant array. */ + a = gfc_copy_expr (array); + gfc_simplify_expr (a, 0); + if (!is_constant_array_expr (a)) + { + gfc_free_expr (a); + return NULL; } if (a->rank == 1) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 65a14e188235..5c229ceb4f2f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-11-24 Steven G. Kargl + + PR fortran/68486 + * gfortran.dg/simplify_cshift_3.f90 + 2015-11-24 Paolo Carlini PR c++/68278 diff --git a/gcc/testsuite/gfortran.dg/pr68227.f90 b/gcc/testsuite/gfortran.dg/pr68227.f90 new file mode 100644 index 000000000000..204b1239253d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr68227.f90 @@ -0,0 +1,23 @@ +! { dg-do compile } +! PR fortran/68227 +! Original code contributed by Gerhard Steinmetz +! +! +program p + + type t + end type + + type t2 + type(t), pointer :: a + end type + + type(t), target :: x + type(t2), pointer :: y(:) + integer :: i + integer :: n = 2 + + allocate (y(n)) + forall (i=1:n) y(i)%a = x + +end program p diff --git a/gcc/testsuite/gfortran.dg/simplify_cshift_3.f90 b/gcc/testsuite/gfortran.dg/simplify_cshift_3.f90 new file mode 100644 index 000000000000..26f54c5431f6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/simplify_cshift_3.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +subroutine foo () + real(4), allocatable, save :: tmp (:, :) + real(4), pointer, save :: arr (:, :, :) + integer :: l, m, n + tmp = (cshift(cshift(arr (:,:,l),m,2),n,1)) +end subroutine foo