xref: /llvm-project/flang/test/Semantics/declarations06.f90 (revision 3cef82d60796b1f18deebf0d844f38d6e85cd4e7)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! A CLASS() entity must be a dummy argument, allocatable,
3! or object pointer.  Don't get confused with procedure pointers.
4module m
5  type t
6  end type
7  !ERROR: CLASS entity 'v1' must be a dummy argument, allocatable, or object pointer
8  class(t) v1
9  class(t), allocatable :: v2 ! ok
10  class(t), pointer :: v3 ! ok
11  !ERROR: CLASS entity 'p1' must be a dummy argument, allocatable, or object pointer
12  procedure(cf1) :: p1
13  procedure(cf2) :: p2
14  procedure(cf3) :: p3
15  !ERROR: CLASS entity 'pp1' must be a dummy argument, allocatable, or object pointer
16  procedure(cf1), pointer :: pp1
17  procedure(cf2), pointer :: pp2
18  procedure(cf3), pointer :: pp3
19  procedure(cf5), pointer :: pp4 ! ok
20 contains
21  !ERROR: CLASS entity 'cf1' must be a dummy argument, allocatable, or object pointer
22  class(t) function cf1()
23  end
24  class(t) function cf2()
25    allocatable cf2 ! ok
26  end
27  class(t) function cf3()
28    pointer cf3 ! ok
29  end
30  subroutine test(d1,d2,d3)
31    class(t) d1 ! ok
32    !ERROR: CLASS entity 'd2' must be a dummy argument, allocatable, or object pointer
33    class(t), external :: d2
34    !ERROR: CLASS entity 'd3' must be a dummy argument, allocatable, or object pointer
35    class(t), external, pointer :: d3
36  end
37  function cf4()
38    class(t), pointer :: cf4
39    cf4 => v3
40  end
41  function cf5
42    procedure(cf4), pointer :: cf5
43    cf5 => cf4
44  end
45end
46