Commit 567a6e1c by Paul Thomas

re PR fortran/52162 (Bogus -fcheck=bounds with realloc on assignment to unallocated LHS)

2018-01-13  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/52162
	* trans-expr.c (gfc_trans_scalar_assign): Flag is_alloc_lhs if
	the rhs expression is neither an elemental nor a conversion
	function.

	PR fortran/83622
	* trans-array.c (is_pointer_array): Remove unconditional return
	of false for -fopenmp.

2018-01-13  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/52162
	* gfortran.dg/bounds_check_19.f90 : New test.

From-SVN: r256607
parent 700b62cc
2018-01-13 Paul Thomas <pault@gcc.gnu.org>
PR fortran/52162
* trans-expr.c (gfc_trans_scalar_assign): Flag is_alloc_lhs if
the rhs expression is neither an elemental nor a conversion
function.
PR fortran/83622
* trans-array.c (is_pointer_array): Remove unconditional return
of false for -fopenmp.
2018-01-13 Thomas Koenig <tkoenig@gcc.gnu.org> 2018-01-13 Thomas Koenig <tkoenig@gcc.gnu.org>
<emsr@gcc.gnu.org> <emsr@gcc.gnu.org>
......
...@@ -786,9 +786,6 @@ gfc_add_ss_to_loop (gfc_loopinfo * loop, gfc_ss * head) ...@@ -786,9 +786,6 @@ gfc_add_ss_to_loop (gfc_loopinfo * loop, gfc_ss * head)
static bool static bool
is_pointer_array (tree expr) is_pointer_array (tree expr)
{ {
if (flag_openmp)
return false;
if (expr == NULL_TREE if (expr == NULL_TREE
|| !GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (expr)) || !GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (expr))
|| GFC_CLASS_TYPE_P (TREE_TYPE (expr))) || GFC_CLASS_TYPE_P (TREE_TYPE (expr)))
......
...@@ -9924,9 +9924,12 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, ...@@ -9924,9 +9924,12 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
/* Walk the lhs. */ /* Walk the lhs. */
lss = gfc_walk_expr (expr1); lss = gfc_walk_expr (expr1);
if (gfc_is_reallocatable_lhs (expr1) if (gfc_is_reallocatable_lhs (expr1)
&& !(expr2->expr_type == EXPR_FUNCTION && !(expr2->expr_type == EXPR_FUNCTION
&& expr2->value.function.isym != NULL)) && expr2->value.function.isym != NULL
&& !(expr2->value.function.isym->elemental
|| expr2->value.function.isym->conversion)))
lss->is_alloc_lhs = 1; lss->is_alloc_lhs = 1;
rss = NULL; rss = NULL;
if ((expr1->ts.type == BT_DERIVED) if ((expr1->ts.type == BT_DERIVED)
......
2018-01-13 Paul Thomas <pault@gcc.gnu.org>
PR fortran/52162
* gfortran.dg/bounds_check_19.f90 : New test.
2018-01-12 Jakub Jelinek <jakub@redhat.com> 2018-01-12 Jakub Jelinek <jakub@redhat.com>
* gcc.target/powerpc/float128-hw7.c: Use scan-assembler-times * gcc.target/powerpc/float128-hw7.c: Use scan-assembler-times
......
! { dg-do run }
! { dg-options "-fbounds-check" }
!
! Test the fix for PR52162 in which the elemental and conversion
! intrinsics in lines 14 and 19 would cause the bounds check to fail.
!
! Contributed by Dominique d'Humieres <dominiq@lps.ens.fr>
!
integer(4), allocatable :: a(:)
integer(8), allocatable :: b(:)
real, allocatable :: c(:)
allocate (b(7:11), source = [7_8,8_8,9_8,10_8,11_8])
a = b ! Implicit conversion
if (lbound (a, 1) .ne. lbound(b, 1)) call abort
if (ubound (a, 1) .ne. ubound(b, 1)) call abort
c = sin(real(b(9:11))/100_8) ! Elemental intrinsic
if ((ubound(c, 1) - lbound(c, 1)) .ne. 2) call abort
if (any (nint(asin(c)*100.0) .ne. b(9:11))) call abort
deallocate (a, b, c)
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment