summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/proc_decl_17.f90
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gfortran.dg/proc_decl_17.f90
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gfortran.dg/proc_decl_17.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/proc_decl_17.f9068
1 files changed, 68 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/proc_decl_17.f90 b/gcc/testsuite/gfortran.dg/proc_decl_17.f90
new file mode 100644
index 000000000..858022a43
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/proc_decl_17.f90
@@ -0,0 +1,68 @@
+! { dg-do run }
+!
+! PR 36322/36463
+!
+! Original code by James Van Buskirk.
+! Modified by Janus Weil <janus@gcc.gnu.org>
+
+module m
+
+ use ISO_C_BINDING
+
+ character, allocatable, save :: my_message(:)
+
+ abstract interface
+ function abs_fun(x)
+ use ISO_C_BINDING
+ import my_message
+ integer(C_INT) x(:)
+ character(size(my_message),C_CHAR) abs_fun(size(x))
+ end function abs_fun
+ end interface
+
+contains
+
+ function foo(y)
+ implicit none
+ integer(C_INT) :: y(:)
+ character(size(my_message),C_CHAR) :: foo(size(y))
+ integer i,j
+ do i=1,size(y)
+ do j=1,size(my_message)
+ foo(i)(j:j) = achar(iachar(my_message(j))+y(i))
+ end do
+ end do
+ end function
+
+ subroutine check(p,a)
+ integer a(:)
+ procedure(abs_fun) :: p
+ character(size(my_message),C_CHAR) :: c(size(a))
+ integer k,l,m
+ c = p(a)
+ m=iachar('a')
+ do k=1,size(a)
+ do l=1,size(my_message)
+ if (c(k)(l:l) /= achar(m)) call abort()
+ m = m + 1
+ end do
+ end do
+ end subroutine
+
+end module
+
+program prog
+
+use m
+
+integer :: i(4) = (/0,6,12,18/)
+
+allocate(my_message(1:6))
+
+my_message = (/'a','b','c','d','e','f'/)
+
+call check(foo,i)
+
+end program
+
+! { dg-final { cleanup-modules "m" } }