public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Sandra Loosemore <sandra@codesourcery.com>
To: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [Fortran, committed] Add testcase for PR95196
Date: Fri, 22 Oct 2021 18:30:00 -0600	[thread overview]
Message-ID: <c2616b25-26b5-6c32-45a2-3af2cf0a9eec@codesourcery.com> (raw)

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

I've committed another testcase from a bugzilla issue that now appears 
to be fixed.

-Sandra

[-- Attachment #2: pr95196.patch --]
[-- Type: text/x-patch, Size: 2594 bytes --]

commit 9a0e34eb45e36d4f90cedb61191fd31da0bab256
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Fri Oct 22 17:22:00 2021 -0700

    Add testcase for PR fortran/95196
    
    2021-10-22  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
    	    Sandra Loosemore  <sandra@codesourcery.com>
    
    	gcc/testsuite/
    
    	PR fortran/95196
    	* gfortran.dg/PR95196.f90: New.

diff --git a/gcc/testsuite/gfortran.dg/PR95196.f90 b/gcc/testsuite/gfortran.dg/PR95196.f90
new file mode 100644
index 0000000..14333e4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/PR95196.f90
@@ -0,0 +1,83 @@
+! { dg-do run }
+
+program rnk_p
+
+  implicit none
+
+  integer, parameter :: n = 10
+  integer, parameter :: m = 5
+  integer, parameter :: s = 4
+  integer, parameter :: l = 4
+  integer, parameter :: u = s+l-1
+  
+  integer :: a(n)
+  integer :: b(n,n)
+  integer :: c(n,n,n)
+  integer :: r(s*s*s)
+  integer :: i
+
+  a = reshape([(i, i=1,n)], [n])
+  b = reshape([(i, i=1,n*n)], [n,n])
+  c = reshape([(i, i=1,n*n*n)], [n,n,n])
+  r(1:s) = a(l:u)
+  call rnk_s(a(l:u), r(1:s))
+  r(1:s*s) = reshape(b(l:u,l:u), [s*s])
+  call rnk_s(b(l:u,l:u), r(1:s*s))
+  r = reshape(c(l:u,l:u,l:u), [s*s*s])
+  call rnk_s(c(l:u,l:7,l:u), r)
+  stop
+  
+contains
+
+  subroutine rnk_s(a, b)
+    integer, intent(in) :: a(..)
+    integer, intent(in) :: b(:)
+    
+    !integer :: l(rank(a)), u(rank(a)) does not work due to Bug 94048 
+    integer, allocatable :: lb(:), ub(:)
+    integer              :: i, j, k, l
+
+    lb = lbound(a)
+    ub = ubound(a)
+    select rank(a)
+    rank(1)
+      if(any(lb/=lbound(a))) stop 11
+      if(any(ub/=ubound(a))) stop 12
+      if(size(a)/=size(b))   stop 13
+      do i = 1, size(a)
+        if(a(i)/=b(i)) stop 14
+      end do
+    rank(2)
+      if(any(lb/=lbound(a))) stop 21
+      if(any(ub/=ubound(a))) stop 22
+      if(size(a)/=size(b))   stop 23
+      k = 0
+      do j = 1, size(a, dim=2)
+        do i = 1, size(a, dim=1)
+          k = k + 1
+          if(a(i,j)/=b(k)) stop 24
+        end do
+      end do
+    rank(3)
+      if(any(lb/=lbound(a))) stop 31
+      if(any(ub/=ubound(a))) stop 32
+      if(size(a)/=size(b))   stop 33
+      l = 0
+      do k = 1, size(a, dim=3)
+        do j = 1, size(a, dim=2)
+          do i = 1, size(a, dim=1)
+            l = l + 1
+            ! print *, a(i,j,k), b(l)
+            if(a(i,j,k)/=b(l)) stop 34
+          end do
+        end do
+      end do
+    rank default
+      stop 171
+    end select
+    deallocate(lb, ub)
+    return
+  end subroutine rnk_s
+  
+end program rnk_p
+

                 reply	other threads:[~2021-10-23  0:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c2616b25-26b5-6c32-45a2-3af2cf0a9eec@codesourcery.com \
    --to=sandra@codesourcery.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).