diff options
author | Cesar Philippidis <cesar@codesourcery.com> | 2018-10-08 07:04:45 -0700 |
---|---|---|
committer | Cesar Philippidis <cesar@gcc.gnu.org> | 2018-10-08 07:04:45 -0700 |
commit | ed9984a03070a1be7c5b3815e410e6269ab721e4 (patch) | |
tree | 515d6e71de92b43e587a9721bf2602a68d770d96 | |
parent | 49108562af2b2c0b96090ed0c6b4abbabb3f9080 (diff) | |
download | gcc-ed9984a03070a1be7c5b3815e410e6269ab721e4.zip gcc-ed9984a03070a1be7c5b3815e410e6269ab721e4.tar.gz gcc-ed9984a03070a1be7c5b3815e410e6269ab721e4.tar.bz2 |
[Fortran] Disable "Assignment to contiguous pointer from non-contiguous target" error
gcc/fortran/
* expr.c (gfc_check_pointer_assign): Demote "Assignment to
contiguous pointer from non-contiguous target" to a warning.
gcc/testsuite/
* gfortran.dg/contiguous_4.f90: Adjust.
* gfortran.dg/contiguous_4.f90: New test.
From-SVN: r264928
-rw-r--r-- | gcc/fortran/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fortran/expr.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/contiguous_4.f90 | 6 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/contiguous_7.f90 | 24 |
5 files changed, 40 insertions, 6 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c4c14f8..6fc3857 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2018-10-08 Cesar Philippidis <cesar@codesourcery.com> + + * expr.c (gfc_check_pointer_assign): Demote "Assignment to + contiguous pointer from non-contiguous target" to a warning. + 2018-10-08 Paul Thomas <pault@gcc.gnu.org> PR fortran/86372 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 3315bb8..1cfda5f 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -3957,13 +3957,13 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue) } } - /* Error for assignments of contiguous pointers to targets which is not + /* Warn for assignments of contiguous pointers to targets which is not contiguous. Be lenient in the definition of what counts as contiguous. */ 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); + gfc_warning (OPT_Wextra, "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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 28e84d2..9d495d4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-10-08 Cesar Philippidis <cesar@codesourcery.com> + + * gfortran.dg/contiguous_4.f90: Adjust. + * gfortran.dg/contiguous_4.f90: New test. + 2018-10-08 Paul Thomas <pault@gcc.gnu.org> PR fortran/86372 diff --git a/gcc/testsuite/gfortran.dg/contiguous_4.f90 b/gcc/testsuite/gfortran.dg/contiguous_4.f90 index b05dcfb..874ef8b 100644 --- a/gcc/testsuite/gfortran.dg/contiguous_4.f90 +++ b/gcc/testsuite/gfortran.dg/contiguous_4.f90 @@ -10,10 +10,10 @@ program cont_01_neg 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" } + r => x(::3) + r2 => x2(2:,:) r2 => x2(:,2:3) r => x2(2:3,1) r => x(::1) - r => x(::n) ! { dg-error "Assignment to contiguous pointer" } + r => x(::n) end program diff --git a/gcc/testsuite/gfortran.dg/contiguous_7.f90 b/gcc/testsuite/gfortran.dg/contiguous_7.f90 new file mode 100644 index 0000000..cccc89f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/contiguous_7.f90 @@ -0,0 +1,24 @@ +! { dg-do compile } +! { dg-additional-options "-Wextra" } +! +! Ensure that contiguous pointers pointing to noncontiguous pointers +! to array results in a warning with -Wextra. + +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-warning "ssignment to contiguous pointer from non-contiguous target" } + r2 => x2(2:,:) ! { dg-warning "ssignment to contiguous pointer from non-contiguous target" } + r2 => x2(:,2:3) + r => x2(2:3,1) + r => x(::1) + r => x(::n) ! { dg-warning "ssignment to contiguous pointer from non-contiguous target" } +end program |