public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] PR 86830: [8/9 Regression] Contiguous array pointer function result not recognized as contiguous
@ 2018-09-09 20:35 Janus Weil
  2018-09-10  6:54 ` Paul Richard Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Janus Weil @ 2018-09-09 20:35 UTC (permalink / raw)
  To: gfortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 345 bytes --]

Hi all,

the attached patch fixes a rejects-valid regression, where a
type-bound procedure call was not correctly detected to have a
contiguous result. The patch is functionally identical with comment #2
in the PR, with a little bit of cleanup on top of it. It regtests
cleanly on x86_64-linux-gnu. Ok for trunk and gcc-8-branch?

Cheers,
Janus

[-- Attachment #2: pr86830.diff --]
[-- Type: text/x-patch, Size: 2568 bytes --]

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 7cfb94ee115..7e2d6445237 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2018-09-09  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-03  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
 	* simplify.c (gfc_simplify_modulo): Re-arrange code to test whether
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index c5bf822cd24..97792fe32a7 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -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;
 
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0c038441a8c..9e1ab44144f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-09-09  Janus Weil  <janus@gcc.gnu.org>
+
+	PR fortran/86830
+	* gfortran.dg/typebound_call_30.f90: New test case.
+
 2018-09-08  Marek Polacek  <polacek@redhat.com>
 
 	PR c++/87150 - wrong ctor with maybe-rvalue semantics.
diff --git a/gcc/testsuite/gfortran.dg/typebound_call_30.f90 b/gcc/testsuite/gfortran.dg/typebound_call_30.f90
new file mode 100644
index 00000000000..3ca63bd2a95
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/typebound_call_30.f90
@@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, Fortran] PR 86830: [8/9 Regression] Contiguous array pointer function result not recognized as contiguous
  2018-09-09 20:35 [Patch, Fortran] PR 86830: [8/9 Regression] Contiguous array pointer function result not recognized as contiguous Janus Weil
@ 2018-09-10  6:54 ` Paul Richard Thomas
  2018-09-11  6:35   ` Janus Weil
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Richard Thomas @ 2018-09-10  6:54 UTC (permalink / raw)
  To: Janus Weil; +Cc: gfortran, gcc-patches

Hi Janus,

That's fine - OK for both branches.

Thanks

Paul


On 9 September 2018 at 21:34, Janus Weil <janus@gcc.gnu.org> wrote:
> Hi all,
>
> the attached patch fixes a rejects-valid regression, where a
> type-bound procedure call was not correctly detected to have a
> contiguous result. The patch is functionally identical with comment #2
> in the PR, with a little bit of cleanup on top of it. It regtests
> cleanly on x86_64-linux-gnu. Ok for trunk and gcc-8-branch?
>
> Cheers,
> Janus



-- 
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, Fortran] PR 86830: [8/9 Regression] Contiguous array pointer function result not recognized as contiguous
  2018-09-10  6:54 ` Paul Richard Thomas
@ 2018-09-11  6:35   ` Janus Weil
  0 siblings, 0 replies; 3+ messages in thread
From: Janus Weil @ 2018-09-11  6:35 UTC (permalink / raw)
  To: Paul Thomas; +Cc: gfortran, gcc-patches

Am Mo., 10. Sep. 2018 um 08:54 Uhr schrieb Paul Richard Thomas
<paul.richard.thomas@gmail.com>:
>
> Hi Janus,
>
> That's fine - OK for both branches.

Committed to trunk as r264201. Will do 8-branch soon.

Thanks for the review,
Janus


> On 9 September 2018 at 21:34, Janus Weil <janus@gcc.gnu.org> wrote:
> > Hi all,
> >
> > the attached patch fixes a rejects-valid regression, where a
> > type-bound procedure call was not correctly detected to have a
> > contiguous result. The patch is functionally identical with comment #2
> > in the PR, with a little bit of cleanup on top of it. It regtests
> > cleanly on x86_64-linux-gnu. Ok for trunk and gcc-8-branch?
> >
> > Cheers,
> > Janus
>
>
>
> --
> "If you can't explain it simply, you don't understand it well enough"
> - Albert Einstein

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-11  6:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-09 20:35 [Patch, Fortran] PR 86830: [8/9 Regression] Contiguous array pointer function result not recognized as contiguous Janus Weil
2018-09-10  6:54 ` Paul Richard Thomas
2018-09-11  6:35   ` Janus Weil

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).