Debian Codegraph @

gcc/testsuite/gfortran.dg/recursive_reference_2.f90

raw
1 ! { dg-do compile }
2 ! Tests the fix for PR30876 in which interface derived types were
3 ! not always being associated.
4 !
5 ! Contributed by Joost VandeVondele <[email protected]>
6 !
7 MODULE M1
8 CONTAINS
9 FUNCTION correct_input(i)
10 INTEGER :: i,correct_input(5), ans(5) = 0
11 IF (i<1) correct_input=test(1)
12 IF (i>5) correct_input=test(5)
13 END FUNCTION correct_input
14
15 RECURSIVE FUNCTION test(i)
16 INTEGER :: test(5),i,j
17 IF (i<1 .OR. i>5) THEN
18 test=correct_input(i)
19 ELSE
20 test=0
21 test(1:6-i)=(/(j,j=i,5)/)
22 test=test(3)
23 ENDIF
24 END FUNCTION
25
26 END MODULE M1
27
28 USE M1
29 integer :: ans(5)
30 IF (ANY(TEST(3).NE.(/5,5,5,5,5/))) STOP 1
31 IF (ANY(TEST(6).NE.(/0,0,0,0,0/))) STOP 2
32 END