summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/associate_51.f90
blob: 2e5218c78cf16c53fd17b1da4246c3dc94e6e9ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
! { dg-do compile }
!
! PR fortran/92994
!
! Contributed by G. Steinmetz
!
recursive function f() result(z)
  associate (y1 => f())
  end associate
  associate (y2 => f)  ! { dg-error "is a procedure name" }
  end associate
end

recursive function f2()
  associate (y1 => f2()) ! { dg-error "Invalid association target" }
  end associate          ! { dg-error "Expecting END FUNCTION statement" }
end

recursive function f3()
  associate (y1 => f3)
    print *, y1()  ! { dg-error "Expected array subscript" }
  end associate
  associate (y2 => f3) ! { dg-error "Associate-name 'y2' at \\(1\\) is used as array" }
    print *, y2(1)
  end associate
end

subroutine p2
  type t
  end type
  type(t) :: z = t()
  associate (y => t())
  end associate
end

subroutine p3
  procedure() :: g
  associate (y => g)  ! { dg-error "is a procedure name" }
  end associate
end

subroutine p4
  external :: g
  associate (y => g)  ! { dg-error "is a procedure name" }
  end associate
end

recursive subroutine s
  associate (y => s)  ! { dg-error "is a procedure name" }
  end associate
end

recursive subroutine s2
   associate (y => (s2)) ! { dg-error "is a procedure name" }
   end associate
end

program p
   associate (y => (p)) ! { dg-error "Invalid association target" }
   end associate ! { dg-error "Expecting END PROGRAM statement" }
end