public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/autopar_devel] PR fortran/95503 - Fix ICE in gfc_is_simply_contiguous, at fortran/expr.c:5844
@ 2020-08-22 22:26 Giuliano Belinassi
  0 siblings, 0 replies; only message in thread
From: Giuliano Belinassi @ 2020-08-22 22:26 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:671987d2790d12fcd998040454413e4424b638ed

commit 671987d2790d12fcd998040454413e4424b638ed
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Jun 11 15:48:56 2020 +0200

    PR fortran/95503 - Fix ICE in gfc_is_simply_contiguous, at fortran/expr.c:5844
    
    The check for assigning a pointer that cannot be determined to be simply
    contiguous at compile time to a contiguous pointer does not need to be
    invoked if the lhs of the assignment is known to have conflicting attributes.
    
    2020-06-11  Harald Anlauf  <anlauf@gmx.de>
    
    gcc/fortran/
            PR fortran/95503
            * expr.c (gfc_check_pointer_assign): Skip contiguity check of rhs
            of pointer assignment if lhs cannot be simply contiguous.
    
    gcc/testsuite/
            PR fortran/95503
            * gfortran.dg/pr95503.f90: New test.

Diff:
---
 gcc/fortran/expr.c                    | 4 +++-
 gcc/testsuite/gfortran.dg/pr95503.f90 | 7 +++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index a9fa03ad153..8daa7bb8d06 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -4346,7 +4346,9 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue,
      contiguous.  Be lenient in the definition of what counts as
      contiguous.  */
 
-  if (lhs_attr.contiguous && !gfc_is_simply_contiguous (rvalue, false, true))
+  if (lhs_attr.contiguous
+      && lhs_attr.dimension > 0
+      && !gfc_is_simply_contiguous (rvalue, false, true))
     gfc_warning (OPT_Wextra, "Assignment to contiguous pointer from "
 		 "non-contiguous target at %L", &rvalue->where);
 
diff --git a/gcc/testsuite/gfortran.dg/pr95503.f90 b/gcc/testsuite/gfortran.dg/pr95503.f90
new file mode 100644
index 00000000000..4a202b405c4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95503.f90
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! PR fortran/95503 - ICE in gfc_is_simply_contiguous
+
+program p
+  complex, target :: a
+  real, pointer, contiguous :: b => a%re ! { dg-error "not an array pointer" }
+end


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-22 22:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22 22:26 [gcc/devel/autopar_devel] PR fortran/95503 - Fix ICE in gfc_is_simply_contiguous, at fortran/expr.c:5844 Giuliano Belinassi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).