blob: 379fbd7f8f9d3c4cf252638a229869282ad54bea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
! { dg-do run }
!
! PR fortran/45019
!
! Check that the compiler knows that
! "arg" and "arr" can alias.
!
MODULE m
IMPLICIT NONE
INTEGER, TARGET :: arr(3)
CONTAINS
SUBROUTINE foobar (arg)
INTEGER, TARGET :: arg(:)
arr(2:3) = arg(1:2)
END SUBROUTINE foobar
END MODULE m
PROGRAM main
USE m
IMPLICIT NONE
arr = (/ 1, 2, 3 /)
CALL bar(arr)
if (any (arr /= (/ 1, 1, 2 /))) call abort()
CALL test()
contains
subroutine bar(x)
INTEGER, TARGET :: x(:)
CALL foobar (x)
end subroutine bar
END PROGRAM main
MODULE m2
IMPLICIT NONE
INTEGER, TARGET :: arr(3)
CONTAINS
SUBROUTINE foobar (arg)
INTEGER, TARGET :: arg(:)
arr(1) = 5
arg(1) = 6
if (arr(1) == 5) call abort()
END SUBROUTINE foobar
END MODULE m2
subroutine test
USE m2
IMPLICIT NONE
arr = (/ 1, 2, 3 /)
CALL bar(arr)
contains
subroutine bar(x)
INTEGER, TARGET :: x(:)
CALL foobar (x)
end subroutine bar
END subroutine test
! { dg-final { cleanup-modules "m m2" } }
|