1! { dg-do compile }
2! { dg-options "-fwhole-file" }
3! Test the fixes for the first two problems in PR40011
4!
5! Contributed by Dominique d'Humieres <dominiq@lps.ens.fr>
6!
7! This function would not compile because -fwhole-file would
8! try repeatedly to resolve the function because of the self
9! reference.
10RECURSIVE FUNCTION eval_args(q)  result (r)
11  INTEGER NNODE
12  PARAMETER (NNODE  = 10)
13  TYPE NODE
14    SEQUENCE
15    INTEGER car
16    INTEGER cdr
17  END TYPE NODE
18  TYPE(NODE) heap(NNODE)
19  INTEGER r, q
20  r = eval_args(heap(q)%cdr)
21END FUNCTION eval_args
22
23function test(n)
24  real, dimension(2) :: test
25  integer            :: n
26  test = n
27  return
28end function test
29
30program arr     ! The error was not picked up causing an ICE
31  real, dimension(2) :: res
32  res = test(2) ! { dg-error "Explicit interface required" }
33  print *, res
34end program
35