OSDN Git Service

PR debug/43329
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / used_types_5.f90
1 ! { dg-do compile }
2 ! Tests the fix for a further regression caused by the
3 ! fix for PR28788, as noted in reply #9 in the Bugzilla
4 ! entry by Martin Reinecke <martin@mpa-garching.mpg.de>.
5 ! The problem was caused by certain types of references
6 ! that point to a deleted derived type symbol, after the
7 ! type has been associated to another namespace. An
8 ! example of this is the specification expression for x
9 ! in subroutine foo below.  At the same time, this tests
10 ! the correct association of typeaa between a module
11 ! procedure and a new definition of the type in MAIN.
12 !
13 module types
14
15   type :: typea
16     sequence
17     integer :: i
18   end type typea
19
20   type :: typeaa
21     sequence
22     integer :: i
23   end type typeaa
24
25   type(typea) :: it = typea(2)
26
27 end module types
28 !------------------------------
29 module global
30
31   use types, only: typea, it
32
33 contains
34
35   subroutine foo (x)
36     use types
37     type(typeaa) :: ca
38     real :: x(it%i)
39     common /c/ ca
40     x = 42.0
41     ca%i = 99
42   end subroutine foo
43
44 end module global
45 !------------------------------
46   use global, only: typea, foo
47   type :: typeaa
48     sequence
49     integer :: i
50   end type typeaa
51   type(typeaa) :: cam
52   real :: x(4)
53   common /c/ cam
54   x = -42.0
55   call foo(x)
56   if (any (x .ne. (/42.0, 42.0, -42.0, -42.0/))) call abort ()
57   if (cam%i .ne. 99) call abort ()
58 end
59 ! { dg-final { cleanup-modules "types global" } }