1! { dg-do compile }
2!
3! PR fortran/92994
4!
5! Contributed by G. Steinmetz
6!
7recursive function f() result(z)
8  associate (y1 => f())
9  end associate
10  associate (y2 => f)  ! { dg-error "is a procedure name" }
11  end associate
12end
13
14recursive function f2()
15  associate (y1 => f2()) ! { dg-error "Invalid association target" }
16  end associate          ! { dg-error "Expecting END FUNCTION statement" }
17end
18
19recursive function f3()
20  associate (y1 => f3)
21    print *, y1()  ! { dg-error "Expected array subscript" }
22  end associate
23  associate (y2 => f3) ! { dg-error "Associate-name 'y2' at \\(1\\) is used as array" }
24    print *, y2(1)
25  end associate
26end
27
28subroutine p2
29  type t
30  end type
31  type(t) :: z = t()
32  associate (y => t())
33  end associate
34end
35
36subroutine p3
37  procedure() :: g
38  associate (y => g)  ! { dg-error "is a procedure name" }
39  end associate
40end
41
42subroutine p4
43  external :: g
44  associate (y => g)  ! { dg-error "is a procedure name" }
45  end associate
46end
47
48recursive subroutine s
49  associate (y => s)  ! { dg-error "is a procedure name" }
50  end associate
51end
52
53recursive subroutine s2
54   associate (y => (s2)) ! { dg-error "Associating selector-expression at .1. yields a procedure" }
55   end associate
56end
57
58program p
59   associate (y => (p)) ! { dg-error "Invalid association target" }
60   end associate ! { dg-error "Expecting END PROGRAM statement" }
61end
62