summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/move_alloc_8.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/move_alloc_8.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/move_alloc_8.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/move_alloc_8.f90106
1 files changed, 106 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/move_alloc_8.f90 b/gcc/testsuite/gfortran.dg/move_alloc_8.f90
new file mode 100644
index 000000000..2fa530666
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/move_alloc_8.f90
@@ -0,0 +1,106 @@
+! { dg-do compile }
+!
+! PR fortran/50684
+!
+! Module "bug" contributed by Martin Steghöfer.
+!
+
+MODULE BUG
+ TYPE MY_TYPE
+ INTEGER, ALLOCATABLE :: VALUE
+ END TYPE
+CONTAINS
+ SUBROUTINE POINTER_INTENT_IN_BUG_WORKING(POINTER_INTENT_IN_VARIABLE)
+ TYPE(MY_TYPE), POINTER, INTENT(IN) :: POINTER_INTENT_IN_VARIABLE
+ TYPE(MY_TYPE), POINTER :: POINTER_VARIABLE_LOCAL
+ INTEGER, ALLOCATABLE :: LOCAL_VALUE
+
+ POINTER_VARIABLE_LOCAL=>POINTER_INTENT_IN_VARIABLE
+ CALL MOVE_ALLOC(POINTER_VARIABLE_LOCAL%VALUE, LOCAL_VALUE)
+
+ RETURN
+ END SUBROUTINE POINTER_INTENT_IN_BUG_WORKING
+
+ SUBROUTINE POINTER_INTENT_IN_BUG_FAILING(POINTER_INTENT_IN_VARIABLE)
+ TYPE(MY_TYPE), POINTER, INTENT(IN) :: POINTER_INTENT_IN_VARIABLE
+ INTEGER, ALLOCATABLE :: LOCAL_VALUE
+
+ CALL MOVE_ALLOC(POINTER_INTENT_IN_VARIABLE%VALUE, LOCAL_VALUE)
+
+ RETURN
+ END SUBROUTINE POINTER_INTENT_IN_BUG_FAILING
+end module bug
+
+subroutine test1()
+ TYPE MY_TYPE
+ INTEGER, ALLOCATABLE :: VALUE
+ END TYPE
+CONTAINS
+ SUBROUTINE sub (dt)
+ type(MY_TYPE), intent(in) :: dt
+ INTEGER, ALLOCATABLE :: lv
+ call move_alloc(dt%VALUE, lv) ! { dg-error "cannot be INTENT.IN." }
+ END SUBROUTINE
+end subroutine test1
+
+subroutine test2 (x, px)
+ implicit none
+ type t
+ integer, allocatable :: a
+ end type t
+
+ type t2
+ type(t), pointer :: ptr
+ integer, allocatable :: a
+ end type t2
+
+ type(t2), intent(in) :: x
+ type(t2), pointer, intent(in) :: px
+
+ integer, allocatable :: a
+ type(t2), pointer :: ta
+
+ call move_alloc (px, ta) ! { dg-error "cannot be INTENT.IN." }
+ call move_alloc (x%a, a) ! { dg-error "cannot be INTENT.IN." }
+ call move_alloc (x%ptr%a, a) ! OK (3)
+ call move_alloc (px%a, a) ! OK (4)
+ call move_alloc (px%ptr%a, a) ! OK (5)
+end subroutine test2
+
+subroutine test3 (x, px)
+ implicit none
+ type t
+ integer, allocatable :: a
+ end type t
+
+ type t2
+ class(t), pointer :: ptr
+ integer, allocatable :: a
+ end type t2
+
+ type(t2), intent(in) :: x
+ class(t2), pointer, intent(in) :: px
+
+ integer, allocatable :: a
+ class(t2), pointer :: ta
+
+ call move_alloc (px, ta) ! { dg-error "cannot be INTENT.IN." }
+ call move_alloc (x%a, a) ! { dg-error "cannot be INTENT.IN." }
+ call move_alloc (x%ptr%a, a) ! OK (6)
+ call move_alloc (px%a, a) ! OK (7)
+ call move_alloc (px%ptr%a, a) ! OK (8)
+end subroutine test3
+
+subroutine test4()
+ TYPE MY_TYPE
+ INTEGER, ALLOCATABLE :: VALUE
+ END TYPE
+CONTAINS
+ SUBROUTINE sub (dt)
+ CLASS(MY_TYPE), intent(in) :: dt
+ INTEGER, ALLOCATABLE :: lv
+ call move_alloc(dt%VALUE, lv) ! { dg-error "cannot be INTENT.IN." }
+ END SUBROUTINE
+end subroutine test4
+
+! { dg-final { cleanup-modules "bug" } }