[C++ PATCH] Deprecate -ffriend-injection
[official-gcc.git] / gcc / testsuite / gfortran.dg / nested_modules_3.f90
blob364460c613826604cc76658ec154d8cfaf4796a3
1 ! { dg-do run }
3 ! This tests the improved version of the patch for PR16861. Testing
4 ! after committing the first version, revealed that this test did
5 ! not work but was not regtested for, either.
7 ! Contributed by Paul Thomas <pault@gcc.gnu.org>
9 MODULE foo
10 TYPE type1
11 INTEGER i1
12 END TYPE type1
13 END MODULE
15 MODULE bar
16 CONTAINS
17 SUBROUTINE sub1 (x, y)
18 USE foo
19 TYPE (type1) :: x
20 INTEGER :: y(x%i1)
21 y = 1
22 END SUBROUTINE SUB1
23 SUBROUTINE sub2 (u, v)
24 USE foo
25 TYPE (type1) :: u
26 INTEGER :: v(u%i1)
27 v = 2
28 END SUBROUTINE SUB2
29 END MODULE
31 MODULE foobar
32 USE foo
33 USE bar
34 CONTAINS
35 SUBROUTINE sub3 (s, t)
36 USE foo
37 TYPE (type1) :: s
38 INTEGER :: t(s%i1)
39 t = 3
40 END SUBROUTINE SUB3
41 END MODULE foobar
43 PROGRAM use_foobar
44 USE foo
45 USE foobar
46 INTEGER :: j(3) = 0
47 TYPE (type1) :: z
48 z%i1 = 3
49 CALL sub1 (z, j)
50 z%i1 = 2
51 CALL sub2 (z, j)
52 z%i1 = 1
53 CALL sub3 (z, j)
54 IF (ALL (j.ne.(/3,2,1/))) CALL abort ()
55 END PROGRAM use_foobar