Debian Codegraph @

gcc/testsuite/gfortran.dg/select_contiguous.f90

raw
1 ! { dg-do compile }
2 ! { dg-options "-O2 -Wextra -fdump-tree-optimized" }
3 !
4 ! PR fortran/122709 - bogus warning for contiguous pointer assignment
5 ! to select type target
6 !
7 ! Contributed by <mscfd at gmx dot net>
8
9 module sc_mod
10 implicit none
11 public
12
13 type :: t
14 integer :: i = 0
15 end type t
16
17 type :: s
18 class(t), dimension(:), contiguous, pointer :: p => null()
19 end type s
20
21 contains
22
23 subroutine foo(x)
24 class(s), intent(in) :: x
25 type(t), dimension(:), contiguous, pointer :: q
26 select type (p_ => x%p)
27 type is (t)
28 q => p_
29 if (.not. is_contiguous(x%p)) stop 1
30 if (.not. is_contiguous(p_)) stop 2 ! Should get optimized out
31 if (.not. is_contiguous(q)) stop 3
32 write(*,*) 'is contiguous: ', is_contiguous(x%p), &
33 is_contiguous(p_), is_contiguous(q)
34 end select
35 end subroutine foo
36
37 end module sc_mod
38
39 program select_contiguous
40 use sc_mod
41 implicit none
42
43 type(s) :: x
44
45 allocate(t :: x%p(1:10))
46 call foo(x)
47 deallocate(x%p)
48
49 end program select_contiguous
50
51 ! { dg-final { scan-tree-dump-not "_gfortran_stop_numeric" "optimized" } }