xref: /llvm-project/flang/test/Semantics/implicit14.f90 (revision 1c530b3d9f86422cbc0417ea8ec97a462e9abe26)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2module m
3  type dt
4    procedure(explicit), pointer, nopass :: p
5  end type
6 contains
7  integer function one()
8    one = 1
9  end
10  function onePtr()
11    procedure(one), pointer :: onePtr
12    onePtr => one
13  end
14  function explicit
15    character(:), allocatable :: explicit
16    explicit = "abc"
17  end
18end
19
20program test
21  use m
22  procedure(), pointer :: p0
23  procedure(one), pointer :: p1
24  procedure(integer), pointer :: p2
25  procedure(explicit), pointer :: p3
26  external implicit
27  type(dt) x
28  p0 => one ! ok
29  p0 => onePtr() ! ok
30  p0 => implicit ! ok
31  !ERROR: Procedure pointer 'p0' with implicit interface may not be associated with procedure designator 'explicit' with explicit interface that cannot be called via an implicit interface
32  p0 => explicit
33  p1 => one ! ok
34  p1 => onePtr() ! ok
35  p1 => implicit ! ok
36  !ERROR: Function pointer 'p1' associated with incompatible function designator 'explicit': function results have incompatible attributes
37  p1 => explicit
38  p2 => one ! ok
39  p2 => onePtr() ! ok
40  p2 => implicit ! ok
41  !ERROR: Function pointer 'p2' associated with incompatible function designator 'explicit': function results have incompatible attributes
42  p2 => explicit
43  !ERROR: Function pointer 'p3' associated with incompatible function designator 'one': function results have incompatible attributes
44  p3 => one
45  !ERROR: Procedure pointer 'p3' associated with result of reference to function 'oneptr' that is an incompatible procedure pointer: function results have incompatible attributes
46  p3 => onePtr()
47  p3 => explicit ! ok
48  !ERROR: Procedure pointer 'p3' with explicit interface that cannot be called via an implicit interface cannot be associated with procedure designator with an implicit interface
49  p3 => implicit
50  !ERROR: Procedure pointer 'p' with explicit interface that cannot be called via an implicit interface cannot be associated with procedure designator with an implicit interface
51  x = dt(implicit)
52  !ERROR: Procedure pointer 'p' with explicit interface that cannot be called via an implicit interface cannot be associated with procedure designator with an implicit interface
53  x%p => implicit
54end
55