diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2017-10-07 11:48:28 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2017-10-07 11:48:28 +0000 |
commit | 5abde510b7e2864c18144c658c4a5d26f8dc12d3 (patch) | |
tree | 2b203f2950f7fe7ca5f8344d3962aa131b60d08a /gcc | |
parent | a4792d44311895bef287eb9632a1d4936ca8eafb (diff) | |
download | gcc-5abde510b7e2864c18144c658c4a5d26f8dc12d3.zip gcc-5abde510b7e2864c18144c658c4a5d26f8dc12d3.tar.gz gcc-5abde510b7e2864c18144c658c4a5d26f8dc12d3.tar.bz2 |
re PR fortran/49232 (Pointer assignment of stride to CONTIGUOUS pointer not diagnosed as invalid)
2017-10-07 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/49232
* expr.c (gfc_check_pointer_assign): Error
for non-contiguous rhs.
2017-10-07 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/49232
* gfortran.dg/contiguous_4.f90: New test.
From-SVN: r253509
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/expr.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/contiguous_4.f90 | 19 |
4 files changed, 38 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 8d3e35f..67a5b02 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,11 @@ 2017-10-07 Thomas Koenig <tkoenig@gcc.gnu.org> + PR fortran/49232 + * expr.c (gfc_check_pointer_assign): Error + for non-contiguous rhs. + +2017-10-07 Thomas Koenig <tkoenig@gcc.gnu.org> + * gfortran.h (async_io_dt): Add external reference. * io.c (async_io_dt): Add variable. (compare_to_allowed_values): Add prototyte. Add optional argument diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index bfbb19e..bc05db2 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -3851,6 +3851,14 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue) } } + /* Error for assignments of contiguous pointers to targets which is not + contiguous. Be lenient in the definition of what counts as + congiguous. */ + + if (lhs_attr.contiguous && !gfc_is_simply_contiguous (rvalue, false, true)) + gfc_error ("Assignment to contiguous pointer from non-contiguous " + "target at %L", &rvalue->where); + /* Warn if it is the LHS pointer may lives longer than the RHS target. */ if (warn_target_lifetime && rvalue->expr_type == EXPR_VARIABLE diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e48f743..319518c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-07 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/49232 + * gfortran.dg/contiguous_4.f90: New test. + 2017-10-06 Paolo Carlini <paolo.carlini@oracle.com> PR c++/66690 diff --git a/gcc/testsuite/gfortran.dg/contiguous_4.f90 b/gcc/testsuite/gfortran.dg/contiguous_4.f90 new file mode 100644 index 0000000..b05dcfb --- /dev/null +++ b/gcc/testsuite/gfortran.dg/contiguous_4.f90 @@ -0,0 +1,19 @@ +! { dg-do compile } +program cont_01_neg + implicit none + real, pointer, contiguous :: r(:) + real, pointer, contiguous :: r2(:,:) + real, target :: x(45) + real, target :: x2(5,9) + integer :: i + integer :: n=1 + + x = (/ (real(i),i=1,45) /) + x2 = reshape(x,shape(x2)) + r => x(::3) ! { dg-error "Assignment to contiguous pointer" } + r2 => x2(2:,:) ! { dg-error "Assignment to contiguous pointer" } + r2 => x2(:,2:3) + r => x2(2:3,1) + r => x(::1) + r => x(::n) ! { dg-error "Assignment to contiguous pointer" } +end program |