summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/interface_assignment_2.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/interface_assignment_2.f90
downloadcbb-gcc-4.6.4-upstream.tar.bz2
cbb-gcc-4.6.4-upstream.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/interface_assignment_2.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/interface_assignment_2.f9049
1 files changed, 49 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/interface_assignment_2.f90 b/gcc/testsuite/gfortran.dg/interface_assignment_2.f90
new file mode 100644
index 000000000..8d7484b31
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/interface_assignment_2.f90
@@ -0,0 +1,49 @@
+! { dg-do run }
+! Checks the fix for PR32842, in which the interface assignment
+! below caused a segfault. This testcase is reduced from vst_2.f95
+! in the iso_varying_string testsuite, from Lawrie Schonfelder
+!
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+!
+module iso_varying_string
+ implicit none
+ integer, parameter :: GET_BUFFER_LEN = 256
+ type varying_string
+ character(LEN=1), dimension(:), allocatable :: chars
+ end type varying_string
+ interface assignment(=)
+ module procedure op_assign_VS_CH
+ end interface assignment(=)
+contains
+ elemental subroutine op_assign_VS_CH (var, expr)
+ type(varying_string), intent(out) :: var
+ character(LEN=*), intent(in) :: expr
+ var = var_str(expr)
+ end subroutine op_assign_VS_CH
+ elemental function var_str (chr) result (string)
+ character(LEN=*), intent(in) :: chr
+ type(varying_string) :: string
+ integer :: length
+ integer :: i_char
+ length = LEN(chr)
+ ALLOCATE(string%chars(length))
+ forall(i_char = 1:length)
+ string%chars(i_char) = chr(i_char:i_char)
+ end forall
+ end function var_str
+end module iso_varying_string
+
+PROGRAM VST_2
+ USE ISO_VARYING_STRING
+ IMPLICIT NONE
+ CHARACTER(LEN=5) :: char_arb(2)
+ CHARACTER(LEN=1) :: char_elm(10)
+ equivalence (char_arb, char_elm)
+ type(VARYING_STRING) :: str_ara(2)
+ char_arb(1)= "Hello"
+ char_arb(2)= "World"
+ str_ara = char_arb
+ if (any (str_ara(1)%chars(1:5) .ne. char_elm(1:5))) call abort
+ if (any (str_ara(2)%chars(1:5) .ne. char_elm(6:10))) call abort
+END PROGRAM VST_2
+! { dg-final { cleanup-modules "iso_varying_string" } }