re PR fortran/86830 (Contiguous array pointer function result not recognized as conti...
authorJanus Weil <janus@gcc.gnu.org>
Tue, 11 Sep 2018 06:33:39 +0000 (08:33 +0200)
committerJanus Weil <janus@gcc.gnu.org>
Tue, 11 Sep 2018 06:33:39 +0000 (08:33 +0200)
fix PR 86830

2018-09-11  Janus Weil  <janus@gcc.gnu.org>

PR fortran/86830
* expr.c (gfc_is_simply_contiguous): Handle type-bound procedure calls
with non-polymorphic objects.

2018-09-11  Janus Weil  <janus@gcc.gnu.org>

PR fortran/86830
* gfortran.dg/typebound_call_30.f90: New test case.

From-SVN: r264201

gcc/fortran/ChangeLog
gcc/fortran/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/typebound_call_30.f90 [new file with mode: 0644]

index 97d97e845bd27c4e82623e08743704b03f0f47bd..64acb7a273572781ac57aebaf863f2600691afc8 100644 (file)
@@ -1,3 +1,9 @@
+2018-09-11  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/86830
+       * expr.c (gfc_is_simply_contiguous): Handle type-bound procedure calls
+       with non-polymorphic objects.
+
 2018-09-10  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/85395
index c5bf822cd24ddb3a2ba53df678f00c90514ed780..97792fe32a7a9c8ab862ac6424f84f49b5dad388 100644 (file)
@@ -5385,16 +5385,13 @@ gfc_is_simply_contiguous (gfc_expr *expr, bool strict, bool permit_element)
        return expr->value.function.esym->result->attr.contiguous;
       else
        {
-         /* We have to jump through some hoops if this is a vtab entry.  */
-         gfc_symbol *s;
-         gfc_ref *r, *rc;
-
-         s = expr->symtree->n.sym;
-         if (s->ts.type != BT_CLASS)
+         /* Type-bound procedures.  */
+         gfc_symbol *s = expr->symtree->n.sym;
+         if (s->ts.type != BT_CLASS && s->ts.type != BT_DERIVED)
            return false;
 
-         rc = NULL;
-         for (r = expr->ref; r; r = r->next)
+         gfc_ref *rc = NULL;
+         for (gfc_ref *r = expr->ref; r; r = r->next)
            if (r->type == REF_COMPONENT)
              rc = r;
 
index dd0f878abc59384ce8652f535ad10ed1b33fa5cb..2af919b99fe263f0e21b58863e6053999d635045 100644 (file)
@@ -1,3 +1,8 @@
+2018-09-11  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/86830
+       * gfortran.dg/typebound_call_30.f90: New test case.
+
 2018-09-10  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/85395
diff --git a/gcc/testsuite/gfortran.dg/typebound_call_30.f90 b/gcc/testsuite/gfortran.dg/typebound_call_30.f90
new file mode 100644 (file)
index 0000000..3ca63bd
--- /dev/null
@@ -0,0 +1,32 @@
+! { dg-do compile }
+!
+! PR 86830: [8/9 Regression] Contiguous array pointer function result not recognized as contiguous
+!
+! Contributed by <only_for_nouse@gmx.de>
+
+module m
+  implicit none
+
+  type :: t1
+   contains
+     procedure :: get_ptr
+  end type
+
+  type :: t2
+     class(t1), allocatable :: c
+  end type
+
+contains
+
+  function get_ptr(this)
+    class(t1) :: this
+    real, dimension(:), contiguous, pointer :: get_ptr
+  end function
+
+  subroutine test()
+    real, dimension(:), contiguous, pointer:: ptr
+    type(t2) :: x
+    ptr => x%c%get_ptr()
+  end subroutine
+
+end module